8

One of my references has page numbers like 12-2, where 12 is the section and 2 the page in this section. I would like to cite this with citep[12-2]{xy} but it is converted into a double-dash page range which results in [1, pp. 12-2].

Other solutions suggest something like \citep[12{-}2] or \def\nbhyph{-\nobreak} \citep[12\nbhyph 2] but both these solutions result in [1, 12-2] without the "p.". I could fix this by adding the p. manually, i.e. citep[p.~12{-}2]{xy} but this looks like it breaks the design.

Is there a more generic solution to this?

MWE:

\documentclass{article}
\usepackage[backend=bibtex, style=ieee, natbib=true]{biblatex}
\begin{filecontents}{bib.bib}
@Book{lamport94,
    author = "Leslie Lamport",
    title = "LaTeX: A Document Preparation System",
    year = 1994
}
\end{filecontents}
\addbibresource{bib}
\begin{document}

single dash \citep[12-2]{lamport94}

\def\nbhyph{-\nobreak}
nbhyph \citep[12\nbhyph 2]{lamport94}

bracelet dash \citep[12{-}2]{lamport94}

bracelet dash with manual "p." \citep[p.~12{-}2]{lamport94}
\end{document}
  • What do you mean by "breaks the design"? The last version looks quite good to me. – LaRiFaRi May 2 '14 at 7:14
  • 1
    @LaRiFaRi: I feel like I shouldn't put the p. there manually. What if I want to change the p. to page for my whole document? – mschrimpf May 2 '14 at 7:30
  • Instead of writing p. manually, it is nicer to use \pno~ (or \ppno~), but of course that still is unnecessary work. – moewe Feb 1 '16 at 12:15
1

Not that this is better than the alternatives already explored by the OP, but it does avoid placing the "p." manually. It works by using an active . as a surrogate for a "page number dash", so that it isn't interpreted as a "page number range" which is the underlying problem being experienced.

The downside is that the \citep must be set in its own group with the . being made active prior to invocation.

\documentclass{article}
\usepackage[backend=bibtex, style=ieee, natbib=true]{biblatex}
\begin{filecontents}{bib.bib}
@Book{lamport94,
    author = "Leslie Lamport",
    title = "LaTeX: A Document Preparation System",
    year = 1994
}
\end{filecontents}
\addbibresource{bib}
\catcode`.=\active
\def.{-}%
\catcode`.=12
\begin{document}

active dot {\catcode`.=\active \citep[12.2]{lamport94}}

\end{document}

enter image description here

1

You could disable - being recognised as a range separator (you will want to treat it as a NumChar then) with

\DeclareRangeChars{~,;+/}
\DeclareNumChars*{-}

This however creates more problems than it solves, I believe, since now \cite[12-34]{sigfridsson} is not recognised as a range any more; you would have to write \cite[12\bibrangedash 34]{sigfridsson} or something along those lines.


Because I believe that pages such as 12-2 don't come up that often I would go with your solution of defining a new command for that hyphen

\def\pnhyph{-}

then in order to make sure that we still get the page prefix we need

\NumCheckSetup{\let\pnhyph\empty}

This just ignores this command when checking if we have a page number or not.

MWE

\documentclass{article}
\usepackage[backend=bibtex, style=ieee, natbib=true]{biblatex}

\addbibresource{biblatex-examples.bib}

\def\pnhyph{-}
\NumCheckSetup{\let\pnhyph\empty}

\begin{document}
single dash \citep[12-2]{sigfridsson} \citep[12\bibrangedash 2]{sigfridsson}

\verb|\pnhyph| \citep[12\pnhyph 2]{sigfridsson}
  \citep[12\pnhyph 2--13\pnhyph 3]{sigfridsson}
  \citep[12\pnhyph 2-13\pnhyph 3]{sigfridsson}

bracelet dash with manual \verb|\pno| \citep[\pno~12{-}2]{sigfridsson}
\end{document}

example output

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.