Mimicking the font that title() uses when calling it with latex interpreter
조회 수: 5 (최근 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일
"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:
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
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Entering Commands에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!