LaTeX 中的书目参考资料

LaTeX 中的书目参考资料

如何按照我的要求写参考文献

[ref1 和 ref2]

我知道我们可以写成\cite{1,2},但我需要输出是[1 and 2],而不是[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}

答案1

为了简化您的工作,您还可以使用biblatex。为了完成答案,这里有一个例子:

\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}

需要编译

pdflatex
biber
pdflatex
pdflatex

cite只需稍加修改即可使用该包。定义一个命令citeduo,其中分隔符and为 而不是,

\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}

不过,对于您之前的所有项目,我建议biblatex使用外部bib-file


编辑

修改后的版本以分离引用:

\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}

相关内容