3

How you can write references as I want

[ref1 and ref2]

I know that we can write as \cite{1,2}, but I need the output to be be [1 and 2], not [1,2].

\documentclass[12pt,a4paper]{report} 
\begin{document} 
we have transform from $ A : f \rightarrow g $ \cite{1 and 2} 

\begin{thebibliography}{30} 
\addcontentsline{toc}{chapter}{Bibliography} 
\bibitem{1} D. Arcoya, \emph{An Introduction to Problems}, Springer, 2011. 
\bibitem{2} Nassor, \emph{On the Uniqueness}, pages 377-390, (1992). 
\end{thebibliography} 
\end{document}
3

To simplify your work you can also work with biblatex. To complete the answer here an example:

\documentclass[12pt,a4paper]{article} 
\usepackage[style=numeric,sortcites]{biblatex}
\addbibresource{biblatex-examples.bib}

\renewbibmacro*{cite}{%
  \printtext[bibhyperref]{%
    \printfield{prefixnumber}%
    \printfield{labelnumber}%
    \ifbool{bbx:subentry}%
      {\printfield{entrysetcount}}%
   \ifnumequal{\value{citecount}}{\value{citetotal}-1}%
       {\gdef\multicitedelim{\addspace\bibstring{and}\space}}%
       {\gdef\multicitedelim{\addcomma\space}}%
    }%
}
\begin{document} 
\cite{companion,ctan,knuth:ct:a}

\cite{companion,ctan,knuth:ct:a}


\cite{companion,ctan}

\cite{knuth:ct:a}
\printbibliography
\end{document}

It need the compilation

pdflatex
biber
pdflatex
pdflatex

You can use the package cite with a minor modification. Define a command citeduo where the separator is and instead of ,.

\documentclass[12pt,a4paper]{report} 
\usepackage{cite}
\newcommand*\citeduo[1]{%
 \bgroup%
   \def\citepunct{\ and\ }%
   \cite{#1}%
  \egroup%
}
\begin{document} 
we have transform from $ A : f \rightarrow g $ \citeduo{Arcoya,Nassor} 

\begin{thebibliography}{30} 
\addcontentsline{toc}{chapter}{Bibliography} 
\bibitem{Arcoya} D. Arcoya, \emph{An Introduction to Problems}, Springer, 2011. 
\bibitem{Nassor} Nassor, \emph{On the Uniqueness}, pages 377-390, (1992). 
\end{thebibliography} 
\end{document}

However for all your previous projects I recommend biblatex with an external bib-file.


EDIT

Modified version to separat cite's:

\documentclass[12pt,a4paper]{report} 
\usepackage[nocompress]{cite}
\usepackage{xparse}
\ExplSyntaxOn
\clist_new:N \mathcal_cite_clist
\NewDocumentCommand \mycite { m }
 {
  \group_begin:
   \citeleft  
    \int_compare:nNnTF { \clist_count:n { #1 }  } = { 1 } 
       { \citen { #1 } }
       { 
        \clist_set:No \mathcal_cite_clist { #1 }
        \mathcal_output_cite:  
       }
   \citeright
  \group_end:
 }

\cs_new:Npn \mathcal_output_cite:
 {
  \int_compare:nNnTF { \clist_count:N \mathcal_cite_clist } = { 2 }
    { \mathcal_output_duo_cite:n { \mathcal_cite_clist }  }
    {
      \clist_gpop:NN \mathcal_cite_clist \l_tmpa_tl
      \citen { \tl_use:N \l_tmpa_tl } \citepunct
      \mathcal_output_cite:
    }
 }
\cs_new:Npn \mathcal_output_duo_cite:n  #1 
 {
 \group_begin:
   \def\citepunct{\ and\ }
   \citen{ #1 }
  \group_end:
 }

\ExplSyntaxOff

\newcommand*\citeduo[1]{%
 \bgroup%
   \def\citepunct{\ and\ }%
   \citen{#1}%
  \egroup%
}
\begin{document} 
we have transform from $ A : f \rightarrow g $ \mycite{Arcoya,Nassor,temp} 

\mycite{Arcoya,Nassor} 

\mycite{Arcoya} 

\begin{thebibliography}{30} 
\addcontentsline{toc}{chapter}{Bibliography} 
\bibitem{Arcoya} D. Arcoya, \emph{An Introduction to Problems}, Springer, 2011. 
\bibitem{Nassor} Nassor, \emph{On the Uniqueness}, pages 377-390, (1992). 
\bibitem{temp} temp
\end{thebibliography} 
\end{document}
  • owww, sorry for this comment but its right just for 2 references if we have three it can not do the best, for example, [1,2 and 3] – Mathcal May 12 '13 at 13:42
  • or some times we have [1,3 and 7] so I want for this situation if you can, thanks very much – Mathcal May 12 '13 at 13:49
  • sorry I can not understand what you mean by biblatex ? :( – Mathcal May 12 '13 at 13:51
  • en.wikibooks.org/wiki/LaTeX/Bibliography_Management, also I read this but :( – Mathcal May 12 '13 at 14:14
  • yeh, but they give us just more Style not the multiple \cite – Mathcal May 12 '13 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.