using latex formatting with questdlg

조회 수: 3 (최근 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 CenterFile Exchange에서 App Building에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by