10

I'm with an annoying problem with natbib. When the super parameter is used, the citation happily goes superscript but the page or chapter number doesn't.

\documentclass{article}
\usepackage[numbers, square, super]{natbib}
\begin{document}
    Some information.\cite[p.~56]{who09}

    \begin{thebibliography}{0}
        \bibitem{who09} Who J F. Nice Book. 2009.
    \end{thebibliography}
\end{document}

The above example shows the page number into normal text instead of superscript. Removing super the page goes into brackets.

4
  • 1
    I've never seen anyone give references in the way you suggest. Can you point to a place where this is used?
    – Joseph Wright
    Commented Apr 12, 2012 at 15:56
  • @joseph, Neither do I. I just want to be consistent in writing free style documents for class. Commented Apr 13, 2012 at 2:44
  • @JosephWright. I suspect it's the only citation format many people will have encountered as it's the format used on Wikipedia.
    – richard
    Commented Nov 28, 2014 at 17:48
  • it's helpful to point out that AMA citation style uses precisely the format indicated by the OP. Commented Aug 17, 2021 at 8:00

2 Answers 2

9

Although this citation style is not common (as Joseph Wright suggested in his comment), you can obtain the desired result with a redefinition of the natbib's internal macro \NAT@citesuper. Here's a working example of such a redefinition:

\documentclass{article}
\usepackage[numbers, square, super]{natbib}

\makeatletter
\renewcommand\NAT@citesuper[3]{\ifNAT@swa
\if*#2*\else#2\NAT@spacechar\fi
\unskip\kern\p@\textsuperscript{\NAT@@open#1\if*#3*\else,\NAT@spacechar#3\fi\NAT@@close}%
   \else #1\fi\endgroup}
\makeatother

\begin{document}

Some text\cite[p.~56]{who09} some text\cite{who09}

\begin{thebibliography}{0}
\bibitem{who09} Who J F. Nice Book. 2009.
\end{thebibliography}

\end{document}

enter image description here

2
  • This has helped me a great deal, works well for \citep, how can the same workaround be applied for \citet, which shows the same behaviour as the initial question.... Commented Apr 14, 2013 at 4:43
  • This breaks in XeLaTeX when certain fonts (e.g. some versions of Linux Libertine) are used with the xltxtra package. The solution then is to replace \textsuperscript in the definitions of \NAT@citesuper with \textsuperscript*. Note this will then break if the use of xltxtra is removed.
    – richard
    Commented Nov 28, 2014 at 18:01
4

I cannot comment, so I feel the urge to post this as an answer. While the exact example asked for is (as was repeated) non-common, there is a very common use for this modification: Turning it into subreferences as in [1a], [1b], by adding the corresponding letter into square brackets \cite[a]{foo}, \cite[b]{foo} Also works with Natbib.

I modified Gonzalo's code snippet by looking at it and guessing which parts would be too many. Probably more code could be removed but I have no idea which that could be, and this is the first working example. (I am specifically suspecting anything containing #2 to be irrelevant, but I do not want to continue researching into this, as I have a thesis to hand in soon.)

\makeatletter
\renewcommand\NAT@citesuper[3]{\ifNAT@swa
\if*#2*\else#2\NAT@spacechar\fi
\unskip\kern\p@\textsuperscript{\NAT@@open#1#3\NAT@@close}%
\else #1\fi\endgroup}
\makeatother

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .