我想删除@thesis 书目条目中“学校”字段和日期(年份)之间的逗号:
这是我的最小示例代码:
\documentclass{minimal}
\usepackage{ngerman}
\usepackage[backend = biber, style = numeric]{biblatex}
%%%%%%%% https://tex.stackexchange.com/a/492917
\newtoggle{bbx:datemissing}
\renewbibmacro*{date}{\toggletrue{bbx:datemissing}%}
\renewbibmacro{volume+number+eid}{%
\printfield{volume}%
\setunit{\addcomma\space}%
\printfield{eid}}
\renewbibmacro*{issue+date}{%
\toggletrue{bbx:datemissing}%
\iffieldundef{issue}{}{
\printtext[parens]{%
\printfield{issue}}}%
\newunit}
\newbibmacro*{date:print}{%
\togglefalse{bbx:datemissing}%
\printdate}
\renewbibmacro*{chapter+pages}{%
\printfield{chapter}%
\setunit{\bibpagespunct}%
\printfield{pages}%
\newunit
\usebibmacro{date:print}%
\newunit}
\renewbibmacro*{note+pages}{%
\printfield{note}%
\setunit{\bibpagespunct}%
\printfield{pages}%
\newunit
\usebibmacro{date:print}%
\newunit}
%%%%%%%%
%%% This is what I came up with
\renewbibmacro{institution+location+date}{%
\printlist{location}%
\iflistundef{institution}{%
\setunit*{\space}%
}{%
\setunit*{\addcolon\space}%
}%
\printlist{institution}%
\setunit*{\space}%
\usebibmacro{date}%
\newunit%
}
\usepackage{filecontents}
\begin{filecontents*}{lit.bib}
@thesis {mythesis,
author = {Me, I.},
school = {University},
title = {Sometitle},
type = {Phd thesis},
year = {123}
}
\end{filecontents*}
\addbibresource{lit.bib}
\begin{document}
\printbibliography
\end{document}
\nocite{*}
我已经尝试过了\renewbibmacro{institution+location+date}{...}
,但是没有用。我对 BibLaTeX 还不太熟悉。
我的想法是,样式numeric
使用了 中的条目类型standard
,我从中复制了宏并删除了所有逗号。但是,这显然不起作用。我该如何删除这个逗号?
答案1
您可以在重新定义的宏的\nopunct
前面添加。我已将示例的文档类更改为。尽管名称如此,但文档类应该\newunit
institution+location+date
article
minimal
不是因为它实际上太小了,所以不用于 MWE。我还删除了该filecontents
包,它现在是 LaTeX 内核的一部分。
\documentclass{article}
\usepackage{ngerman}
\usepackage[backend = biber, style = numeric]{biblatex}
\newtoggle{bbx:datemissing}
\renewbibmacro*{date}{\toggletrue{bbx:datemissing}}
\renewbibmacro{volume+number+eid}{%
\printfield{volume}%
\setunit{\addcomma\space}%
\printfield{eid}}
\renewbibmacro*{issue+date}{%
\toggletrue{bbx:datemissing}%
\iffieldundef{issue}{}{
\printtext[parens]{%
\printfield{issue}}}%
\newunit}
\newbibmacro*{date:print}{%
\togglefalse{bbx:datemissing}%
\printdate}
\renewbibmacro*{chapter+pages}{%
\printfield{chapter}%
\setunit{\bibpagespunct}%
\printfield{pages}%
\newunit
\usebibmacro{date:print}%
\newunit}
\renewbibmacro*{note+pages}{%
\printfield{note}%
\setunit{\bibpagespunct}%
\printfield{pages}%
\newunit
\usebibmacro{date:print}%
\newunit}
%%% This is what I came up with
\renewbibmacro{institution+location+date}{%
\printlist{location}%
\iflistundef{institution}{%
\setunit*{\space}%
}{%
\setunit*{\space}%
}%
\printlist{institution}%
\setunit*{\space}%
\usebibmacro{date}%
\nopunct\newunit%
}
\begin{filecontents*}[overwrite]{\jobname.bib}
@thesis {mythesis,
author = {Me, I.},
school = {University of Somewhere},
title = {Sometitle},
type = {Phd thesis},
year = {1980}
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
答案2
答案更改 Biblatex 中的页面和年份的顺序,您正在使用的代码,使用相当钝的工具将date
打印移到之后pages
。这可能并非您在所有情况下都想要或需要的。
pages
这是一个稍微复杂一些的设置,只有当有(或)时才移动日期chapter
,这可能会导致在某些情况下输出的效果稍微好一些。
\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage[backend=biber, style=numeric]{biblatex}
\newtoggle{bbx:datesuppressed}
\renewbibmacro*{date}{%
\ifboolexpr{
test {\iffieldundef{pages}}
and test {\iffieldundef{chapter}}}
{\printdate}
{\toggletrue{bbx:datesuppressed}}}
\renewbibmacro{volume+number+eid}{%
\printfield{volume}%
\setunit{\addcomma\space}%
\printfield{eid}}
\renewbibmacro*{issue+date}{%
\toggletrue{bbx:datesuppressed}%
\iffieldundef{issue}
{}
{\printtext[parens]{%
\printfield{issue}}}%
\newunit}
\newbibmacro*{date:print}{%
\iftoggle{bbx:datesuppressed}
{\togglefalse{bbx:datesuppressed}%
\printdate}
{}}
\renewbibmacro*{chapter+pages}{%
\printfield{chapter}%
\setunit{\bibpagespunct}%
\printfield{pages}%
\newunit
\usebibmacro{date:print}%
\newunit}
\renewbibmacro*{note+pages}{%
\printfield{note}%
\setunit{\bibpagespunct}%
\printfield{pages}%
\newunit
\usebibmacro{date:print}%
\newunit}
\renewbibmacro{institution+location+date}{%
\printlist{location}%
\iflistundef{institution}
{\setunit*{\space}}
{\setunit*{\addcolon\space}}%
\printlist{institution}%
\setunit*{\space}%
\usebibmacro{date}%
\newunit
}
\begin{filecontents*}{\jobname.bib}
@phdthesis{mythesis,
author = {Me, I.},
school = {University},
title = {Sometitle},
year = {123},
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}
\begin{document}
\nocite{mythesis,sigfridsson,westfahl:space}
\printbibliography
\end{document}
正如艾伦在他的答案下的评论中所解释的那样,biblatex
的标点符号处理是异步的:标点符号存储在缓冲区中,仅在需要时打印(即,当下一条\print...
命令实际打印某些内容时)。由于在问题中的代码中,\usebibmacro{date}
ininstitution+location+date
实际上并不打印日期,因此before 最终并不控制日期之前的标点符号。日期仅由in \setunit
打印,此时其他命令将不同的标点符号添加到缓冲区中。date:print
chapter+pages
\setunit
\nopunct
设置永久标记,在命令打印新内容/文本之前不打印任何标点符号\print...
。在这种情况下,它有助于抑制不需要的句号。由于\nopunct
可以在标点符号跟踪器内部和外部使用,因此它是一个调整标点符号的方便工具,但我通常会尽量避免使用它,并且更喜欢不使用它的解决方案,因为它可能会产生超出预期的效果。