Are there limitations in length of latex interpreted - expression in msgbox?

3 Ansichten (letzte 30 Tage)
krissk
krissk am 23 Aug. 2016
Kommentiert: Jon White am 22 Sep. 2020
This might be just a bit of a curiosity regarding the latex interpreter in msgbox.
I have an expression I want to display (mess_stringequiv), but am not able to get it right. I get a blank box and the message "Unable to interpret TeX string", when I include this one.
However, if I modify it slightly (e.g. mess_stringequiv5), it is no problem. The code under illustrates some trial of workarounds. Is there a way to get the string in mess_stringequiv to be displayed in a messagebox?
If not, is this due to the textwrap length setting in the msgbox (and is it possible to change that one)?
% code
clear all
clc
sz = get( 0, 'Screensize' );
CreateStruct.Interpreter = 'latex';
CreateStruct.WindowStyle = 'modal';
mess_stringequiv = ['$e= \frac{2}{\sqrt{3}} \ln((1 + \frac{\gamma^2}{2})^{0.5} + \frac{\gamma}{2}):$'];
mess_stringequiv2 = ['$e= 2/\sqrt{3}$',' ','$\ln((1 + \frac{\gamma^2}{4})^{0.5} + \frac{\gamma}{2})$: '];
mess_stringequiv3 = ['$e= \frac{2}{3}$',' ','$\ln((1 + \frac{\gamma^2}{4})^{0.5} + \frac{\gamma}{2})$: '];
mess_stringequiv4 = ['$e= \frac{2}{\sqrt{3}} \ln\left((1 + \frac{\gamma^2}{2})^{0.5}\right):$'];
mess_stringequiv5 = ['$e= \frac{2}{\sqrt{3}} \ln((1 + \frac{\gamma^2}{2})^{0.5} + \gamma/2):$'];
h = msgbox({mess_stringequiv2;mess_stringequiv3;mess_stringequiv4;mess_stringequiv5},'Success',CreateStruct);
ah = get( h, 'CurrentAxes' );
ch = get( ah, 'Children' );
set( ch, 'FontSize', 12 );
set(h, 'position', [(sz(3)-300)/2 (sz(4)-300)/2 300 300] ); %makes box bigger
waitfor(h)
close all
I am using MATLAB R2009a.
Thanks!

Antworten (1)

Natch Ruengsakulrach
Natch Ruengsakulrach am 1 Sep. 2016
There is a bug in the way that "msgbox" always automatically wraps the text at 75 characters, regardless of which Interpreter is used. This may modify your LaTeX string into something which is no longer valid LaTeX syntax.
I have attached “mymsgbox.m” as a workaround. I work for MathWorks and have forwarded this feedback to the appropriate product team.
mess_stringequiv = ['$e= \frac{2}{\sqrt{3}} \ln((1 + \frac{\gamma^2}{2})^{0.5} + \frac{\gamma}{2}):$ '];
mess_stringequiv2 = ['$e= 2/\sqrt{3}$',' ','$\ln((1 + \frac{\gamma^2}{4})^{0.5} + \frac{\gamma}{2})$: '];
mess_stringequiv3 = ['$e= \frac{2}{3}$',' ','$\ln((1 + \frac{\gamma^2}{4})^{0.5} + \frac{\gamma}{2})$: '];
mess_stringequiv4 = ['$e= \frac{2}{\sqrt{3}} \ln\left((1 + \frac{\gamma^2}{2})^{0.5}\right):$'];
mess_stringequiv5 = ['$e= \frac{2}{\sqrt{3}} \ln((1 + \frac{\gamma^2}{2})^{0.5} + \gamma/2):$'];
h = mymsgbox({mess_stringequiv;mess_stringequiv2;mess_stringequiv3;mess_stringequiv4;mess_stringequiv5},'Success',CreateStruct);
  3 Kommentare
Juan Estrella-Martínez
Juan Estrella-Martínez am 19 Jun. 2020
Hey mate! I'm writing a script and would like to use the attached code. How should I credit you? Didn't see your info in the code.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by