1

I plot graph in my article with the command '\begin{tikzpicture} ..\end{tikzpicture}'. First, I extract datas from matlab in a text file and I use \addplot with all the options. It is great, but my compilation is very very long ( I have a lot of figures ). Is it possible to have all the figures in tikz external files ( which I can modify sometimes ) and convert into a pdf file (because using \includegraphics with a pdf file is very fast) ?

5

You can process your tikzpictures as standalone documents and then include them as pictures. E.g., the file myplot.tex might contain

\documentclass[border=0.1cm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[...]
  ...
  \end{axis}
\end{tikzpicture}
\end{document}

Your main document then includes the generated pdfs:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics{myplot.pdf}
\end{document}
1

My advise is to put the tikz-code of your plots in separate files as it is easier to manage. I use an alias for \input to include these files just in case it requires special treatment later on.

\documentclass{article}
\newcommand{\tikzinput}[1]{%
    \input{#1}%
}

\begin{document}
\tikzinput{myplot.tikz}
\end{document}

Second, you should use \tikzexternalize to speed up compilation. See the pgfplots manual: 7.1.1 Using the Automatic Externalization Framework of TikZ

\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{external}
\tikzexternalize% activate externalization!

\begin{document}
  \begin{tikzpicture}
  \begin{axis}
  \addplot {x^2};
  \end{axis}
  \end{tikzpicture}
\end{figure}
\end{document}
  • Thanks for your answer, both of you! I don't why, but it does not for one for my figure. I have a double figure which is 4 tikz pictures. ( \begin{figure} \begin{minipage} 2 tikz picture \end{minipage} \end {figure} + the same for the 2 others ). How can i do that? – J.Darmody Sep 15 '16 at 19:06
  • You should create a new question with a minimal example and don't forget to specify your environment (pdflatex, windows, ...). – Manuel Schmidt Sep 16 '16 at 5:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.