필터 지우기
필터 지우기

How can I include the permil (parts per thousand) symbol in a plot with the LaTex inpreter?

조회 수: 49 (최근 30일)
Does anyone know of a way to include the permil (parts per thousand) symbol in a MATLAB plot with the LaTex interpreter?

답변 (6개)

Ilham Hardy
Ilham Hardy 2013년 8월 20일
편집: Ilham Hardy 2013년 8월 20일
Jiro Doke's solution:
slabel(['5 ',char(8240)])
  댓글 수: 1
Christian Spathelf
Christian Spathelf 2013년 8월 27일
Thanks for the reply, but MATLAB does not accept slabel for my plot (or I am using it incorrectly). Below is an example of my code for the y-axis description:
ylabel({'$\varepsilon_{s,max}$\,[\permil]'}, 'Interpreter','latex');

댓글을 달려면 로그인하십시오.


Thomas Deneux
Thomas Deneux 2013년 10월 23일
hi, i ran into the same problem and used the following solution: '5^{\fontsize{7}o}/{\fontsize{7}oo}'. It's not a proper permil symbol, but the rendering is good enough. You might want to change 7 to another font size. It works with the default 'tex' interpreter.

Walter Roberson
Walter Roberson 2013년 8월 27일
  댓글 수: 1
Christian Spathelf
Christian Spathelf 2013년 8월 28일
Thanks for the response Walter. I have been reduced to manually changing the symbol in Adobe Illustrator and saving the figure as EPS. Not so elegant, but it works.

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2017년 12월 24일
As of R2014b, you can include char(8240) in any text object with interpreter 'none' or interpreter 'tex' -- but not with interpreter 'latex'

Yigal Barkan
Yigal Barkan 2017년 12월 25일
Hi Christian.
I had encountered the same problem and found a creative way to overcome it, because it seemed there's no real solution as these characters are omitted in the system.
My solution is quite straightforward. you take the location of the label after it's drawn and add a text in a proper location using the default TEX interpreter with only the permil sign. The location comes out correct in most cases, but can be adjusted if not.
ylabh=ylabel('$\mathrm{1000ln{\alpha}_{A-B}}\quad$','interpreter','latex','Color','k');
xy=ylabh.Extent;
text(xy(1)+xy(3)/2,(xy(2)+xy(4))*1,'[‰]','Rotation',90,'HorizontalAlignment','center');
-it doesn't always work with "xy(3)/2" and "xy(4)*1, so the factors (2 and 1) might need to be changed.
-note that Latex interpreter always draws in somekind of grey, therefore I specifically choose 'k' as color text color when Latex is used.
Hope this helps,
Yigal

Philipp Lauff
Philipp Lauff 2023년 4월 18일
편집: Philipp Lauff 2023년 4월 18일
Hey guys,
if you install the font 'LMRoman12' on your system, you can use the following syntax:
xlabel('strain \epsilon_{t} [‰]','FontName','LMRoman12-Regular')
It uses Matlab's default interpreter Tex with the font of Latex. However, the subscript position is not the same in tex and latex, so there is a small difference. Still this looks the best to me.
Have fun!
Philipp
Edit: When exporting the diagram then to pdf or eps, Matlab comes back to a normal (non-latex) font. To prevent this, use the '-dsvg' option:
print('-vector',filename, '-dsvg')

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by