8

In a book I'm citing, the pages are numbered as following: X-Y, where X is the chapter number and Y is the number of the page in that chapter. For example, the fifth page of the third chapter would be numbered 3-5.

To get the page number 3-5 in a reference, I have to write 3\-5, since BibTeX seems to automatically replace hyphens in the page numbers with en dashes. So that's a problem I had which is solved now.

However, even after writing pages = {3\-5} in the BibTeX code, BibTeX writes "pages 3-5" in the bibliography, not "page 3-5". How can I make BibTeX understand that "3-5" is just one page and not a range of pages?

7

Don't make BibTeX see the hyphen:

\begin{filecontents*}{\jobname.bib}
@inbook{x,
 author={A. Uthor},
 title={A chapter},
 booktitle={A book},
 publisher={Publisher},
 year={2012},
 pages={3\pagehyphen5},
}
\end{filecontents*}
\documentclass{article}
\usepackage{natbib}

\newcommand{\pagehyphen}{-}

\begin{document}
\cite{x}
\bibliographystyle{plainnat}
\bibliography{\jobname}
\end{document}

enter image description here

You can also have the definition of the command in the .bib file, with a @preamble entry.

\begin{filecontents*}{\jobname.bib}
@preamble{"\providecommand\pagehyphen{-}"}
@inbook{x,
 author={A. Uthor},
 title={A chapter},
 booktitle={A book},
 publisher={Publisher},
 year={2012},
 pages={3\pagehyphen5},
}
\end{filecontents*}
\documentclass{article}
\usepackage{natbib}

\begin{document}
\cite{x}
\bibliographystyle{plainnat}
\bibliography{\jobname}
\end{document}

Without any extra macro, you can use {\char45} for the hyphen in the .bib file; however this is not the best solution, in my opinion.

\begin{filecontents*}{\jobname.bib}
@inbook{x,
 author={A. Uthor},
 title={A chapter},
 booktitle={A book},
 publisher={Publisher},
 year={2012},
 pages={3{\char45}5},
}
\end{filecontents*}
\documentclass{article}
\usepackage{natbib}

\begin{document}
\cite{x}
\bibliographystyle{plainnat}
\bibliography{\jobname}
\end{document}
  • 1
    Is there any way I can define \pagehyphen in the .bib file? Your code works, but if I want to give away my bibliography to someone else, I will have to provide them with the macro as well. – StrawberryFieldsForever Jun 27 '13 at 17:36
  • 3
    @StrawberryFieldsForever -- Yes, by adding the instruction @preamble{ "\newcommand{\pagehyphen}{--}"} in the bib file. – Mico Jun 27 '13 at 17:45
  • 1
    @StrawberryFieldsForever Add a @preamble entry; I'll show it in my answer. – egreg Jun 27 '13 at 17:46
  • Great, it works! :) Thanks! Although since I need a normal hyphen, not an en dash, I added @preamble{ "\newcommand{\pagehyphen}{-}"} to my .bib file. – StrawberryFieldsForever Jun 27 '13 at 17:59
  • 1
    @StrawberryFieldsForever You could try \char45 instead of the hyphen. – egreg Jun 28 '13 at 10:42

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.