Created
May 10, 2013 09:43
-
-
Save mblondel/5553469 to your computer and use it in GitHub Desktop.
Cross-referencing in LaTeX.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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