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.

The default citation delimiter is ,. For instance,

\cite{John96, Doe78, White05}

generates something like [8, 2, 4], where the citation numbers (8, 2, and 4) are separated by a comma (,).

This is very natural in Latin languages, but some other languages use different delimiters. Let's assume you want to change the delimiter to, say +. How do you do that?

share|improve this question
1  
Do you mean in the input or in the output? The two look the same here, but that is simply because using , is a convention in both areas. –  Joseph Wright May 15 '11 at 10:47
    
@Joseph: I meant in the output. –  Sadeq Dousti May 15 '11 at 12:31

2 Answers 2

up vote 5 down vote accepted

Redefine the \@citex macro. In the following example, I use the etoolbox package to change only parts of the definition.

\documentclass{article}

\usepackage{etoolbox}

\makeatletter
\patchcmd{\@citex}{,\penalty\@m\ }{+}{}{}
\makeatother

\usepackage{filecontents}

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

\begin{document}

Some text \cite{A01,B02}

\bibliographystyle{plain}
\bibliography{\jobname}

\end{document}
share|improve this answer

The commas are directly used in the internal LaTeX macro \@citex. You can redefine this:

\documentclass{article}
\newcommand*{\citedelimiter}{+}
\makeatletter
\def\@citex[#1]#2{\leavevmode
  \let\@citea\@empty
  \@cite{\@for\@citeb:=#2\do
    {\@citea\def\@citea{\citedelimiter\penalty\@m}%
     \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}%
     \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
     \@ifundefined{b@\@citeb}{\hbox{\reset@font\bfseries ?}%
       \G@refundefinedtrue
       \@latex@warning
         {Citation `\@citeb' on page \thepage \space undefined}}%
       {\@cite@ofmt{\csname b@\@citeb\endcsname}}}}{#1}}
\makeatother
\begin{document}
\cite{John96, Doe78, White05}
\end{document}

Extension packages may provide macros for that purpose.

Here's the output, with question marks since the citations are undefined, but you see the new delimiters:

enter image description here

Compared to the original LaTeX source, I changed the line

{\@citea\def\@citea{,\penalty\@m\ }%

to

{\@citea\def\@citea{\citedelimiter\penalty\@m}%

I introduced the macro \citedelimiter to allow easy changes, what the original LaTeX did not foresee. Patching, such as suggested by lockstep, is an elegant and short way, though it may fail if the original macro would be changed, for instance by another package. At least your own redefinition may still work then, however I would also take care and check and work at the new macro, which has been redefinied by another package.

share|improve this answer
    
+1. Both of the answers (yours and lockstep's) provide excellent solutions. As you described, your answer is more robust, but at the cost of being more complex. I accepted lockstep's answer since it is shorter and more suitable to my environment; however, I advise any serious TeX-er to adopt Stefan's solution. –  Sadeq Dousti May 15 '11 at 12:30

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.