我试图改进我的乳胶代码,并想确保如果有一个版本,它前面不会有一个点,因为我将它设置为括号中(并且在括号前面和后面有一个点对我来说看起来很奇怪)。
这是我的旧代码:
\documentclass[
12pt,
a4paper,
headings=standardclasses,
listof=totoc,
numbers=noenddot
]{scrartcl}
\usepackage[
backend=biber,
style=ext-authoryear,
sorting=nyvt,
datamodel=customstyles,
maxnames=25,
innamebeforetitle=true,
usetranslator=true,
alldates=terse,
labeldate=year,
dashed=false,
doi=false,
isbn=false,
url=false
]{biblatex}
\addbibresource{\jobname.bib}
% edition in front of addendum in parantheses
\DeclareFieldFormat{edition}{\mkbibparens{#1}}
\renewbibmacro*{edition}{}
\renewbibmacro*{pubinstorg+location+date}[1]{%
\printlist{location}%
\iflistundef{#1}
{\setunit*{\locdatedelim}}
{\setunit*{\locpubdelim}}%
\printlist{#1}%
\setunit*{\pubdatedelim}%
\usebibmacro{date}%
\newunit
\printfield{edition}%
\newunit}
\usepackage[hidelinks, pdfencoding=auto]{hyperref}
\usepackage{microtype}% avoid bib formatting issues
\begin{filecontents}{\jobname.bib}
@book{Wittgenstein.1999,
address = {Cambridge, Mass.},
author = {Wittgenstein, Ludwig},
date-modified = {2021-04-20 20:44:48 +0900},
edition = {Nachdruck der 2. Aufl., Erstauflage 1953},
isbn = {0-631-14670-9},
publisher = {Blackwell},
title = {Philosophische Untersuchungen. Philosophical Investigations},
translator = {Anscombe, G. E. M.},
year = {1999}}
\end{filecontents}
\begin{document}
\section{Introduction}
\cite{Wittgenstein.1999}
\printbibliography
\end{document}
这是我修改代码的方式:
\documentclass[
12pt,
a4paper,
headings=standardclasses,
listof=totoc,
numbers=noenddot
]{scrartcl}
\usepackage[
backend=biber,
style=ext-authoryear,
sorting=nyvt,
datamodel=customstyles,
maxnames=25,
innamebeforetitle=true,
usetranslator=true,
alldates=terse,
labeldate=year,
dashed=false,
doi=false,
isbn=false,
url=false
]{biblatex}
\addbibresource{\jobname.bib}
% edition in front of addendum in parantheses
\DeclareFieldFormat{edition}{\mkbibparens{#1}}
\renewbibmacro*{edition}{}
\renewbibmacro*{pubinstorg+location+date}[1]{%
\printlist{location}%
\iflistundef{#1}
{\setunit*{\locdatedelim}}
{\setunit*{\locpubdelim}}%
\printlist{#1}%
\setunit*{\pubdatedelim}%
\usebibmacro{date}%
\setunit{\space}%
\printfield{edition}%
\newunit}
\usepackage[hidelinks, pdfencoding=auto]{hyperref}
\usepackage{microtype}% avoid bib formatting issues
\begin{filecontents}{\jobname.bib}
@book{Wittgenstein.1999,
address = {Cambridge, Mass.},
author = {Wittgenstein, Ludwig},
date-modified = {2021-04-20 20:44:48 +0900},
edition = {Nachdruck der 2. Aufl., Erstauflage 1953},
isbn = {0-631-14670-9},
publisher = {Blackwell},
title = {Philosophische Untersuchungen. Philosophical Investigations},
translator = {Anscombe, G. E. M.},
year = {1999}}
\end{filecontents}
\begin{document}
\section{Introduction}
\cite{Wittgenstein.1999}
\printbibliography
\end{document}
这是正确的方法吗?还是我应该考虑采用不同的方法?
答案1
那 - 就像
\DeclareFieldFormat{edition}{\mkbibparens{#1}}
\renewbibmacro*{edition}{}
\renewbibmacro*{pubinstorg+location+date}[1]{%
\printlist{location}%
\iflistundef{#1}
{\setunit*{\locdatedelim}}
{\setunit*{\locpubdelim}}%
\printlist{#1}%
\setunit*{\pubdatedelim}%
\usebibmacro{date}%
\setunit{\space}%
\printfield{edition}%
\newunit}
基本上我也会这么做。
我只会使用\setunit{\addspace}%
而不是\setunit{\space}
。\addspace
是一个biblatex
与 相比执行一些额外管理的命令\space
。 (它会尝试避免不必要的双空格等。如果其余代码很好,则可能不需要进行管理。但这是在这里代替 的biblatex
常用习惯用法。)\addspace
\space
具体来说,\setunit{\addspace}
(或\setunit{\space}
)将一个空格添加到的标点符号缓冲区,然后如果字段非空,则该空格biblatex
将在 之前打印。如果字段为空,则空格将保留在缓冲区中,直到遇到下一个可打印的内容。但这通常会先于另一个覆盖缓冲区中空格的操作。edition
edition
\setunit
在所有意图和目的上都\newunit
等同于\setunit{\newunitpunct}
,因此会做同样的事情,只是用\newunitpunct
(默认情况下是句点加空格)代替空格。
底线:如果你想控制标点符号前特定字段,只需\setunit
在相关之前使用即可\printfield
。