using latex formatting with questdlg

6 ビュー (過去 30 日間)
George Howell
George Howell 2018 年 7 月 26 日
回答済み: TED MOSBY 2025 年 7 月 2 日
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!

回答 (1 件)

TED MOSBY
TED MOSBY 2025 年 7 月 2 日
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!

カテゴリ

Help Center および File ExchangeApp Building についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by