필터 지우기
필터 지우기

latex TickLabelInterpreter in Matlab 2011b

조회 수: 2 (최근 30일)
Slade Wilson
Slade Wilson 2017년 5월 19일
답변: Julio Perez Olvera 2020년 5월 2일
Hello,
I am trying to prepare some figures in Matlab for my Latex document. One part is done correctly with
set(0,'DefaultTextFontname', 'CMU Serif');
set(0,'DefaultAxesFontName', 'CMU Serif');
set(0,'defaulttextinterpreter','latex');
however, I can not have tick labels with the same font. I have tried with
set(ax,'TickLabelInterpreter', 'latex');
but I got error
Error using hg.axes/set The name 'TickLabelInterpreter' is not an accessible property for an instance of class 'axes'.
Then I tried with
F = getframe(gca);
set(gca, 'FontName', 'CMU Serif')
and then it is OK in Matlab, but exported eps. file with
saveas(gcf, name,'epsc');
in Latex does not have CMU Serif font on tick labels. However, legend and axis labels have.
Any suggestion? I use Matlab 2011b and obtained figures are attched.
Thanks in advance.

답변 (2개)

KL
KL 2017년 5월 19일
편집: KL 2017년 5월 19일
ax = get(gca,'XTickLabel')
set(gca,'XTickLabel',ax,'FontName','CMU Serif')
  댓글 수: 1
Slade Wilson
Slade Wilson 2017년 5월 19일
편집: Slade Wilson 2017년 5월 22일
Hi KL,
Thank you very much for your answer. It is still the same... It is fine in Matlab, but when exported eps file is compiled with latex, everything but tick labels has CMU Serif font, as it can be seen in attached figures.

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


Julio Perez Olvera
Julio Perez Olvera 2020년 5월 2일
I have the same issue, any ideas why? See the MWE:
set(0,'DefaultTextFontName','Garamond',...
'DefaultTextFontWeight', 'normal', ...
'DefaultTextFontSize',13.5,...
'DefaultAxesFontName','Garamond',...
'DefaultAxesFontWeight', 'normal', ...
'DefaultAxesFontSize',12,...
'DefaultLineLineWidth',1.2,...
'DefaultLegendFontSize',11.5,...
'DefaultLegendFontSizeMode','manual',...
'DefaultLineMarkerSize',8.5,...
'defaulttextinterpreter','latex')
set(0,'DefaultFigureRenderer','opengl');
x=[10:2:1000];
y=[10:2:1000];
n=figure('Units','centimeters',...
'Position',[0 0 width height],...
'PaperPositionMode','auto');
scatter(x,y,10,'filled','^','k')
grid on
ax = gca;
ax.XTick = [0:200:1000];
ax.XTickLabel=({'0','200','400','600','800','1000'});
ax.YTick = [0:200:1000];
ax.YTickLabel=({'0','200','400','600','800','1000'});
txt2 = '234';
text(600,600,'Something','HorizontalAlignment','right','Interpreter','Latex')
ylabel('metres')
xlabel('metres')
title('Test');
outerpos = ax.OuterPosition;
ti = ax.TightInset;
left = outerpos(1) + ti(1);
bottom = outerpos(2) + ti(2);
ax_width = outerpos(3) - ti(1) - ti(3);
ax_height = outerpos(4) - ti(2) - ti(4);
ax.Position = [left bottom ax_width ax_height];
print('-dpng','-r500','Name.png')
print('-depsc2','-r500','Name.eps')

카테고리

Help CenterFile Exchange에서 Discrete Data Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by