for a few days I've been stacked with a problem which no manual or documentation resolved, please help:
I have my 'main.tex' report document file, where I use the 'standalone' package to load the chapter contents, something like this:
\documentclass[12pt,a4paper,oneside]{report}
\usepackage{standalone}
\begin{document}
\input{chapter-about-this}
\input{chapter-about-that}
\end{document}
Inside the 'chapter-about-this.tex' sub-file, I use the 'standalone' package too, this one is to load the charts with plots or another pictures taking hundreds of source code rows:
\documentclass{standalone}
\usepackage{standalone}
\usepackage{pgfplots}
\begin{document}
\chapter{Very important chapter}
Blah blah, look at \ref{fig:super-plot}.
\input{superplot-source-code}
\end{document}
And this nested 'superplot-source-code.tex' sub-file brings the plot:
\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{figure}
\label{fig:super-plot}
\caption{Very strange plot}
...plot...
\end{figure}
\end{document}
When I compile the chapter itself, figure reference is built with no problem. The problem comes, when I try to compile the main report file. Figure's caption has its ordered number, but the referencing text inside the chapter looks like 'Blah blah, look at ??.' - with two question mark instead of 1.2 or something like that.
For example, with the bibliography reference input with \cite command, there is no problem, it gives the number, although the source code with bibliography is also sub-filed with this package (but in 1st level include).
I found out, that compilation with 'latex' has to be done for two or three times to reach all the references. But I'm developing with TeXworks editor and compiling with pdfLaTeX+MakeIndex+BibTex with synctex enabled, which - I hope - should run latex for as many times as needed. So where is the point?


\documentclasscommand in each of the files you input into main.tex. You cannot do that. There can be only one\documentclassin the whole document. Also, packages can only be loaded in the preamble of the document (i.e. before\begin{document}). – Jubobs Mar 14 at 0:06standaloneclass and package – JLDiaz Mar 14 at 0:12