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 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?

share|improve this question

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

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

3 Answers 3

up vote 5 down vote accepted

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

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

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.

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

@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)

share|improve this answer
    
If my answer was "a great help", consider to upvote it. ;-) –  lockstep Aug 6 '13 at 9:35
    
@lockstep Of course - done, and thanks for the reminder. –  Chris H Aug 6 '13 at 9:50

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.