1

document.tex:

\documentclass{article}

\usepackage{standalone}
\usepackage{pgfplotstable}

\begin{document}
\input{plot.tex}
\end{document}

plot.tex:

\documentclass{standalone}

\usepackage{pgfplotstable}

\pgfplotstableread{
  X Y
  1 2
  3 4
}\table

\begin{document}
\begin{tikzpicture}
  \begin{axis}
    \addplot table {\table};
  \end{axis}
\end{tikzpicture}
\end{document}

Compile with:

pdflatex document.tex

And I obtain:


(./plot.tex

! LaTeX Error: Not in outer par mode.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.14     \addplot table {\table};

? 
! Emergency stop.
 ...                                              

l.14     \addplot table {\table};

!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on document.log.

The standalone file compiles just fine, I only get that error if I try to include it in another document. Why does this happen and what are my options here?

cYrus
  • 111

1 Answers1

0

As Ulrike Fischer commented, the solution is to move \pgfplotstableread inside \begin{document}:

\documentclass{standalone}

\usepackage{pgfplotstable}

\begin{document}
%%%%%%%%%%%%%%%%%%%
\pgfplotstableread{
  X Y
  1 2
  3 4
}\table
%%%%%%%%%%%%%%%%%%%
\begin{tikzpicture}
  \begin{axis}
    \addplot table {\table};
  \end{axis}
\end{tikzpicture}
\end{document}
cYrus
  • 111