How to use the latex interpreter properly in appdesigner figures?

10 次查看(过去 30 天)
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.
  1 个评论
Ralf Hillebrand
Ralf Hillebrand 2019-10-8
Part 1.:
You found a problem in the LaTeX parser of the equation renderer, which is used here. The text behind the equation part gets indeed lost. A shorter workaround would be to move text2 into the equation: $test1 \text{test2}$
Part 2:
The tabular environment is not part of the TeX commands supported by the equation renderer. Please check https://www.mathworks.com/help/matlab/matlab_prog/insert-equations.html for the list of supported commands. The array environment is supported though and should do what you want: \begin{array}{cc}1&2\\3&4\end{array}

请先登录,再进行评论。

采纳的回答

Divya Yerraguntla
Divya Yerraguntla 2019-9-19
Hi Rick,
I have brought this issue to the notice of our developers. They will investigate the matter further.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by