Centering multiline text with the LaTeX interpreter

5 views (last 30 days)
To get two-line text on a figure I have to do:
uicontrol('Style','text','Position',[14, -1000,0], 'String',{'line 1','Longer line 2'});
However, if I want the strings to be interpreted by LaTeX, I'd first try:
uicontrol('Style','text','Position',[14, -1000,0], 'String',{'line 1','Longer line 2'}, 'HorizontalAlignment', 'left', 'Interpreter','Latex','FontSize',36);
But the MATLAB doesn't like the interpreter command.
But
text(14, -1000, {'\makebox[4in][c]{text}','\makebox[4in][c]{longer text}'}, 'HorizontalAlignment', 'left', 'Interpreter','Latex','FontSize',36);
Does not produce any text on the figure !
Does anyone know how to get 2 lines of centered text on a figure while being interpreted by LaTeX ?

Answers (1)

Walter Roberson
Walter Roberson on 28 Aug 2012
When that command is given by itself, the position (14,-1000) is outside of the graph limits, so nothing shows up.
If you change to (0,0) for testing purposes, then further experimentation shows that the graph will show up if you change to (e.g.) 4cm rather than 4in .

Community Treasure Hunt

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

Start Hunting!