是否可以定义一个 LaTeX 命令,将引用键作为输入,并将该键第一次出现的文章部分(内部\cite{}
)作为输出,即第一次引用此给定参考文献的位置?(不使用 bibtex 或 biblatex)
答案1
我不确定您的用例,但这里为您提供了一个使用 package 的起点backref
。至少,它会在项目本身之后打印每个 bib.-item 被引用的部分数量。
\documentclass[a4paper]{article}
\usepackage[ref]{backref}
\renewcommand*{\backref}[1]{}
\renewcommand*\backrefalt[4]{%
\ifcase #1 %
No citations.%
\or
One citation in section #2.%
\else
#1 citations in sections #2.%
\fi
}
\begin{document}
\section{First Section}
\cite{Rei91}
\section{Second Section}
\cite{CA}, \cite{MSW00}, \cite{Rei91}
\section{Third Section}
\cite{MSW00}, \cite{Rei91}
\section{Fourth Section}
\cite{CA}, \cite{MSW00}, \cite{Rei91}
\begin{thebibliography}{99}
\bibitem{HB98} Huynen, M.~A. and Bork, P. 1998. Measuring genome
evolution. {\itshape Proceedings of the National Academy of Sciences
USA} 95:5849--5856.
\bibitem{CA} Caprara, A. 1997. Sorting by reversals is difficult. In:
{\itshape Proceedings of the First Annual International Conference
on Computational Molecular Biology (RECOMB 97),} New York: ACM.
pp. 75--83.
\bibitem{MSW00} McLysaght, A., Seoighe, C. and Wolfe, K.~H. 2000. High
frequency of inversions during eukaryote gene order evolution. In
Sankoff, D. and Nadeau, J.~H., editors, {\itshape Comparative
Genomics}, Dordrecht, NL: Kluwer Academic Press. pp. 47--58.
\bibitem{Rei91} Reinelt, G. 1991. {\itshape The Traveling Salesman -
Computational Solutions for TSP Applications.} Berlin: Springer
Verlag.
\end{thebibliography}
\end{document}
答案2
一位同事对这个问题提出了解决方案:
\documentclass[a4]{article}
\makeatletter
\renewcommand\@bibitem[1]{\item\if@filesw\immediate\write\@auxout
{\string\bibcite{#1}{\theenumiv}}\fi\ignorespaces}
\renewenvironment{thebibliography}[1]
{\section*{\refname}% %% use \bibname instead of
% %% \refname if using the
% %% report or book document classes
\@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}%
\list{\@biblabel{\the\c@section.\@arabic\c@enumiv}}%
% %% ^^ added \the\c@section
{\settowidth\labelwidth{\@biblabel{#1}}%
\leftmargin\labelwidth
\advance\leftmargin\labelsep
\@openbib@code
\usecounter{enumiv}%
\let\p@enumiv\@empty`
\renewcommand\theenumiv{\the\c@section.\@arabic\c@enumiv}}%
% %% ^^ added \the\c@section
\sloppy
\clubpenalty4000
\@clubpenalty \clubpenalty
\widowpenalty4000%
\sfcode`\.\@m}
{\def\@noitemerr
{\@latex@warning{Empty `thebibliography' environment}}%
\endlist}
\makeatother
\begin{document}
\section{Foo}
Blah blah blah~\cite{cite1}, and see later~\cite{cite2}.
\begin{thebibliography}{99}
\bibitem{cite1} Foo bar.
\end{thebibliography}
\section{Bar}
Bleh bleh bleh~\cite{cite2}. And also~\cite{cite1}.
\begin{thebibliography}{99}
\bibitem{cite2} Baz bof.
\end{thebibliography}
\end{document}