How to use the latex interpreter properly in appdesigner figures?
조회 수: 6 (최근 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
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
2019년 9월 19일
Hi Rick,
I have brought this issue to the notice of our developers. They will investigate the matter further.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!