Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
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 Apr 12 '12 at 15:56
    
@joseph, Neither do I. I just want to be consistent in writing free style documents for class. –  Kanvuanza Apr 13 '12 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 Nov 28 at 17:48

2 Answers 2

up vote 7 down vote accepted

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

share|improve this answer
    
Thanks, this solves my problem. –  Kanvuanza Apr 13 '12 at 3:03
    
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.... –  Nicholas Hamilton Apr 14 '13 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 Nov 28 at 18:01

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.