# [texhax] Optional argument to \cite{}

Steve Schwartz s.schwartz at imperial.ac.uk
Thu Jul 15 20:19:37 CEST 2010

Hi Dan,

On Wed, 2010-07-14 at 13:39 +0100, Dan wrote:
> \citet[pp.~171--176]{Phillips:2009:GFD}
>
> is supposed to produce output like
>
> Phillips [17, pp. 171-176].
>
> Unfortunately, it actually produces
>
> Phillips [17], pp. 171–176.

Hmm, this is actually true (to my surprise). In looking into the
natbib.dtx I see that Pat Daly didn't use the variosu \cite commands
within the documentation, but merely typeset what he thought it should
do. Note, however, that the citep form does work as advertised, namely:

\citep[pp~171--176]{dumb91} results in:

[2, pp 171-176]

so you can get what you intended by:

\citeauthor{dumb91}~\citep[pp~171--176]{dumb91}

Returning to your original question, with multiple citations and
multiple annotations of page numbers, natbib has enough capability to
allow you to roll your own. Here goes (tested)

Put:

\makeatletter
\newcommand\citeopen{\NAT at open}
\newcommand\citeclose{\NAT at close}
\newcommand\citesep{\NAT at sep}
\makeatother

in your preamble. You don't need to do it this way, but it makes your
tex file immune should you change your mind about whether to use square
or round parentheses, for example.

Then the source line:

\citeopen\citenum{dumb91}~pp~171--176\citesep\citenum{dumb93}\citesep
\citenum{dumb92}~pp~2--7\citeclose

generates

[2 pp 171–176,1,3 pp 2–7]

if you use the defaults for abbrvnat bibliography style. Hardwiring into
the source looks tidier:

[\citenum{dumb91}~pp~171--176,\citenum{dumb93},\citenum{dumb92}~pp~2--7]

There may be a way to avoid a \citenum for each citation, but some
things I tried had side effects. Of course, if you decide to change from
numerical to author-year citations this approach will force you to
change this somehow; redefining \citenum might save some work.

Hope this helps...

Steve

--
+-------------------------------------------------------------------+
Professor Steven J Schwartz        Phone: +44-(0)20-7594-7660
Head, Space & Atmospheric Physics  Fax:   +44-(0)20-7594-7772
The Blackett Laboratory            E-mail: s.schwartz at imperial.ac.uk
Imperial College London            Office: Huxley 6M67A
London SW7 2AZ, U.K.               Web: www.sp.ph.ic.ac.uk/~sjs
+-------------------------------------------------------------------+