I have a problem with my MATLAB plots. I need to use tikz/pgf
created figures and display MATLAB plots where I want the font and fontsize to be equal in all figures even if I change the size of the figure in LaTeX. I tried the following, but I have always at least one problem left, using Texmaker on Windows 7.
- Use psfrag package for graphic import. Problem is I get
Unrecoverable error, exit code 1
. Anyway pdflatex finishes and everything is okay, just the psfrag plots are not printed. I tried to find a solution but any of the suggested ifpdf variants didn't work. If I use onlypsfrag
everything is okay.
Code Example:
\documentclass{book}
\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{shapes,external}
\tikzexternalize
\usepackage{psfrag}
\usepackage{auto-pst-pdf}
\begin{document}
\begin{figure}[!htb]
\begin{center}
\psfragfig[width=0.8\textwidth]{images/test.eps}
\end{center}
\end{figure}
\begin{figure}[htb]
\centering
\begin{tikzpicture}[font=\footnotesize]
\node[rectangle, draw] (box)
{Text};
\end{tikzpicture}
\caption{Structure of \textit{User Controller}}
\label{fig:UserController}
\end{figure}
\end{document}
More precisely it creates a *-pics.pdf
file, but its just an empty page. It doesn't create any log file, I just don't know where the problem is. Further it doesn't make a difference if replace the externalization in tikz.
- Use
.eps
Export in MATLAB and create a pdf_tex with Inkscape.
Minimal Example:
\documentclass{book}
\usepackage{graphicx}
\usepackage{epstopdf}
\begin{document}
\include{images/test}
\end{document}
I tried it with graphicx, too, but in both cases the same problem, as can be seen in the picture.
The axes numbering is displaced, the numbers of the y-axis even rotated. I don't understand why this happens, in the eps Original everything is okay.
Another problem of the second trial is, that the use of \centering
or \begin{center}
in the figure environment leads to missing \item
errors I don't understand.
It would be really nice if anybody of you could help me or provide me with another solution how to import MATLAB figures, such that in the end all fonts and fontsizes are suitable.
Thank you very much and please tell me if you need more information.
P.S. Minimal example for graphicx.
\documentclass{book}
\usepackage{graphicx,import}
\usepackage{color}
\begin{document}
\chapter{test chapter}
\begin{figure}[h!]
%\centering
\import{images/}{test.pdf_tex}
\end{figure}
\end{document}
(Activating \centering here leads to the reported error.)
Edit: I tried the use of eps2pgf, too, but it throws an error with my graphics ("Type: Feature not (yet) implemented: TexString for /hyphen is unknown")
Edit 2: For all who have a valid MATLAB license, it happens with all my figures, for example create it with
plot(1:.1:100, sin(1:.1:100));
xlabel('time');
ylabel('Power');
legend('Power');
save it as .eps and convert it with Inkscape.
Edit 3: So now I uploaded the example file: sinus1.eps
.eps
file and add a link here? – Ian Thompson Mar 29 '17 at 8:58.pdf_tex
file. You can use any service to hold the eps – daleif Mar 29 '17 at 14:38.eps
and worked with that file. The conversion to.eps_tex
or.pdf_tex
files was done in inkspace using the appropriate option in the save dialogue. By the way, I uploaded the.eps
file and added the link to my post. – Martin Herrmann Mar 30 '17 at 4:51