using latex formatting with questdlg

6 views (last 30 days)
George Howell
George Howell on 26 Jul 2018
Answered: TED MOSBY on 2 Jul 2025
Hi all,
I am trying to use make a quick table of previous inputs to display when using questdlg ask a question. I have used the 'tex' interpreter but am struggling to get the formatting just how I want it.
I am currently using this code
load ./settings/previousInputs.mat
opts.Interpreter = 'tex';
opts.Default = 'No';
inputQst = ['Use previous inputs settings? \newline\newline\it', ...
'OS:', compType, '\newline' ...
'Hardware:', hardwareMethod, '\newline', ...
'Transport:', transMethod, '\newline', ...
'Release:', release, '\newline'
];
prevInputs = questdlg(inputQst , ...
'Previous Input Settings', ...
'Yes', 'No', opts);
but the question box appears as;
and ideally I'd like it to be a bit neater and not have half a line put onto a new line?!
I have tried using \tab etc but nothing seems to work?
Any help would be greatly appreciated!

Answers (1)

TED MOSBY
TED MOSBY on 2 Jul 2025
Hi George,
You can try "uiconfirm" as an alternative for the dialog box for a better text formatting.
Below is a code snippet for your use case:
compType = 'Windows 10';
hardwareMethod = 'GPU';
transMethod = 'vdjavdhajsmvefnafsdna ajsfhedvfnsadvas';
release = 'R2024b';
msg = sprintf([ ...
"Use previous input settings?\n\n" + ...
"OS: %s\n" + ...
"Hardware: %s\n" + ...
"Transport: %s\n" + ...
"Release: %s" ], ...
compType, hardwareMethod, transMethod, release);
fig = uifigure;
answer = uiconfirm(fig, msg,'Previous Input Settings', ...
'Options',{'Yes','No'}, ...
'DefaultOption',2, ...
'Interpreter','tex');
delete(fig);
This outputs a dialog box looking like this:
Note that uiconfirm always needs a parent uifigure (that’s why you see the extra window).
Hope this helps!

Categories

Find more on App Building in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!