Warning "Unable to interpret LaTeX string ..."

2 次查看(过去 30 天)
I am getting a very large number of warnings "Unable to interpret LaTeX string ..." while running a MATLAB function that makes a figure with annotations. It is almost as if the warning is printed for every character of processed LaTeX code. Yet the figure is successfully made, so I would like to disable the warning.
What is the identifier of this warning? I found the identifiers 'MATLAB:tex' and 'MATLAB:gui:latexsup:BadTeXString' but they don’t help.
I resorted to "excessive force" but putting my function call between "warnState = warning( 'off' , 'all' ) ;" and "warning( warnState ) ;". But this works in an odd way. When I execute the three calls in a script, I still get the numerous warnings. But when I execute them one by one in the command window, I do not get the warnings. Also, when I put the warning control commands inside the function (at the beginning and the end), I still get the warnings.

回答(2 个)

Jan
Jan 2012-2-21
What is your question?
  • Do you want to find out, why your strings produce the warnings? Then post the strings here such that we can give an advice.
  • Or do you look for a method to suppress the warnings: don't do this. 1. suppressing a warning takes a lot of time, 2. the strings are still not displayed correctly.
  1 个评论
Gilles Gnacadja
Gilles Gnacadja 2012-2-21
Hi Jan,
Thank you for taking interest in my problem.
I actually support the idea that suppressing interpreter or compiler warnings is in general a bad idea. In this case however, that is what I wanted because, as I said, the image is produced just fine.
The call stack seems to indicate that the warning comes from within the MathWorks function createTextBox(). In the source file createTextBox.m, there is an area where MathWorks programmers "disable tex/latex warnings to prevent too much information being output to the command window". It seems that they believe that unnecessary warnings are generated.
Furthermore, the apparently illogical behavior of the "excessive force" option makes me want to better understand how warning control works.
Having said all that, I provide below a toy example of MATLAB code that causes the warning, along with the listing of warnings that is printed.
Thanks again,
Gilles
annotation( hdlFigure , ...
'textbox' , [0.69 0.84 0.21 0.05] , ...
'Interpreter' , 'latex' , ...
'String' , 'The value is $x = 5$' , ...
'HorizontalAlignment' , 'center' , ...
'FontSize' , 24 , ...
'FitBoxToText' , 'off' , ...
'LineStyle' , 'none' ) ;
Warning: Unable to interpret LaTeX string "is $x"
> In scribe.textbox.createTextBox>localGetStrSize at 572
In scribe.textbox.createTextBox>localResizeText at 460
In scribe.textbox.createTextBox>localChangePosition at 341
In scribe.scribeobject.createScribeObject>localUpdatePosition at 48
Warning: Unable to interpret LaTeX string "is $x ="
> In scribe.textbox.createTextBox>localGetStrSize at 572
In scribe.textbox.createTextBox>localResizeText at 460
In scribe.textbox.createTextBox>localChangePosition at 341
In scribe.scribeobject.createScribeObject>localUpdatePosition at 48
Warning: Unable to interpret LaTeX string "5$"
> In scribe.textbox.createTextBox>localGetStrSize at 572
In scribe.textbox.createTextBox>localResizeText at 460
In scribe.textbox.createTextBox>localChangePosition at 341
In scribe.scribeobject.createScribeObject>localUpdatePosition at 48
Warning: Unable to interpret LaTeX string "Thevalueis $x =5$"
> In scribe.textbox.createTextBox>localGetStrSize at 572
In scribe.textbox.createTextBox>localResizeText at 465
In scribe.textbox.createTextBox>localChangePosition at 341
In scribe.scribeobject.createScribeObject>localUpdatePosition at 48
Warning: Unable to interpret LaTeX string "is $x"
> In scribe.textbox.createTextBox>localGetStrSize at 572
In scribe.textbox.createTextBox>localResizeText at 460
In scribe.textbox.createTextBox>localChangePosition at 341
In scribe.scribeobject.createScribeObject>localUpdatePosition at 48
Warning: Unable to interpret LaTeX string "is $x ="
> In scribe.textbox.createTextBox>localGetStrSize at 572
In scribe.textbox.createTextBox>localResizeText at 460
In scribe.textbox.createTextBox>localChangePosition at 341
In scribe.scribeobject.createScribeObject>localUpdatePosition at 48
Warning: Unable to interpret LaTeX string "5$"
> In scribe.textbox.createTextBox>localGetStrSize at 572
In scribe.textbox.createTextBox>localResizeText at 460
In scribe.textbox.createTextBox>localChangePosition at 341
In scribe.scribeobject.createScribeObject>localUpdatePosition at 48
Warning: Unable to interpret LaTeX string "Thevalueis $x =5$"
> In scribe.textbox.createTextBox>localGetStrSize at 572
In scribe.textbox.createTextBox>localResizeText at 465
In scribe.textbox.createTextBox>localChangePosition at 341
In scribe.scribeobject.createScribeObject>localUpdatePosition at 48
Warning: Unable to interpret LaTeX string "Thevalueis $x =5$"
Warning: Unable to interpret LaTeX string "is $x"
> In scribe.textbox.createTextBox>localGetStrSize at 572
In scribe.textbox.createTextBox>localResizeText at 460
In scribe.textbox.createTextBox>localChangePosition at 341
In scribe.scribeobject.createScribeObject>localUpdatePosition at 48
Warning: Unable to interpret LaTeX string "is $x ="
> In scribe.textbox.createTextBox>localGetStrSize at 572
In scribe.textbox.createTextBox>localResizeText at 460
In scribe.textbox.createTextBox>localChangePosition at 341
In scribe.scribeobject.createScribeObject>localUpdatePosition at 48
Warning: Unable to interpret LaTeX string "5$"
> In scribe.textbox.createTextBox>localGetStrSize at 572
In scribe.textbox.createTextBox>localResizeText at 460
In scribe.textbox.createTextBox>localChangePosition at 341
In scribe.scribeobject.createScribeObject>localUpdatePosition at 48
Warning: Unable to interpret LaTeX string "Thevalueis $x =5$"
> In scribe.textbox.createTextBox>localGetStrSize at 572
In scribe.textbox.createTextBox>localResizeText at 465
In scribe.textbox.createTextBox>localChangePosition at 341
In scribe.scribeobject.createScribeObject>localUpdatePosition at 48

请先登录,再进行评论。


Jiro Doke
Jiro Doke 2012-2-21
In case you didn't know, you could suppress certain warnings, like this:
warnState = warning('off', 'MATLAB:gui:latexsup:BadTeXString');
But your other problem is that turning off the warning didn't work when it was called inside a function. Try doing this:
dbstop if warning
And then when you enter debug mode, check the status of the warning. I wonder if there's something in the code that turns it back on.
  5 个评论
Jiro Doke
Jiro Doke 2012-2-22
Gilles,
You can use "lastwarn" function to get the warning ID. Do that when you enter debug mode.
I'm not sure what's going on with your odd warning behavior. Is your figure visualization commands directly in the top-level function? Could they be inside some callbacks? The only thing I can think of is that the vis commands are being called in a subfunction (e.g. callback), and so the warning is being turned back on before the subfunction gets called at some "later time".
Gilles Gnacadja
Gilles Gnacadja 2012-2-22
Jiro,
I think you are right to suspect callbacks. I do not do any explicitly, but I do see many callbacks as MATLAB tries (successfully) to do what I ask for with sizes and positions of text boxes. In one case where I managed to eliminate the warnings (by doing the on/off cycle outside the function), I subsequently get the same warnings when I resize the figure. I am probably doing something suboptimal, but since I get the figures I want, I am going to leave this issue as is.
Thank you very much for your assistance.
Gilles

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by