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!