[Tex/LaTex] Same pgfplots within standalone for usage in elsarticle and revtex4-1

best practiceselsarticlepgfplotsrevtexstandalone

Suppose I have created a plot with pgfplots for a scientific paper.

However, for usual reasons the targeted journal is not certain. Possibly the plot has to be adjusted to match different journals (consider here revtex4-1 and elsarticle). This includes font type, font sizes, columnwidths/textwidths.

For instance, the values of the \columnwidth differ:

% \documentclass[preprint,5p,twocolumn,12pt]{elsarticle}
\the\columnwidth=252.0pt
% \documentclass[aps,final,pre,twocolumn,10pt]{revtex4-1}
\the\columnwidth=246.0pt

I have considered the package standalone:

plot.tex:

\documentclass[class=elsarticle,5p,twocolumn,12pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.5}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
width=\columnwidth,
title=Inv. cum. normal,
xlabel={$x$},
ylabel={$y$},
]
\addplot[blue] table {invcum.dat};
\end{axis}
\end{tikzpicture}
\end{document}

download invcum.dat

paper.tex:

\documentclass[preprint,5p,twocolumn,12pt]{elsarticle}
\usepackage{lipsum}
\usepackage{graphicx}
\begin{document}
\setlength{\parindent}{0ex}
\lipsum[1]\vspace*{2ex}
\begin{figure}
  \centering
  \includegraphics{plot}
  \caption{interesting results}
\end{figure}
\vspace*{2ex}\lipsum[2]
\end{document}

After the paper got rejected :(, the documentclass gets changed.

paper.tex

\documentclass[final,aps,pre,twocolumn,10pt]{revtex4-1}

plot.tex

\documentclass[class=revtex4-1,final,aps,pre,twocolumn,10pt]{standalone}

For some reason standalone fails to accept as class option revtex4-1.

What would be a good workflow to minimize the workload using pdflatex without using dvi-eps path. Quantities, which should be available to plotting, are font size, \columnwidth and \textwidth.

An answer with a gnuplot+standalone solution would be a good addition.

Related questions:

Best Answer

You can use \includestandalone from standalone package (requires -shell-escape).

plot.tex:

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.5}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
width=\columnwidth,
title=Inv. cum. normal,
xlabel={$x$},
ylabel={$y$},
]
\addplot[blue] table {invcum.dat};
\end{axis}
\end{tikzpicture}
\end{document}

Then in elsarticle:

\documentclass[preprint,twocolumn,12pt]{elsarticle}
\usepackage{lipsum}
\usepackage{graphicx}
%\usepackage{pgfplots}
%\pgfplotsset{compat=1.5}
\usepackage[subpreambles=true]{standalone}
\begin{document}
\setlength{\parindent}{0ex}
\lipsum[1]\vspace*{2ex}
\begin{figure}
  \centering
  \includestandalone[mode=buildnew]{plot}
  %\includegraphics{plot}
  \caption{interesting results}
\end{figure}
\vspace*{2ex}\lipsum[2]
\end{document}

enter image description here

And in revtex4-1

\documentclass[final,aps,pre,twocolumn,10pt]{revtex4-1}
\usepackage{lipsum}
\usepackage{graphicx}
%\usepackage{pgfplots}
%\pgfplotsset{compat=1.5}
\usepackage[subpreambles=true]{standalone}
\begin{document}
\setlength{\parindent}{0ex}
\lipsum[1]\vspace*{2ex}
\begin{figure}
  \centering
  \includestandalone[mode=buildnew]{plot}
  %\includegraphics{plot}
  \caption{interesting results}
\end{figure}
\vspace*{2ex}\lipsum[2]
\end{document}

enter image description here

Now, for curiosity, try with a big font size and different font.

\documentclass[18pt]{scrartcl}
\usepackage{lipsum}
\usepackage{mathpazo}
\usepackage{graphicx}
%\usepackage{pgfplots}
%\pgfplotsset{compat=1.5}
\usepackage[subpreambles=true]{standalone}
\begin{document}
\setlength{\parindent}{0ex}
\lipsum[1]\vspace*{2ex}
\begin{figure}
  \centering
  \includestandalone[mode=buildnew]{plot}
  %\includegraphics{plot}
  \caption{interesting results}
\end{figure}
\vspace*{2ex}\lipsum[2]
\end{document}

enter image description here

Related Question