我有一个大bib
文件,其中包含很多条目,其中大多数条目都包含一个note
文件。我想自动遍历所有条目,并为每个条目插入类似以下内容的文档:
Paper's title / First author (et al. if needed) [x]
Note:
The content of the note field.
其中[x]
是打印的参考文献列表中条目的编号。
如果我知道条目的密钥,那么使用biblatex
它可能是这样的:
\newcommand{\completecite}[1]{
\citetitle{#1}, \citeauthor{#1} \cite{#1}
\citefield{#1}{note}
}
我的问题是如何遍历bib
文件中的所有条目?
lua
也许可以使用和的组合来解决biblatex
。但我的问题是,是否有一种简单而规范的方法来做到这一点?否则,我很乐意得到一个提示,如何使用 来解决这个问题lua
。
简而言之,最终目标是跟踪单个bib
文件中的所有论文和手动添加的注释,并生成包含每个条目注释的 pdf。
答案1
\printbibliography
如果我们施展一些黑魔法,我们就能有效地使用它。
首先我们定义一个通用驱动程序
\newbibmacro*{cite:title}{%
\printtext[bibhyperref]{%
\printfield[citetitle]{labeltitle}}}
\newbibmacro*{cite:shorthand}{%
\printtext[bibhyperref]{\printfield{shorthand}}}
\newbibmacro*{citetitle}{%
\iffieldundef{shorthand}
{\usebibmacro{cite:title}}%
{\usebibmacro{cite:shorthand}}}
\DeclareBibliographyDriver{drorver}{%
\usebibmacro{citetitle}%
\setunit{\addcomma\space}%
\printfield{year}%
\setunit{\addspace}%
\printtext[brackets]{\usebibmacro{cite}}%
\par
\printfield{note}%
}
以及新的列表格式
\defbibenvironment{drorlist}
{\list
{}
{\setlength{\leftmargin}{\bibhang}%
\setlength{\itemindent}{-\leftmargin}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}}
{\endlist}
{\item}
然后魔法
\makeatletter
\newcommand{\makealldror}{\def\blx@driver##1{\csuse{blx@bbx@drorver}}}
\makeatother
这使得所有条目都使用该drorver
类型。宏blx@driver
用于调用正确的条目类型的相关驱动程序(\blx@bbx@<type>
)我们让该宏\blx@bbx@drorver
始终选择。(请参阅biblatex2.sty
第 1665 行以了解真正的定义\blx@driver
)
然后我们使用
\begingroup
\makealldror
\printbibliography[env=drorlist]
\endgroup
排版您想要的格式的列表。
平均能量损失
\documentclass{article}
\usepackage[backend=biber,style=numeric]{biblatex}
\usepackage{citeall}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{batty2007iq,
title={IQ in early adulthood and later cancer risk: cohort study of one million Swedish men},
author={Batty, G. David and Wennerstad, Karin Modig and Smith, George Davey and Gunnell, David and Deary, Ian J. and Tynelius, Per and Rasmussen, Finn},
journal={Annals of Oncology},
volume={18},
number={1},
pages={21--28},
year={2007},
publisher={European Society for Medical Oncology},
note = {ipsum ipsum ipsum ipsum},
}
@article{batty2007premorbid,
title={Premorbid (early life) IQ and Later Mortality Risk: Systematic Review},
author={Batty, G. David and Deary, Ian J. and Gottfredson, Linda S.},
journal={Annals of Epidemiology},
volume={17},
number={4},
pages={278--288},
year={2007},
publisher={Elsevier},
note = {Lorem lorem lorem lorem lorem lorem},
}
@article{batty2009iq_early,
title={IQ in Early Adulthood and Mortality By Middle Age: Cohort Study of 1 Million Swedish Men},
author={Batty, G. David and Wennerstad, Karin Modig and Smith, George Davey and Gunnell, David and Deary, Ian J. and Tynelius, Per and Rasmussen, Finn},
journal={Epidemiology},
volume={20},
number={1},
pages={100--109},
year={2009},
publisher={LWW},
note = {In Mexico is een man gearresteerd.},
}
@article{batty2009iq_socio,
title={IQ in Early Adulthood, Socioeconomic Position, and Unintentional Injury Mortality by Middle Age: A Cohort Study of More Than 1 Million Swedish Men},
author={Batty, G. David and Gale, Catharine R. and Tynelius, Per and Deary, Ian J. and Rasmussen, Finn},
journal={American Journal of Epidemiology},
volume={169},
number={5},
pages={606--615},
year={2009},
publisher={Oxford University Press},
note = {Lore ipsum dolor sit amet \begin{itemize}\item Lorem\end{itemize}},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\newbibmacro*{cite:title}{%
\printtext[bibhyperref]{%
\printfield[citetitle]{labeltitle}}}
\newbibmacro*{cite:shorthand}{%
\printtext[bibhyperref]{\printfield{shorthand}}}
\newbibmacro*{citetitle}{%
\iffieldundef{shorthand}
{\usebibmacro{cite:title}}%
{\usebibmacro{cite:shorthand}}}
\DeclareBibliographyDriver{drorver}{%
\usebibmacro{citetitle}%
\setunit{\addcomma\space}%
\printfield{year}%
\setunit{\addspace}%
\printtext[brackets]{\usebibmacro{cite}}%
\par
\printfield{note}%
}
\defbibenvironment{drorlist}
{\list
{}
{\setlength{\leftmargin}{\bibhang}%
\setlength{\itemindent}{-\leftmargin}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}}
{\endlist}
{\item}
\makeatletter
\newcommand{\makealldror}{\def\blx@driver##1{\csuse{blx@bbx@drorver}}}
\makeatother
\begin{document}
\nocite{*}
\begingroup
\makealldror
\printbibliography[env=drorlist]
\endgroup
\printbibliography
\end{document}
我们可以使用citeall
此任务的包。
首先我们需要为这项工作定义一个好的引用宏。它主要是从标准.cbx
文件中拼凑起来的。
\newbibmacro*{cite:title}{%
\printtext[bibhyperref]{%
\printfield[citetitle]{labeltitle}}}
\newbibmacro*{cite:shorthand}{%
\printtext[bibhyperref]{\printfield{shorthand}}}
\newbibmacro*{citetitle}{%
\iffieldundef{shorthand}
{\usebibmacro{cite:title}}%
{\usebibmacro{cite:shorthand}}}
\newbibmacro*{drorcite}{%
\usebibmacro{citetitle}%
\setunit{\addcomma\space}%
\printfield{year}%
\setunit{\addspace}%
\printtext[brackets]{\usebibmacro{cite}}%
\par
\printfield{note}%
}
\DeclareCiteCommand{\drorcite}
{\usebibmacro{prenote}}
{\usebibmacro{drorcite}}
{\multicitedelim}
{\usebibmacro{postnote}}
然后就
\citeall[\drorcite]
并且文件中的所有条目.bib
都以 引用\drorcite
。
平均能量损失
\documentclass{article}
\usepackage[backend=biber,style=numeric]{biblatex}
\usepackage{citeall}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{batty2007iq,
title={IQ in early adulthood and later cancer risk: cohort study of one million Swedish men},
author={Batty, G. David and Wennerstad, Karin Modig and Smith, George Davey and Gunnell, David and Deary, Ian J. and Tynelius, Per and Rasmussen, Finn},
journal={Annals of Oncology},
volume={18},
number={1},
pages={21--28},
year={2007},
publisher={European Society for Medical Oncology},
note = {ipsum ipsum ipsum ipsum},
}
@article{batty2007premorbid,
title={Premorbid (early life) IQ and Later Mortality Risk: Systematic Review},
author={Batty, G. David and Deary, Ian J. and Gottfredson, Linda S.},
journal={Annals of Epidemiology},
volume={17},
number={4},
pages={278--288},
year={2007},
publisher={Elsevier},
note = {Lorem lorem lorem lorem lorem lorem},
}
@article{batty2009iq_early,
title={IQ in Early Adulthood and Mortality By Middle Age: Cohort Study of 1 Million Swedish Men},
author={Batty, G. David and Wennerstad, Karin Modig and Smith, George Davey and Gunnell, David and Deary, Ian J. and Tynelius, Per and Rasmussen, Finn},
journal={Epidemiology},
volume={20},
number={1},
pages={100--109},
year={2009},
publisher={LWW},
note = {In Mexico is een man gearresteerd.},
}
@article{batty2009iq_socio,
title={IQ in Early Adulthood, Socioeconomic Position, and Unintentional Injury Mortality by Middle Age: A Cohort Study of More Than 1 Million Swedish Men},
author={Batty, G. David and Gale, Catharine R. and Tynelius, Per and Deary, Ian J. and Rasmussen, Finn},
journal={American Journal of Epidemiology},
volume={169},
number={5},
pages={606--615},
year={2009},
publisher={Oxford University Press},
note = {Lore ipsum dolor sit amet},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\newbibmacro*{cite:title}{%
\printtext[bibhyperref]{%
\printfield[citetitle]{labeltitle}}}
\newbibmacro*{cite:shorthand}{%
\printtext[bibhyperref]{\printfield{shorthand}}}
\newbibmacro*{citetitle}{%
\iffieldundef{shorthand}
{\usebibmacro{cite:title}}%
{\usebibmacro{cite:shorthand}}}
\newbibmacro*{drorcite}{%
\usebibmacro{citetitle}%
\setunit{\addcomma\space}%
\printfield{year}%
\setunit{\addspace}%
\printtext[brackets]{\usebibmacro{cite}}%
\par
\printfield{note}%
}
\DeclareCiteCommand{\drorcite}
{\usebibmacro{prenote}}
{\usebibmacro{drorcite}}
{\multicitedelim}
{\usebibmacro{postnote}}
\begin{document}
\citeall[\drorcite]
\end{document}
答案2
您可以使用citeall
。但是如果您的条目没有注释字段,则可能必须定义更好的\completecite
命令。还请注意,citeall
编写该命令是为了测试和调试新的引用样式,而不是为了“文档循环”。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}
\usepackage{citeall}
\newcommand{\completecite}[1]{%
\citetitle{#1}, \citeauthor{#1} \cite{#1}
\par
\citefield{#1}{note}\par
}
\begin{document}
\citeall[\completecite]
\end{document}