This question seems to adress the same issue but without solution either: https://nl.mathworks.com/matlabcentral/answers/349223-why-is-the-latex-font-not-selectable-in-eps-export
Using latex interpreter makes eps figures pixelated
조회 수: 22 (최근 30일)
이전 댓글 표시
I'm making some figures in Matlab to use in a latex document.
To make sure the figures are vectorized in the final document I'm saving them as .eps files with the following command:
saveas(gcf, 'filename', 'epsc2')
This works as expected.
To make the style of the figures match the rest of the document, I set all the interpreters to 'latex' with these commands:
set(groot, 'defaultAxesTickLabelInterpreter','latex');
set(groot, 'defaultLegendInterpreter','latex');
set(0, 'defaulttextInterpreter','latex');
However, this causes the figures in the document to become pixelated. The figure quality is still quite okay, the pixelation is not super noticeable but the text is not searchable anymore in the final document.
How can I use the latex interpreters while still having nice vectorized eps figures?
Setting the renderer to Painters does not change the issue.
Thanks for your help
채택된 답변
Suraj
2023년 4월 25일
The pixelation you are seeing may be due to the way that LaTeX and EPS files handle text. When you set the interpreter to 'latex', MATLAB generates an EPS file with LaTeX code embedded in the file. However, the text in the EPS file is not vectorized, and will be rendered by LaTeX as rasterized text, resulting in the pixelation you see.
One solution is to use the “matlab2tikz” package to export your figures to a TikZ file, which can then be compiled in LaTeX. TikZ is a vector graphics language that can be used to generate high-quality figures in LaTeX. When you export a figure to a TikZ file, the text is converted to vector paths, which ensures that the text will be searchable and that the figure will be fully vectorized.
To use "matlab2tikz", you will need to install the package and add it to your MATLAB path. Once you have done that, you can use the following code to export a figure to a TikZ file:
% Set the interpreter to 'latex'
set(groot, 'defaultAxesTickLabelInterpreter','latex');
set(groot, 'defaultLegendInterpreter','latex');
set(0, 'defaulttextInterpreter','latex');
% Plot your figure
% plot(…)
% Export the figure to a TikZ file
matlab2tikz('filename.tikz', 'figurehandle', gcf);
This will create a TikZ file named 'filename.tikz' in your current directory.
You can then include this file in your LaTeX document using the following command -
\input{filename.tikz}
You may refer to the "matlab2tikz” documentation page for more details - https://www.mathworks.com/matlabcentral/fileexchange/22022-matlab2tikz-matlab2tikz
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Printing and Saving에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!