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

조회 수: 14 (최근 30일)
Leo Simon
Leo Simon 2020년 4월 7일
댓글: Leo Simon 2020년 4월 7일
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
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에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by