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 use superscripted citation style by using \setcitestyle{super} in LaTeX preamble, which done the job as I wanted. However, there are several region, in which I need to temporarily disable the superscript. For example the sentence

This figure is reproduced from reference [1]

doesn't look right with [1] being superscripted.

How to achieve that? Any idea? Thanks.

share|improve this question
    
Welcome to TeX.SX. –  Claudio Fiandrino Jan 17 '13 at 8:54
    
I've just realized that my question is basically the same as this: tex.stackexchange.com/questions/50476/…, as well as tex.stackexchange.com/questions/36235/…. Sorry for not doing proper search before. –  Indra Yudhistira Jan 21 '13 at 9:13

1 Answer 1

up vote 8 down vote accepted

The following example changes \setcitestyle locally and puts it in macro \citen. \setcitestyle of package natbib (2010/09/13 8.31b) contains a space right at the beginning of the macro definition by an uncommented end of line, the trick with \romannumeral removes this space.

\documentclass{article}
\usepackage[square]{natbib}
\setcitestyle{super}

\newcommand*{\citen}[1]{%
  \begingroup
    \romannumeral-`\x % remove space at the beginning of \setcitestyle
    \setcitestyle{numbers}%
    \cite{#1}%
  \endgroup   
}

\begin{document}
Package \textsf{accsupp}\cite{oberdiek:accsupp}.
This figure is reproduce from reference~\citen{oberdiek:zref}.
\bibliographystyle{plainnat}
\raggedright
\bibliography{oberdiek-bundle}
\end{document}

Result

Inside moving arguments (e.g., \caption) macro \citen can be protected using \protect or by using \DeclareRobustCommand for the definition:

\newcommand*{\citen}{}% generate error, if `\citen` is already in use
\DeclareRobustCommand*{\citen}[1]{%
  \begingroup
    \romannumeral-`\x % remove space at the beginning of \setcitestyle
    \setcitestyle{numbers}%
    \cite{#1}%
  \endgroup
}
share|improve this answer
    
Cool! Thanks very much. If I got enough reputation, I'll definitely vote up this answer. –  Indra Yudhistira Jan 17 '13 at 11:07
    
Ah, I just realized that there are errors if I try to put that inside a figure caption. The LaTEX error are "Argument of \@iforloop has an extra}.", "Paragraph ended before \@iforloop was complete." and "Extra \else.". Do you have any idea? Thanks. –  Indra Yudhistira Jan 17 '13 at 11:51
1  
@Indra Add \protect. Macro \citen is fragile because of fragile \setcitestyle. Or use \DeclareRobustCommand instead of \newcommand. –  Heiko Oberdiek Jan 17 '13 at 11:54
    
That solves the problem! Thanks. –  Indra Yudhistira Jan 17 '13 at 12:16

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.