
對於樣式文件,我想在引用之前自動產生文字的確認段落/部分(基於使用者提供的巨集設定的一些選項)。該方法應該適用於bibtex
和biblatex
。這個怎麼做?
使用 bibtex 時,我可以透過預先執行以下操作來實現此目的thebibliography
:
\BeforeBeginEnvironment{thebibliography}{%
\section{Acknowledgements}%
Example text.%
}
這不適用於 biblatex。我嘗試修補\printbibliography
\pretocmd\printbibliography{%
\section{Acknowledgements}%
Example text.%
}{}{}%
但這行不通。有沒有一個簡單/優雅的解決方案?
++++ 更新以提供 MWE
對於沒有提供 MWE 表示歉意。假設有一個 template.bib 其中包含一個引用:
@article{RSA78,
author = {Ronald L. Rivest and Adi Shamir and Leonard M. Adleman},
title = {A Method for Obtaining Digital Signatures and Public-Key Cryptosystems},
pages = {120--126},
year = {1978},
journal = {Communications of the ACM},
volume = {21},
number = {2},
publisher = {ACM New York, NY, USA},
doi = {10.1145/359340.359342},
}
然後我想在參考文獻顯示之前自動插入一個段落/部分(無需作者修改其末尾的命令)。這是一個 MWE:
\documentclass{article}
\begin{document}
This is an example citation~\cite{RSA78}.
\bibliographystyle{alphaurl}
\bibliography{template}
\end{document}
使用 Bibtex 時,我可以使用以下方法來實現此目的:
\documentclass{article}
\usepackage{etoolbox}
\BeforeBeginEnvironment{thebibliography}{%
\section*{Acknowledgements}%
Section text.%
}
\begin{document}
This is an example citation~\cite{RSA78}.
\bibliographystyle{alphaurl}
\bibliography{template}
\end{document}
如何使用 biblatex / biber 做到這一點?微量元素:
\documentclass{article}
\usepackage{biblatex}
\addbibresource{template.bib}
\begin{document}
This is an example citation~\cite{RSA78}.
\printbibliography
\end{document}
使用註釋選項\printbibliography
無法達到我想要的效果。
答案1
biblatex
已經有了這種插入的基礎設施,不需要重新定義內部結構來做到這一點。即,prenote
選項\printbibliography
,允許您選擇以 定義的書目註釋\defbibnote
。您可以在呼叫時進行設置\printbibliography
,也可以使用 設定全域預設值\DeclarePrintbibliographyDefaults
,具體取決於您的實際用例。在範例中,我將設定prenote
為預設值並設定title
為本地,因為它似乎更有意義:
\documentclass{article}
\usepackage{biblatex}
\addbibresource{template.bib}
\defbibnote{myprenote}{Section text.}
\DeclarePrintbibliographyDefaults{prenote=myprenote}
\begin{document}
This is an example citation~\cite{RSA78}.
\printbibliography[title=Acknowledgements]
\end{document}
編輯:正如評論中所澄清的那樣(但評論是後來編輯的......),真正想要的是標題本身之前的東西。為此,您可以設定\defbibheading
:
\documentclass{article}
\usepackage{biblatex}
\addbibresource{template.bib}
\defbibheading{myheading}[\bibname]{%
\section*{Acknowledgements}%
Section text.%
\section*{#1}%
\markboth{#1}{#1}}
\DeclarePrintbibliographyDefaults{heading=myheading}
\begin{document}
This is an example citation~\cite{RSA78}.
\printbibliography
\end{document}