MATLAB Answers

Translated by

このページのコンテンツは英語から自動翻訳されています。自動翻訳をオフにする場合は「<a class="turn_off_mt" href="#">ここ</a>」をクリックしてください。


Warning: Unable to interpret TeX string

Matlab2010 さんによって質問されました 2013 年 1 月 28 日
I often use greek/ latin variables in my titles/ axis, with no problem.
For example;
figure; title('\bf My Output, \Theta');
comes out fine.
I have just tried to use a latex command for the first time and get the error "Warning: Unable to interpret TeX string "Maxima \hat{V}"
legend('Maxima {\hat V}', 'Location','Best', 'interpreter','latex');
I am using MATLAB 2012A on Win7. I use WinEdt 6 and the latest MikTex Package.
I have seen there is a lot of stuff on this error in the forums, but it seems to be platform dependant. None of the fixes I have found seem to work for me.
any ideas? thank you!

  0 件のコメント

サインイン to comment.


2 件の回答

回答者: José-Luis
2013 年 1 月 28 日
編集済み: José-Luis
2013 年 1 月 28 日

Matlab does not support the full set of latex commands. Please look for the string property in text properties to see the supported commands.

  5 件のコメント

2013 年 1 月 28 日
Be sure to send enhancement requests. TMW considers them.
Daniel Shub
2013 年 1 月 28 日
I am not sure what you mean by MATLAB doesn't support all LaTeX commands. With the LaTeX interpreter the string is essentially processed as if it was inserted unmodified into a standard LaTeX article class document. There are a couple of oddities and limitations, but not many and these can be easily hacked by editing either tex.m or mwarticle.cls
2013 年 1 月 29 日
From the documentation on text properties ( Interpreter ):
Interpret TeXinstructions. Controls whether MATLAB interprets certain characters in the String property as TeX instructions (default) or displays all characters literally.
  • latex — Supports a basic subset of the LaTeX markup language.
  • tex — Supports a subset of plain TeX markup language. See the String property for a list of supported TeX instructions.
  • none — Displays literal characters.
That is what I meant. Matlab is Turing complete, so in a sense it has the potential to support everything. If you have to start editing internal files to get something to work, then it is not supported, at least as far as I understand the term. Also, it might be trivial to you, but it definitely is not trivial to me.

サインイン to comment.

回答者: Daniel Shub
2013 年 1 月 28 日
編集済み: Daniel Shub
2013 年 1 月 28 日

It is very possible that I have screwed up my systems LaTeX processing (I have been playing with it recently). For example, on my system,
title('\bf My Output, \Theta');
doesn't work, but
title('\bf My Output, $\Theta$');
does. Similarly
title('Maxima {\hat V}', 'interpreter','latex')
doesn't work, but
title('Maxima ${\hat V}$', 'interpreter','latex')
Getting LaTeX to work with a legend is apparently a little tricker. Apparently, despite legend objects having an Interpreter property, it cannot be set with
h = legend('Maxima ${\hat V}$', 'Location','Best', 'interpreter','latex');
get(h, 'Interpreter')
Tells you that the interpreter is still tex. It also produces a warning
Warning: Ignoring extra legend entries.
This keys you into the fact that it is treating 'interpreter','latex' as legend entries. If instead you do
h = legend('Maxima ${\hat V}$', 'Location','Best');
set(h, 'Interpreter', 'latex')
everything is fine (despite the warnings). Even better would be
h = legend('XXX', 'Location','Best');
set(h, 'Interpreter', 'latex', 'string', 'Maxima ${\hat V}$');
which avoids all the errors also.

  2 件のコメント

Daniel Shub
2013 年 1 月 28 日

Moved from answer to comment

none wrote:

ok. very odd.

When I do

      title('Maxima ${\hat V}$', 'interpreter','latex')

I can see the latex as its supposed to be.

When I try and do

legend('Maxima ${\hat V}$', 'Location','Best', 'interpreter','latex');

I get "Warning: Unable to interpret TeX string "Maxima ${\hat V}$" "

and the latex does not show properly

Matlab2010 2013 年 1 月 28 日
excellent. thanks !!
plot(1:10); hold all; plot(1:10); plot(1:10);
[legend_h,object_h,plot_h,text_strings] = legend('XXX','YYY','ZZZ', 'Location','Best');
set(legend_h, 'Interpreter', 'latex', 'string', {'Maxima ${\hat X}$','Maxima ${\hat Y}$','Maxima ${\hat Z}$'});

サインイン to comment.

Translated by