Skip to content

Instantly share code, notes, and snippets.

@mblondel

mblondel/xref.txt

Created May 10, 2013
Embed
What would you like to do?
Cross-referencing in LaTeX.
paper.tex: main manuscript
supp.tex: supplementary material
Cross-referencing
-----------------
We want to cross-reference equations in paper.tex from supp.tex.
Add the following to supp.tex:
\usepackage{xr}
\externaldocument{paper}
Then use \ref, \eqref, \section etc normally.
Equation numbering
------------------
In order for the equation numbering in supp.tex to start from the last equation
in paper.tex, add the following to paper.tex:
\usepackage{newfile}
[...]
\newoutputstream{stream}
\openoutputfile{counters}{stream}
\addtostream{stream}{
\protect\setcounter{equation}{\arabic{equation}}%
}
\closeoutputstream{stream}
\end{document}
This will save the equation counter to a file named "counters".
Other counters include: part, chapter, section, subsection, subsubsection,
paragraph, subparagraph, page, equation, figure, table, footnote, mpfootnote
Then include the "counters" file in supp.tex:
\input{counters}
\addtocounter{equation}{1}
To get the references correctly, each file must be compiled with pdflatex two
(or three) times.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment