0

I'm writing on a large document with many tables. Rules require me to provide every table as a standalone PDF file as well, so I do this:

In main.tex:

\documentclass{article}
\usepackage{standalone}
\begin{document}
\section{Hello}\label{sec:hello}
\input{table}
\end{document}

In table.tex

\documentclass[float=true,preview=true]{standalone}
\begin{document}
\begin{table}
\begin{tabular}{c}
   A table in section \ref{sec:hello}
\end{tabular}
\caption{A Table}
\end{table}
\end{document}

Now, at first glance, this works nicely. However, in the standalone version of the table, the section reference is broken for obvious reasons, since LaTeX doesn't know about the section in the standalone file.

I suppose there is some hack to make this work by making LaTeX use the main.aux when compiling table.tex, but I can't really think of a nice way to handle this. Any suggestions?

carsten
  • 2,966
  • 4
  • Do you need captions in those standalone table files? If you remove the table environmentfromtable.texand use\includestandalone` then things will work. –  Nov 05 '15 at 05:12
  • 1
    I'm not sure whether I need the captions, I need to check, but xr seems to work as intended, thanks! – carsten Nov 05 '15 at 05:28
  • Oh, I just discovered one more thing: It would be nice if the tables also had the correct numbers in the standalone. Would this be possible? – carsten Nov 05 '15 at 05:41
  • @carsten: What does "correct numbers" mean? – Werner Nov 05 '15 at 06:15
  • @Werner: Let's say I have two tables. When compiling main.tex, LaTeX assigns them the numbers 1 and 2. Now, compiling the standalone versions, they both get called "Table 1", since they are each the first table in the standalone document. I would like the captions in the standalone to state the table numbers as given in the main document. – carsten Nov 05 '15 at 20:23
  • That's one of the drawbacks of creating separate standalone documents for content. You may consider using only whatever you have within the document environment instead. If there's no reason for using file in the standalone format, then I'd suggest doing that. – Werner Nov 05 '15 at 20:33

0 Answers0