How to use the latex interpreter properly in appdesigner figures?

10 ビュー (過去 30 日間)
Rick Butler
Rick Butler 2019 年 7 月 21 日
コメント済み: Ralf Hillebrand 2019 年 10 月 8 日
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 Center および File ExchangeGet 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