1

I am using BibTeX with natbib. My style file orders my bibliography in the order in which articles were cited. Occasionally, however, I want an \cite to be ignored for the purposes of the bibliography order, but fully working otherwise.

Minimal working example:

\documentclass{article}
\usepackage[square,numbers,sort]{natbib}
\begin{document}
\cite{c} % Want to cite, but ignore for purpose of bibliography order.
\cite{a}
\cite{b}
\cite{c}
\bibliographystyle{unsrt}
\bibliography{ex}
\end{document}

with ex.bib:

@article{a, author="a"}
@article{b, author="b"}
@article{c, author="c"}

results in:

enter image description here

as expected. I want to replace that first citation with a new command, say \ignorecite so that the order is a,b,c, and so that the order in the main document is 3,1,2,3

lockstep
  • 250,273
innisfree
  • 598
  • 5
  • 17

2 Answers2

4

All you have to do is remove the capability to write a citation to the .aux file. This is achieved by momentarily setting \@fileswfalse:

\newcommand{\ignorecite}[1]{{\@fileswfalse\cite{#1}}}%

With the entire \cite command still in tact, hyperlinks and formatting functions as usual.

enter image description here

\documentclass{article}

% Write bibliography items to file
\usepackage{filecontents}% http://ctan.org/pkg/filecontents
\begin{filecontents*}{ex.bib}
@article{a, author="a"}
@article{b, author="b"}
@article{c, author="c"}
\end{filecontents*}

\makeatletter
\newcommand{\ignorecite}[1]{{\@fileswfalse\cite{#1}}}%
\makeatother
\usepackage[square,numbers,sort]{natbib}% http://ctan.org/pkg/natbib
\usepackage{hyperref}% http://ctan.org/pkg/hyperref
\begin{document}
\ignorecite{c} % Want to cite, but ignore for purpose of bibliography order.
\cite{a}
\cite{b}
\cite{c}
\bibliographystyle{unsrt}
\bibliography{ex}
\end{document}
Werner
  • 603,163
0

Similar to Werner's answer, this one by Frank Mittelbach proposes a command that takes the citation call itself:

\makeatletter
\def\ignorecitefornumbering#1{%
     \begingroup
         \@fileswfalse
         #1%                     % do \cite comand
    \endgroup
}
\makeatother
Firebug
  • 139