2

I was using the cite package and encountered a problem with it. The citation number sometimes remains "[?]"; even after several compiling cycles. Here is MWE and its outcome:

\documentclass{article}
\usepackage{cite}

\begin{document}
This is a MWE. This citation~\cite{foo} works correctly but this one~\cite{bib: bar} doesn't.

\begin{thebibliography}{2}
\bibitem{foo} foo
\bibitem{bib: bar} bar
\end{thebibliography}

\end{document}

enter image description here

It seems this problem occurs when \bibitem's parameter includes space like \bibitem{bib: bar} bar.

Can anyone solve this problem?

P.S. Further information such as an solution without abondoning my habit would be appreciated.

  • What do you need the space for in bibitem{bib: bar}? – Ruben Dec 16 '14 at 22:14
  • It's merely my habit. I always write labels and bibliography items like \label{eq: foo} or \label{fig: foo} in order to give the same name to different objects (equation, figure, table, etc.). – Merzong Dec 16 '14 at 22:27
  • Regarding your P.S.: With the solution I showed you, you can still write \cite{bib: bar} in the manuscript. – Ruben Dec 17 '14 at 0:28
2

The Problem is that \cite eats the spacetokens when writing to the main auxiliary file; i.e., even if you say \cite{bib: bar} the resulting entry in the .aux would look like \citation{bib:bar}. But, when the engine is looking for \bibcite{bib:bar}... it won't find anything because \bibitem preserves all the spaces in the input.

You can leave the citations in the desired form, e.g. \cite{bib: bar} if you don't want to abandon your labeling habit, but you have to write \bibitem{bib:bar} ... in the thebibliography environment:

\documentclass{article}
\usepackage{cite}

\begin{document}
This is a MWE. This citation~\cite{foo} works correctly and this one~\cite{bib: bar} too, though there is a space in between the label name. 

\begin{thebibliography}{2}
\bibitem{foo} foo
\bibitem{bib:bar} bar
\end{thebibliography}
\end{document}

output

  • Thank you for the answer. The reason I write labels in this style is that I think putting words after colon without space is grammatically incorrect. Anyway I understood why my MWE didn't work. – Merzong Dec 16 '14 at 23:06
  • 1
    The interpunction-space-rule you are refering to holds for typeset text. It is insignificant in the coding layer. Notice that "bib: bar" in your cite instruction is a macro argument and it does not have to be in line with the rule you mentioned. – Ruben Dec 17 '14 at 0:34
  • @Merzong Spaces are generally not a good idea in anything 'programmatic': code labels have their own grammar entirely independent of 'natural' language (think CamelCaseCommandNames or names_with_underscores). – Joseph Wright Jan 16 '15 at 8:19

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.