MATLAB Answers

0

How to use the latex interpreter properly in appdesigner figures?

Asked by Rick Butler on 21 Jul 2019
Latest activity Edited by Rick Butler on 21 Jul 2019
Part 1:
I'm trying to print LaTeX text which is partly in math mode and partly in text mode to a figure in appdesigner. However, when I put text mode after math mode in the same string, only the text in math mode is displayed. Specifically, the line
text(app.UIAxes, .2, .5, '$test1$ test2', 'Interpreter', 'latex');
plots 'test1' in app.UIAxes and ignores 'test2'. When I take a look at app.UIAxes.Children.String, it does show the entire string I specified.
The same happens when I try to do it for figure titles or axis labels in appdesigner. It doesn't happen when I do it in a separate figure in a new window.
(i.e.,
text(figure(1), .2, .5, '$test1$ test2', 'Interpreter', 'latex');
works fine).
Also,
text(app.UIAxes, .2, .5, 'test1 test2', 'Interpreter', 'latex');
text(app.UIAxes, .2, .5, '$test1 test2$', 'Interpreter', 'latex');
text(app.UIAxes, .2, .5, 'test1 $test2$', 'Interpreter', 'latex');
all work well.
What could cause this to happen?
A workaround could be to plot two strings separately, i.e., something like
text1 = text(app.UIAxes, .2, .5, '$test1$', 'Interpreter', 'latex');
text(app.UIAxes, text1.Extent(1)+text1.Extent(3), text1.Extent(2)+text1.Extent(4)/2, 'test2', 'Interpreter', 'latex');
but I'm wondering if it can be done in one line, as that would be much more convenient.
Part 2:
Similar to part 1, I'm trying to use a tabular in appdesigner, i.e.,
text(app.UIAxes, .2, .5, '\begin{tabular}{cc}1&2\\3&4\end{tabular}', 'Interpreter', 'latex');
but this results in '\begintabularcc1&2\3&4' being plotted. Again, it works fine if I do it in a separate figure. How to do this properly? I suppose a similar workaround as in Part 1 could apply but that seems very tedious.

  0 Comments

Sign in to comment.

Products


Release

R2019a

0 Answers