Use Matlab 2014b figures (via Inkscape) in pdfTeX
조회 수: 12 (최근 30일)
이전 댓글 표시
Hello everybody,
I know there are many threads related to this topic, but I still could not find a satisfying solution.
Summary: Matlab 2014b figures -> export as .eps or .svg -> load into Inkscape ( problem is in here: text is not recognized ) -> use Inkscpe to save as .pdf_tex -> use in scrreprt document (pdfTeX)
----------
The goal: I want to use different Matlab 2014b plots in a scientific paper. Within those plot I want to use the same LaTeX font as it is used in my scrreprt document.
The problem: When I export or print the Matlab figures as .eps or .svg (possible in 2014b) it is not possible to use the document font (type and size) or access the text (labels, axisticks) Inkscape.
What I've done so far: I used matlab2tikz . This lets me access the plot with the "correct" font. But it does not create the results I want to have. This thread mentions a related problem.
I greated some figures in Inkscape (.svg) and used the export method which provides .pdf_tex files. Then I used \input to include them into the to the document. This works very well ("correct font and nice quality"), so I want to use this method, but in the first place I need to print/export the figures in a way that lets Inkscape read the text as text and notas pixels in a picture.
What is definitely not desired: Setting the Matlab figure 'Interpreter' to 'Latex' looks nice in the figure, but is useless when including it into a latex document
I appreciate any help. Thanks in advance.
댓글 수: 0
답변 (4개)
Nicolas
2015년 10월 31일
편집: Nicolas
2015년 11월 1일
I was struggling with the same problem and I think I may have found a solution. I'm posting this here in case you are still looking for a solution with SVGs and for other people who find this.
I'm using Matlab 2015b and exporting to SVG. I want to use SVG because some things look better than with matlab2tikz, e.g. transparent surfaces. I want text in my figures (labels, ticklabels, annotations) to be saved as text strings s.t. I can include the figure using the procedure described here . If my figure does not contain any complicated latex strings, the text is stored as text and everything works fine.
The problem arises when I have some text that is actually Latex stuff, e.g.
text(0,0,'$\rho$')
This is then saved with the symbol already inserted and the text in the SVG is a vector graphic, not text.
text(0,0,'$\rho$', 'interpreter', 'none')
creates an SVG that still has the '\rho' text, but its a vector graphic.
The Solution
If I do
text(0,0,'$\\rho$')
(i.e. using interpreter 'tex', NOT 'Latex', and NOT 'none') the text is stored as plain ascii text in the SVG file. Note the escaping '\'. Now we can even use custom commands defined in our latex documents. e.g.
text(0,0,'$\\mycommand\{\\rho\}$')
where '\mycommand{}' is some command defined in our Latex environment. Note that we have to escape every backslash '\' and also every curly brace {}.
I hope this helps somebody fighting with Matlab and Latex. (A fight that shouldn't be this hard considering what most people use Matlab for.)
댓글 수: 0
MSleiman
2016년 3월 9일
Fonts can be interpreted by Latex, figures can be adjusted in Inkscape, and you get .pdf, .svg, .pdf_tex formats for your figures.
Mohammad
댓글 수: 2
Jan de Jong
2016년 3월 10일
I hope you think the function is useful. I had the same struggle as you described. I therefore wrote the function Plot2LaTeX. There are improvements possible, but I hope it can help. Especially for the people for who EPS is no longer an option since it is not supported by pdf+LaTeX
andre rossi
2017년 3월 22일
If someone have a similar problem that's what I did: Inkscape did not recognize some fonts that matlab uses. So I copied the matlab fonts from matlab directory to system fonts folder. For linux/mac something like that would work: 1- create a user fonts folder:
mkdir $HOME/.fonts
2- Copy matlab fonts to your user fonts folder
cp /opt/MATLAB/R2016a/sys/fonts/ttf/cm/*.ttf $HOME/.fonts
3- Update font cache
fc-cache
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!