14

I am using natbib with superscript numbered citations as follows:

\usepackage[super,comma,sort&compress]{natbib} 

It works great when I have the case This is a reference~\cite{author1999}. My reference appears as a superscript.

However, I occasionally want write something like: As shown by \citet{author1999} where I want the citation written out and not as a superscript. natbib in super mode inserts a superscript when using \citet.

Is there a way to have natbib use \citet in regular mode despite being in super mode? Can one change the mode temporarily to not have super and then switch it back on again?

migrated from stackoverflow.com Nov 26 '11 at 13:51

This question came from our site for professional and enthusiast programmers.

  • 1
    There is in the documentation (here 6 years later...) mentioned the use of \citenum instead of \cite (or \citet or others). This will display the pure reference number 3. Without superscript or brackets or anything. I believe brackets can just be added manually, which should be doable for occasional uses. – Steeven May 22 '17 at 12:54
13

Assuming you want a non-superscript numbered citation, you could define a new command \citenst that mimicks \citet but locally disables the settings of the superscript option.

\documentclass{article}

\usepackage[super,comma,sort&compress]{natbib}

\makeatletter
\newcommand*{\citenst}[2][]{%
  \begingroup
  \let\NAT@mbox=\mbox
  \let\@cite\NAT@citenum
  \let\NAT@space\NAT@spacechar
  \let\NAT@super@kern\relax
  \renewcommand\NAT@open{[}%
  \renewcommand\NAT@close{]}%
  \citet[#1]{#2}%
  \endgroup
}
\makeatother

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@misc{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
\end{filecontents}

\begin{document}

This is a reference~\cite{A01}.

As shown by \citenst{A01}~\dots

As shown by \citet{A01}~\dots

\bibliographystyle{plainnat}
\bibliography{\jobname}

\end{document}

enter image description here

  • 1
    Wow! I would like to use your \citet with output either Author1 et al. (2001)^1 or Author1 et al.^1. However, I get (author?) errors. My .bib entries seem to be correct (were generated by BibDesk). Not sure what I am doing wrong. – Paul Nov 26 '11 at 14:48
  • The first alternative (year plus citation number) is beyond my capabilities. As for the second one: If my MWE works for you, you should try to delete all auxiliary files in your actual document and compile again. If your document still doesn't work, you have to provide a MWE so others can see what exactly you're doing. – lockstep Nov 26 '11 at 14:55
  • Your MWE works for me with the named style and not plainnat or unsrt. I am very happy with named and your solution. I also got Alan's suggestion to work as well. Thanks to both! – Paul Nov 26 '11 at 17:31
8

You can't generally mix author-year type citations with numeric citations. But natbib provides the \citeauthor and \citeyear commands, so you could construct a simple version for the uses you have:

\newcommand{\textcite}[1]{\citeauthor{#1}~\citeyear{#1}}

And then use \textcite{<key>}. If you just need the author, then you can use \citeauthor directly.

  • 1
    Thanks Alan. I get the warning: Author undefined for citation`boyd2004convex' and an (author?) (year?) in the text. The BibTeX entry is: @book{boyd2004convex, title={Convex optimization}, author={Boyd, S.P. and Vandenberghe, L.}, year={2004}, publisher={Cambridge Univ Pr} } – Paul Nov 26 '11 at 14:35
3

@lockstep's answer was a great help, but I had a slightly different issue, my search brought me here.

I'm using a superscripted reference style with RevTeX, but I wanted the reference number in the running text, e.g. "further details can be found in reference 7".

So I modified lockstep's code as follows:

%citenumns provides the reference number for a citation, not superscripted or bracketed
\makeatletter
\newcommand*{\citenumns}[2][]{%
  \begingroup
  \let\NAT@mbox=\mbox
  \let\@cite\NAT@citenum
  \let\NAT@space\NAT@spacechar
  \let\NAT@super@kern\relax
  \renewcommand\NAT@open{}%
  \renewcommand\NAT@close{}%
  \cite[#1]{#2}%
  \endgroup
}
\makeatother

now we can have ...further details can be found in reference \citenumns{some_ref} and get the effect I was looking for.

(added here as this was the most relevant question to place it under, I would have as good as duplicated it)

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.