2

I have a set of TeX documents {d}. These documents need to refer to one another. To achieve this, I have a references.bib with one entry for each document in {d}. Inside each element of {d}, there are various \cite lines referring to the elements in references.bib.

Now I write a PhD thesis and I want to include the items in {d} as appendices. If I \cite them, they show up in the text as e.g. "[4]", which is not how one normally refers to appendices. I want references to the appendices to show up as e.g. "Appendix A". How an we achieve this?

If I \label the elements in {d} and then \ref them in the main text, I get what we want. However, this fails where the appendices refer to each other, because they would have to use \cite when compiled alone and \ref when part of the PhD thesis.

Is there a solution? The best thing I've thought of is making a separate appendices.bib for the PhD thesis. The question then becomes, how do I make the \cite commands show only the referent's title and also prevent the referred item from showing up in the bibliography?

Minimal Working Example

The following files are just a set of stand-alone documents (the set {d} described above). In bananaMilkshake.tex, there is a normal citation using \cite.

./banana-docs/bananaMilkshake.tex

\documentclass{report}

\usepackage{import}

\begin{document}

\subimport*{./}{bananaMilkshake-content}

\bibliographystyle{plain}
\bibliography{references}

\end{document}

./banana-docs/bananaMilkshake-content.tex

First, peel a banana \cite{Sank:peelBanana}.
Then put it in the blender.

./banana-docs/peelBanana.tex

\documentclass{report}

\usepackage{import}

\begin{document}

\subimport*{./}{peelBanana-content}

\end{document}

./banana-docs/peelBanana-content.tex

Separate the top part and then pull the peel off in three sections.

./banana-docs/references.bib

@misc{Sank:bananaMilkshake,
  author = {Sank, Daniel},
  title={How to Make a Banana Milkshake}
}

@misc{Sank:peelBanana,
  author = {Sank, Daniel},
  title={How to Peel a Banana}
}

Now we have a PhD thesis which wants to use the documents defined above as appendices:

./thesis.tex

\documentclass{report}

\usepackage{import}
\usepackage{appendix}

\begin{document}

For details on how to make a banana milkshake, see appendix \ref{appendix:bananaMilkshake}.

\subimport*{./}{appendix}

\bibliographystyle{plain}
\bibliography{banana-docs/references}

\end{document}

./appendix.tex

\begin{appendices}

\chapter{How to Make a Banana Milkshake} \label{appendix:bananaMilkshake}
\subimport*{./banana-docs/}{bananaMilkshake-content}

\chapter{How to Peel a Banana} \label{appendix:peelBanana}
\subimport*{./banana-docs/}{peelBanana-content}

\end{appendices}

If you build thesis.tex, you find a line

For details on how to make a banana milkshake, see appendix A.

which is nice. However, in appendix A, you see

First, peel a banana [1]. Then put it in the blender.

and in the bibliography you see

[1] Daniel Sank. How to peel a banana.

which is not so nice. You want to be able to \ref Appendix B from within Appendix A, but you can't because a \ref in bananaMilkshake.tex has nothing to point to.

One thing that almost works is to make a separate .bib file for the thesis and \ref to the appendices inside it. This at least puts "Appendix A" in the bibliography, but that's not quite what we want.

  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. That said, creating a new \if which is set to true in the thesis only and defining a new command which \cites or \refs depending on that \if might work? – greyshade Aug 31 '14 at 18:48
  • @greyshade: Added MWE. I don't understand how to use the switch you suggest though, because then I'd have to use my new command in every document I might ever want to include in an appendix. – DanielSank Aug 31 '14 at 21:54
1

I have figured out how to do this. The basic idea is to use a home-made macro name in place of \cite and define that macro differently based on whether we're compiling as a stand-alone document or as part of a thesis. A complete example is shown below. Do not be intimidated by the large number of files; what's actually going on is really simple so just follow each step.

/cite_as_appendix.tex

\newcommand{\mycitetype}{Appendix}
\newcommand{\mycite}[1]{
  \ref{#1}
}

/cite_as_external.tex

\newcommand{\mycitetype}{Ref.}
\newcommand{\mycite}[1]{
  \cite{#1}
}

/packages.tex

\usepackage{import}

/references-local.bib

@misc{qubits,
author = {Sank, Daniel},
title = {Qubits}
}

@misc{iq_mixer,
author = {Sank, Daniel},
title = {IQ mixer}
}

/iq-mixer/as-article.tex

\documentclass{article}
\input{../packages.tex}
\input{../cite_as_external.tex}
\author{Daniel Sank}
\title{IQ Mixer}
\begin{document}
\maketitle
\subimport*{./}{content}
\bibliographystyle{plain} \bibliography{../references-local}    
\end{document}

/iq-mixer/as-appendix.tex

\chapter{IQ Mixer} \label{iq_mixer}
\input{content.tex}

/iq-mixer/content.tex

This is a discussion of IQ mixers.
It will be useful when reading \mycitetype \mycite{qubits}.

/qubits/as-article.tex

\documentclass{article}
\input{../packages.tex}
\input{../cite_as_external.tex}
\author{Daniel Sank}
\title{Qubits}
\begin{document}
\maketitle
\subimport*{./}{content}
\bibliographystyle{plain} \bibliography{../references-local}    
\end{document}

/qubits/as-appendix.tex

\chapter{Qubits} \label{qubits}
\input{content.tex}

/qubits/content.tex

This is a discussion of qubits.
You should read \mycitetype \mycite{iq_mixer} first.

/thesis/main.tex

\documentclass{book}

\input{../packages.tex}
\input{../cite_as_appendix.tex}
\author{Daniel Sank} \title{Book}
\begin{document}
\maketitle
\tableofcontents

\chapter{Introduction}
This is a book about quantum computing.

\chapter{Science!}
To understand superconducting qubits, you should read \mycitetype \mycite{qubits} and \mycitetype \mycite{iq_mixer}.

\begin{appendix}
\subimport*{../iq-mixer/}{as-appendix}
\subimport*{../qubits/}{as-appendix}
\end{appendix}

\end{document}

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.