我想使用 BibTeX 在参考文献部分的特定参考文献后插入一些垂直空格,最好使用如下命令序列:
\cite{ABC-2001}
\refvspace{1cm}
\cite{XYZ-2002}
参考文献用 导入\bibliography{references.bib}
。顺序按引用顺序。参考书目样式是自定义的,但我们假设它是\bibliographystyle{unsrt}
为了明确性。
如何在不修改 bib 文件的情况下做到这一点?
一个可能的起点:
\documentclass{article}
\begin{filecontents}{refs.bib}
@misc{P, author = {P}, year = {2001}}
@misc{Q, author = {Q}, year = {2002}}
@misc{A, author = {A}, year = {2001}}
@misc{B, author = {B}, year = {2002}}
\end{filecontents}
\begin{document}
This is a survey on different topics.
\section*{Topic 1}
Text \cite{P}. Text \cite{Q}.
\section*{Topic 2}
% TODO: Visually separate the two topics in the bibliography here
Text \cite{A}. Text \cite{B}.
\bibliographystyle{unsrt}
\bibliography{refs}
\end{document}
答案1
让我们考虑一下您的意见:
\cite{ABC-2001}
\refvspace{1cm}
\cite{XYZ-2002}
我们可以指定一些\vspace
与 的引用相关的宏XYZ-2002
。也就是说,\vspace{1cm}
一旦\bibitem{XYZ-2002}
在参考书目中找到它,就会立即调用。
下面这个最小的例子实现了这一点:
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{refs.bib}
@misc{P, author = {P}, year = {2001}}
@misc{Q, author = {Q}, year = {2002}}
@misc{A, author = {A}, year = {2001}}
@misc{B, author = {B}, year = {2002}}
\end{filecontents}
\makeatletter
\let\@refvspace\relax
\providecommand{\refvspace}[1]{%
\gdef\@refvspace{#1}% Store \refvspace
}
\let\old@cite\cite% Store \cite in \old@cite
\renewcommand{\cite}[1]{%
\ifx\@refvspace\relax
% No \refvspace was used
\else
\begingroup
% Create vspace macro
\edef\x{\endgroup
\noexpand\global\noexpand\@namedef{#1@vspace}{\noexpand\vspace{\@refvspace}}}\x
\global\let\@refvspace\relax
\fi
\old@cite{#1}}% Process regular \cite
\let\old@bibitem\bibitem% Store \bibitem in \old@bibitem
\renewcommand{\bibitem}[1]{%
\csname #1@vspace\endcsname% Insert \vspace macro
\old@bibitem{#1}}% Process regular \bibitem
\makeatother
\begin{document}
This is a survey on different topics.
\section*{Topic 1}
Text \cite{P}. \refvspace{\baselineskip}Text \cite{Q}.
\section*{Topic 2}
\refvspace{1cm}
Text \cite{A}. Text \cite{B}.
\bibliographystyle{unsrt}
\bibliography{refs}
\end{document}
注意事项:
上面的例子相当简单,从
\cite
和中删除了可选参数\bibitem
。但是,如果需要,可以恢复。内容不会写入
.bib
也不会写入.bbl
,因此仅当\bibliography
发生时才会起作用后所有的\refvspace
宏。