特定の参照の後に垂直スペースを挿入する (bibtex)

特定の参照の後に垂直スペースを挿入する (bibtex)

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マクロ。

関連情報