maximum number of characters of the latex interpreter?

Hi
I wanted to write a multiline text in a text box with the latex interpreter but found that there seems to be a limit on how many characters I can use. Is there a way around it?
For example the following code works for N<17 but crashes the latex interpreter for N>=17:
N=17;
A=reshape(1:N^2,N,N)';
Na=length(A(:,1));
ltex=cell(Na,1);
for inda=1:Na
ltex{inda}=num2str(A(inda,:));
end
figure
th=text(0.1,0.9,ltex,'interpreter','latex')
set(th,'verticalAlignment','top')

4 comentarios

Oleg Komarov
Oleg Komarov el 12 de Sept. de 2011
What do you need the latex interpreter for?
And besides, you're missing $ in the strings.
What are you trying to achieve?
Fred
Fred el 13 de Sept. de 2011
I'm aware that $ is needed to write math in latex but that is not relevant. The purpose of the code above is just to show that the latex interpreter stops working after you have used certain number of characters.
In practice I'm creating an axes where I use use the text command to output certain results in latex form with greek symbols, etc. However I found that when I have too many lines the interpreter just stops working as in the code above.
Oleg Komarov
Oleg Komarov el 13 de Sept. de 2011
Please correct the above example (since you know):
Warning: Unable to interpret LaTeX string
I'm using R2011a Win32 Vista.
Fred
Fred el 14 de Sept. de 2011
just change first line to N=16

Iniciar sesión para comentar.

 Respuesta aceptada

the cyclist
the cyclist el 13 de Sept. de 2011
According to this section of the documentation:
there is a maximum of string size of 1200 characters for the LaTeX interpreter, and multiline strings reduce the limit (by about 10 characters per line).

3 comentarios

Wording clarification: each line break consumes about 10 characters, so the limit is (total string lengths + 10*number_of_lines <= 1200).
I point this out because when I first read "of about 10 characters per line", I thought the cyclist meant that if you used more than one line, each line could only be 10 characters long.
Fred
Fred el 14 de Sept. de 2011
thanks. That is what I was looking for. So there is a limitation. Too bad. I guess I will just have to use multiple text commands
the cyclist
the cyclist el 14 de Sept. de 2011
Clarified my answer in response to Walter's comment.

Iniciar sesión para comentar.

Más respuestas (1)

Oleg Komarov
Oleg Komarov el 13 de Sept. de 2011
A workaround:
N = 20;
ltex = cellstr(reshape(sprintf('%3.0f\\;',1:N^2).',[],N).');
axes('Ylim',[0,18])
for n = 17:-1:1
th = text(0.02,n,['$' ltex{18-n} '$'],'interpreter','latex');
end

2 comentarios

Fred
Fred el 14 de Sept. de 2011
thanks. I'm aware of this workaround but I just wanted to avoid using multiple text commands since I may want to move the text boxes around dynamically and having multiple text makes it more tedious.
You could put them inside a uipanel() and then they would move together.

Iniciar sesión para comentar.

Categorías

Preguntada:

el 12 de Sept. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by