0

I'm preparing a latex document using the input command. There's a separate file for the appendix called appendix.tex. I wish to add references to theorems in the appendix in the main paper, but I don't want to have the appendix in the final compiled pdf. Is there a way to achieve this (without manually cropping pages from the final pdf)?

To elaborate further: Right now, if I don't include \input{appendix}, I get a lot of ?? (broken references) in my pdf. I wish to replace the ?? with the right theorem numbers without including the appendix.

  • 1
    Well, is it very useful to have references to theorems etc. that can't be looked after then, because you omitted the appendix? – user31729 Aug 2 '17 at 19:23
  • Presumably a journal editor has requested that the body of the paper be submitted separately from an online appendix. – pnj Oct 22 '17 at 11:05
1

Please post a MWE next time.


You can do it with a little trick:

Run your appendix.tex via \input{appendix.tex} in an external document. Then use the xr-hyper package to include the external document with \externaldocument{extfile}. Make sure you run the extfile.tex on its own minimum once.

You will have a three file MWE:

Main document

\documentclass{article} 
\usepackage{xr-hyper}
\usepackage{hyperref} 

\externaldocument{extfile} 

\begin{document}
\autoref{sec:external}

\autoref{sec:local}

\section{Local section}\label{sec:local}
% \input{appendix}
\end{document}

External Document

\documentclass{article}
\usepackage{hyperref}

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

Appendix

\section{Appendix}
\label{sec:external}
1

First, I agree with Christian Hupfer. I would be annoyed reading such a document. Second, providing the appendix as an additional PDF may be a good idea, but it's a bit more complicated then goofynos answer suggests, if the page numbers should be continous across both files. And if there are cross references from the appendix to the main part, it get's even more complicated.

But if you really want a PDF file with cross references going nowhere, there are two ways to achieve this. For both you need to compile your PDF with the appendix attached first to get all references right. Then, after some changes to the main file, you need to compile the file one more time to get rid of the appendix.

Solution 1, with \include:

Here you need to add \includeonly{<files>} to the preamble for the last run. <files> is a comma seperated list of all included files with the exception of those for the appendix.

Note that \include always starts a new page.

\documentclass[a4paper]{article}
\usepackage{lipsum}

% uncomment for last run
% comma seperated list of all files except those for appendix
%\includeonly{main}

\begin{document}
\include{main}

\appendix
\include{appendix}

\end{document}

Solution 2, with \input:

Here you need to comment out the files for the appendix and add \nofiles to the preamble. The latter prevents LaTeX from writing auxiliary files, so the informations about the \labels there are not overwritten.

Note: \input does not start a new page.

\documentclass[a4paper]{article}
\usepackage{lipsum}

% uncomment for last run
%\nofiles

\begin{document}
\input{main}

\appendix
% comment out for last run
\input{appendix}

\end{document}

For completeness, main.tex:

\section{Main text}
\lipsum[1]

Reference to appendix: \ref{lia}

\lipsum[2]

and appendix.tex:

\section{Stuff}
\label{lia}
\lipsum[3]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.
https://tex.stackexchange.com/questions/384500/include-references-to-appendix-without-including-appendix
tex.stackexchange.com
crawl=CC-MAIN-2019-47
141014
application/http; msgtype=response
sha1:ZZBTXZRDII2DKVJYSRFOL6DD36Q7HYJK
<urn:uuid:1e44ef69-2679-4428-bdb8-32031373b54a>
2019-11-15T15:18:53Z
151.101.1.69
text/html
sha1:OFSFHMZL3HDJW64XYTFSBUCLF5EOQSX2
<urn:uuid:92556880-e111-4cc7-b292-e8d426004a5f>
https://tex.stackexchange.com/questions/384500/include-references-to-appendix-without-including-appendix
response
<urn:uuid:85fcf082-4e0b-489b-9412-c785c0a3cc6e>
isPartOf: CC-MAIN-2019-47
publisher: Common Crawl
description: Wide crawl of the web for November 2019
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-37.ec2.internal
software: Apache Nutch 1.16 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.1-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: http://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/