使用 BibTeX 引用项目时,只有引用的项目才会显示在参考书目中(除非您使用)。我可以对文件末尾的\nocite{*}
正常内容产生相同的效果吗?(我有一个很长的列表,用于几份较长的报告。)\bibitems
.tex
答案1
如果您愿意接受应该\bibitem
以空白行结束,那么您可以修改和中的一些代码source2e
以refcheck
使其工作。您已经运行了 latex 三次以获得文本中的正确编号。
\documentclass{article}
\makeatletter
\let\@@citation@@=\citation
\renewcommand{\citation}[1]{\@@citation@@{#1}%
\@for\@tempa:=#1\do{\@ifundefined{cit@\@tempa}%
{\global\@namedef{cit@\@tempa}{}}{}}%
}
\def\@lbibitem[#1]#2#3\par{%
\@ifundefined{cit@#2}{}{\item[\@biblabel{#1}\hfill]}%
\if@filesw
{\let\protect\noexpand
\immediate
\write\@auxout{\string\bibcite{#2}{#1}}}\fi\ignorespaces
\@ifundefined{cit@#2}{}{#3}}
\def\@bibitem#1#2\par{%
\@ifundefined{cit@#1}{}{\item}%
\if@filesw \immediate\write\@auxout
{\string\bibcite{#1}{\the\value{\@listctr}}}\fi\ignorespaces
\@ifundefined{cit@#1}{}{#2}}
\makeatother
\begin{document}
Test a citation \cite{one} and another \cite{three}. Also one more
for luck: \cite{five}.
\begin{thebibliography}{9}
\bibitem{one} Reference one.
\bibitem{two} Reference two.
\bibitem[Special]{three} Reference three.
\bibitem{four} Reference four.
\bibitem{five} Reference five.
\bibitem[Unusual]{six} Reference six.
\end{thebibliography}
\end{document}
代码的第一部分是refcheck
对\cite
命令的修改,以便记录 bibitem 的使用。第二部分是对核心 latex 的修改\bibitem
,以便它始终在文件中记录标签.aux
,但仅在引用该项目时才打印出正文。
如果您需要将其与 一起使用,hyperref
因此有参考书目的链接,则必须将编码调整为和hyperref
上的 版本,因为只会覆盖当前定义。如下所示,请注意包加载的位置:\@lbibitem
\@bibitem
hyperref
hyperref
\documentclass{article}
\makeatletter
\let\@@citation@@=\citation
\renewcommand{\citation}[1]{\@@citation@@{#1}%
\@for\@tempa:=#1\do{\@ifundefined{cit@\@tempa}%
{\global\@namedef{cit@\@tempa}{}}{}}%
}
\makeatother
\usepackage{hyperref}
\makeatletter
\def\@lbibitem[#1]#2#3\par{%
\@ifundefined{cit@#2}{}{\@skiphyperreftrue
\H@item[%
\ifx\Hy@raisedlink\@empty
\hyper@anchorstart{cite.#2\@extra@b@citeb}%
\@BIBLABEL{#1}%
\hyper@anchorend
\else
\Hy@raisedlink{%
\hyper@anchorstart{cite.#2\@extra@b@citeb}\hyper@anchorend
}%
\@BIBLABEL{#1}%
\fi
\hfill
]%
\@skiphyperreffalse}%
\if@filesw
\begingroup
\let\protect\noexpand
\immediate\write\@auxout{%
\string\bibcite{#2}{#1}%
}%
\endgroup
\fi
\ignorespaces
\@ifundefined{cit@#2}{}{#3}}
\def\@bibitem#1#2\par{%
\@ifundefined{cit@#1}{}{\@skiphyperreftrue\H@item\@skiphyperreffalse
\Hy@raisedlink{%
\hyper@anchorstart{cite.#1\@extra@b@citeb}\relax\hyper@anchorend
}}%
\if@filesw
\begingroup
\let\protect\noexpand
\immediate\write\@auxout{%
\string\bibcite{#1}{\the\value{\@listctr}}%
}%
\endgroup
\fi
\ignorespaces
\@ifundefined{cit@#1}{}{#2}}
\makeatother
\begin{document}
Test a citation \cite{one} and another \cite{three}. Also one more
for luck: \cite{five}.
\begin{thebibliography}{9}
\bibitem{one} Reference one.
\bibitem{two} Reference two.
\bibitem[Special]{three} Reference three.
\bibitem{four} Reference four.
\bibitem{five} Reference five.
\bibitem[Unusual]{six} Reference six.
\end{thebibliography}
\end{document}
答案2
您可以更改输入格式以将文本放入参数中。然后很容易抑制一个条目:
\documentclass{article}
\usepackage{xpatch}
\makeatletter
\xpretocmd\@citex{\csgdef{used@cite@#2}{x}}{}{\failed}
\newcommand\checkbibentry[2]{\ifcsdef{used@cite@#1}{\bibitem{#1}{#2}}{}}
\makeatletter
\begin{document}
\cite{a} \cite{c}
\begin{thebibliography}{99}
\checkbibentry{a}{some text to a}
\checkbibentry{b}{some text to b}
\checkbibentry{c}{some text to c}
\end{thebibliography}
\end{document}