Mimicking the font that title() uses when calling it with latex interpreter

4 次查看(过去 30 天)
The command
h1 = title('TITLE')
brings up a title in a heavy bold font. I would like the command
h2 = title('$\nabla$ TITLE','Interpreter','latex')
creates the title in a wishy-washy font. Adding \bfseries, as in
h3 = title('{\bfseries $\nabla$ TITLE}','Interpreter','latex')
makes it a bit better, but still not as bold as without the Interpreter? What's really wierd is that for x=1,3
hx.FontWeight = 'bold' ; hx.FontSize=11
I know that for most latex commands, e.g., \alpha,
title('\alpha TTITLE')
will produce the desired font weight, but unfortunately, there are lots of matlab commands, like \nabla, which aren't supported in this way.
Is there a solution to this issue, i.e., a way to mimic the default title font and size using the interpreter? Thanks very much.
  1 个评论
Tommy 2020-4-7
Note, from the reference page for text:
"The displayed text uses the default LaTeX font style. The FontName, FontWeight, and FontAngle properties do not have an effect. To change the font style, use LaTeX markup."
As you have found, you can use some LaTeX commands, such as \textbf, but it seems like many other commands are not supported. A bold sans-serif font won't be as 'wishy-washy'. When I try to set the font to sans-serif family, I get a warning:
>> title('\textsf{TITLE}', 'Interpreter', 'latex')
Warning: Error updating Text.
Font cmss10 is not supported.
Warning: Error updating Text.
Font cmss10 is not supported.
but the title does show in a sans-serif font. Adding \textbf changes the title ever so slightly, but it doesn't quite get you what you want:
See here - that sweet sweet bold sans serif font was apparently available in 2010a but not 2011b.
You can play around with the different options, but there doesn't seem to be much flexibility.
Also: \nabla is available in TeX, the default interpreter. That reference page for text that I linked above has all of the supported special characters and modifiers for TeX. You might want to give it a look before deciding that you need LaTeX.


回答(1 个)

Peter O
Peter O 2020-4-7
Try using the Tex interpreter with the \bf switch?
title('\bf\nabla TITLE','Interpreter','tex') seems to get the bold you're looking for (I'm on 2019b)
The tex interpreter is MATLAB's usual way of producing the special symbols like nabla and alpha, and it has slightly different bold/color/italic switches than the full-fledged LaTeX interpreter.
See https://www.mathworks.com/help/matlab/creating_plots/greek-letters-and-special-characters-in-graph-text.html#bux4rpf
  1 个评论
Leo Simon
Leo Simon 2020-4-7
Thanks veyr much @Peter and @Tommy,
You're right @Peter, indeed \nabla is supported. Solves my problem for this application, but not in general since there are other latex symbols that are not supported.
It would be nice if MathWorks would fix this silly thing, which must be very easy to fix.



Help CenterFile Exchange 中查找有关 Graphics Object Properties 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by