我想使用 XeLaTeX 和 Biber 创建一份包含参考书目的文档。参考书目中有中文书籍和文章,也有英文或德文书籍和文章。有些作者用中文和英文撰写了文章(或书籍,这里不重要)。在中文文章中,我还想用字符为作者提供中文姓名,而在他的英文文章中则不需要这样做。
下面是我的 .bib 文件的示例。该\zh{}
函数用于防止 LaTeX 打印脚注中的字符:
@article{Liu2008,
author = {Liu, {Guofu \zh{(刘国福)}}},
title = {The Latest Development of Immigration Law: On the Transformation of China's Emmigration and Immigration Administration Law (移民法的最新发展——兼论中国出入境管理法的改造和重塑)},
journal = {Journal of Henan Administrative Institute of Politics and Law (河南省政法管理干部学院学报)},
year = {2008},
volume = {5},
pages = {46--58},
language = {chinese},
keywords = {article,hani}
}
@book{Liu2011,
author = {Liu, {Guofu \zh{(刘国福)}}},
title = {Chinese Immigration Law},
year = {2011},
publisher = {Ashgate},
address = {Farnham},
language = {english},
keywords = {monography,latn}
}
现在的重点是:Biber 当然只在两条记录的作者字段内容相同的情况下才会将作者视为同一人。如果我在英文文章中也不使用中文字符,Biber 会写出全名,以便区分“两位”作者,而忽略他们实际上是同一个人的事实。因此,即使在英文或德文文章中,我也需要在作者姓名中包含中文字符。
这样做了之后,我得到了我想要的一切:在参考书目中,作者的名字有“刘国福 (2008)”的模式,而在脚注中只有“LIU 2008”(只要没有其他名叫刘的作者)。
我使用 .tex 文件前言部分中的以下代码片段完成了此操作:
\providecommand{\zh}[1]{}
\AtBeginBibliography{%
\renewcommand*{\zh}[1]{#1}
}
但是:如果条目没有将中文设置为语言,我该如何告诉 LaTeX 不要打印\zh{}
作者字段中的部分。有没有这样有条件地设置的方法?此外,在脚注中永远不应该出现中文字符。如果我可以直接告诉 LaTeX 如何在 .tex 文件中执行此操作,那就太好了。
还有多位作者的文章,其格式应为“王丽萍;张爱玲 (2008)”,我猜这会让使用另一个中文字符输入字段变得有些复杂,因为这样所有中文名字都会排在拉丁字母作者姓名列表之后。
编辑(2014-03-22):
看来我的问题已经在其他地方考虑过了:
如何使用 biblatex、biber 和 polyglossia 创建多语言(英语、日语)书目
因此,从 bibLaTeX 3.0 和 biber 2.0(目前两个版本均处于实验阶段)开始,可以保存大多数领域的转录或翻译,更令人惊奇的是,有一种方法可以为每个 .bib 条目分别设置显示模式(显示原始语言、显示翻译等)。
编辑(2014-03-23):
另一种方法是使用名称词缀:
https://tex.stackexchange.com/a/66825/47927
这似乎是 ienissei 提案的一个实际例子。
答案1
为了最终全面回答我自己的问题以供将来参考,以下内容将实现我最初想要的效果:
首先,不需要使用令牌\zh{}
,因为此示例将使用 Audrey 在此处描述的名称词缀:https://tex.stackexchange.com/a/66825/47927
我没有使用titleaddon
奥黛丽求婚的部分,因为我不需要这个。另外,我坚持只使用姓氏和名字的顺序。
因此,参考书目条目应该是这样的(关键字“latn”或“hani”代表相应文章的书写系统,用于有条件地隐藏名称的中文部分):
@article{Liu2008,
author = {Liu, 刘国福, Guofu},
title = {The Latest Development of Immigration Law: On the Transformation of China's Emmigration and Immigration Administration Law (移民法的最新发展——兼论中国出入境管理法的改造和重塑)},
journal = {Journal of Henan Administrative Institute of Politics and Law (河南省政法管理干部学院学报)},
year = {2008},
volume = {5},
pages = {46--58},
language = {chinese},
keywords = {article,hani}
}
@book{Liu2011,
author = {Liu, 刘国福, Guofu},
title = {Chinese Immigration Law},
year = {2011},
publisher = {Ashgate},
address = {Farnham},
language = {english},
keywords = {monography,latn}
}
现在介绍 .tex 文件的部分(根据 Audrey 的上述链接帖子稍作编辑):
% Keep name affixes for English names
\forcsvlist{\listadd\nameaffixlist}{Junior,Senior}
\newcommand{\ifnameaffix}[1]{%
\ifboolexpr{test{\ifrmnum{#1}} or test{\ifinlist{#1}{\nameaffixlist}}}}
% Set label format using last-first order
\DeclareNameFormat{labelname}{%
\ifboolexpr{test{\ifblank{#7}} or test{\ifnameaffix{#7}}}
{\ifcase\value{uniquename}%
\usebibmacro{name:last}{#1}{#3}{#5}{#7}\or
\ifuseprefix
{\usebibmacro{name:last-first}{#1}{#4}{#5}{#8}}
{\usebibmacro{name:last-first}{#1}{#4}{#6}{#8}}\or
\usebibmacro{name:last-first}{#1}{#3}{#5}{#7}\fi}%
{\ifnumequal{\value{uniquename}}{0}%
{\usebibmacro{name:cjk}{#1}{}{}}
{\usebibmacro{name:cjk}{#1}{#3}{}}}%
\usebibmacro{name:andothers}
}
% Set name field format also using last-first order
\DeclareNameFormat{last-first}{%
\ifboolexpr{test{\ifblank{#7}} or test{\ifnameaffix{#7}}}
{\iffirstinits
{\usebibmacro{name:last-first}{#1}{#4}{#5}{#7}}
{\usebibmacro{name:last-first}{#1}{#3}{#5}{#7}}}
{\usebibmacro{name:cjk}{#1}{#3}{#7}}%
\usebibmacro{name:andothers}
}
\DeclareNameAlias{sortname}{last-first}
\DeclareNameAlias{default}{last-first}
% Making Chinese name appear after first name in parentheses, but only if the keyword 'hani' exists (see bib entries above for reference)
\newbibmacro*{name:cjk}[3]{%
\usebibmacro{name:delim}{#2#3#1}%
\usebibmacro{name:hook}{#2#3#1}%
\mkbibnamelast{#1}%
\ifblank{#2}{}{\bibnamedelimd\mkbibnamefirst{#2}}%
\ifkeyword{hani}{%
\ifblank{#3}{}{\bibnamedelimd\mkbibnameaffix{\mkbibparens{#3}}}%
}{}
}
\AtEveryBibitem{\clearlist{language}}
\AtBeginBibliography{%
\renewcommand*{\multinamedelim}{\addsemicolon\space}
}
需要注意的一点是:如果参考书目中只显示作者的第一次出现,而后面的出现用破折号代替,则此脚本将根据第一个条目的语言选择第一次出现。因此,如果第一个条目不是中文,但后面的条目之一是中文,则中文名称不会出现在任何地方。
编辑(2018-01-22):
宏名称name:last
和name:first
已更改为name:family
和name:given
,因此宏\mkbibnamefirst
也已重命名为\mkbibnamegiven
和\iffirstinits
为\ifgiveninits
。此外,\ifblank
应更改为\ifdefvoid
。我最近没有测试这个答案。我猜,由于 BibLaTeX 包在此期间已更新多次,因此必须更改其他一些内容。
这是我作为 MWE 的最终设置(尽管代码相当多):
\begin{filecontents}{example.bib}
@article{Liu2008,
author = {Liu, 刘国福, Guofu},
title = {The Latest Development of Immigration Law: On the Transformation of China's Emmigration and Immigration Administration Law (移民法的最新发展——兼论中国出入境管理法的改造和重塑)},
journal = {Journal of Henan Administrative Institute of Politics and Law (河南省政法管理干部学院学报)},
year = {2008},
volume = {5},
pages = {46--58},
language = {chinese},
keywords = {article,hani}
}
@book{Liu2011,
author = {Liu, 刘国福, Guofu},
title = {Chinese Immigration Law},
year = {2011},
publisher = {Ashgate},
address = {Farnham},
language = {english},
keywords = {monography,latn}
}
\end{filecontents}
\documentclass{article}
\usepackage{fontspec}
\setmainfont[SmallCapsFeatures={LetterSpace=2}]{TeX Gyre Termes}
\usepackage{xeCJK}
\setCJKmainfont[Script=CJK]{Noto Serif CJK SC}
\CJKsetecglue{\,}
\usepackage[
backend=biber,
language=autobib,
autolang=hyphen,
style=authoryear,
defernumbers=true,
sortlocale=en-GB,
urldate=long,
dateabbrev=false,
sortcites=true,
sorting=anyvt,
safeinputenc
]{biblatex}
% =====
\renewbibmacro*{labeltitle}{\iffieldundef{shorttitle}%
{\printfield{title}\clearfield{title}}%
{\mkbibemph{\printfield{shorttitle}}\addspace\printtext[parens]{\printfield{year}}}%
}
\renewbibmacro*{date+extradate}{\ifkeyword{law}%
{}%
{\printtext[parens]{%
\iflabeldateisdate%
{\printfield{issue}\setunit*{\addspace}\printdateextra}%
{\printlabeldateextra}}}%
}
\renewbibmacro*{issue+date}{\ifkeyword{law}%
{}%
{\iflabeldateisdate%
{\printfield{issue}\setunit*{\addspace}\printtext[parens]{\printdate}}%
{\printtext[parens]{\printfield{issue}\setunit*{\addspace}\printdate}}}%
}
\renewbibmacro*{cite:labeldate+extradate}{\ifkeyword{law}%
{}%
{\iffieldundef{labelyear}%
{}%
{\printtext[bibhyperref]{\mkbibparens{\printlabeldateextra}}}}%
}
\renewcommand*{\multinamedelim}{\addnbthinspace\slash\thinspace}
\renewcommand*{\finalnamedelim}{\multinamedelim}
\renewcommand*{\labelnamepunct}{\addcolon\addspace}
\renewcommand*\mkbibnameprefix[1]{\textsc{#1}}
\renewcommand*\mkbibnamefamily[1]{\textsc{#1}}
\renewcommand*\bibnamedash{\rule[.48ex]{3em}{.5pt}\addspace}
\DeclareFieldFormat*{citetitle}{\mkbibemph{#1}}
\DeclareFieldFormat*{extradate}{\addnbthinspace\mknumalph{#1}}
\DeclareFieldFormat*{url}{URL\addcolon\addspace\url{#1}}
% =====
% Settings for Chinese names
\forcsvlist{\listadd\nameaffixlist}{Junior,Senior}
\newcommand{\ifnameaffix}[1]{%
\ifboolexpr{ test {\ifrmnum{#1}} or test {\xifinlist{#1}{\nameaffixlist}} }}
% Based on definitions from biblatex.def
\newbibmacro*{name:cjk}[3]{%
\usebibmacro{name:delim}{#2#3#1}%
\usebibmacro{name:hook}{#2#3#1}%
\mkbibnamefamily{#1}%
\ifdefvoid{#2}{}{\bibnamedelimd\mkbibnamegiven{#2}}%
\ifkeyword{hani}{%
\ifdefvoid{#3}{}{\bibnamedelimd\mkbibnamesuffix{\mkbibparens{\upshape #3}}}%
}{}}
\newbibmacro*{name:cjk-short}[3]{%
\usebibmacro{name:delim}{#2#3#1}%
\usebibmacro{name:hook}{#2#3#1}%
\mkbibnamefamily{#1}%
\ifdefvoid{#2}{}{\bibnamedelimd\mkbibnamegiven{#2}}%
\ifkeyword{hani}{%
\ifdefvoid{#3}{}{}%
}{}}
\DeclareNameFormat{given-family}{%
\ifboolexpr{ test {\ifdefvoid{\namepartsuffix}} or test {\ifnameaffix{\namepartsuffix}} }%
{\ifgiveninits%
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiveni}
{\namepartprefix}
{\namepartsuffix}}%
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}}}%
{\usebibmacro{name:cjk}{\namepartfamily}{\namepartgiven}{\namepartsuffix}}%
\usebibmacro{name:andothers}}
\DeclareNameFormat{family-given}{%
\ifboolexpr{ test {\ifdefvoid{\namepartsuffix}} or test {\ifnameaffix{\namepartsuffix}} }%
{\ifgiveninits%
{\usebibmacro{name:family-given}
{\namepartfamily}
{\namepartgiveni}
{\namepartprefix}
{\namepartsuffix}}%
{\usebibmacro{name:family-given}
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}}}%
{\usebibmacro{name:cjk}{\namepartfamily}{\namepartgiven}{\namepartsuffix}}%
\usebibmacro{name:andothers}}
\DeclareNameFormat{family-given/given-family}{%
\ifboolexpr{ test {\ifdefvoid{\namepartsuffix}} or test {\ifnameaffix{\namepartsuffix}} }%
{\ifnumequal{\value{listcount}}{1}%
{\ifgiveninits%
{\usebibmacro{name:family-given}
{\namepartfamily}
{\namepartgiveni}
{\namepartprefix}
{\namepartsuffix}}%
{\usebibmacro{name:family-given}
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}}%
\ifboolexpe{ test {\ifdefvoid\namepartgiven} and test {\ifdefvoid\namepartprefix} }%
{}%
{\usebibmacro{name:revsdelim}}}%
{\ifgiveninits%
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiveni}
{\namepartprefix}
{\namepartsuffix}}%
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}}}}%
{\usebibmacro{name:cjk}{\namepartfamily}{\namepartgiven}{\namepartsuffix}}%
\usebibmacro{name:andothers}}
\DeclareNameFormat{labelname}{%
\ifcase\value{uniquename}%
\usebibmacro{name:family}
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}%
\or%
\ifboolexpr{ test {\ifdefvoid{\namepartsuffix}} or test {\ifnameaffix{\namepartsuffix}} }%
{\ifuseprefix%
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiven} % i
{\namepartprefix}
{\namepartsuffix}}% i
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiven} % i
{\namepartprefix} % i
{\namepartsuffix}}}% i
{\usebibmacro{name:cjk-short}{\namepartfamily}{\namepartgiven}{\namepartsuffix}}%
\or%
\ifboolexpr{ test {\ifdefvoid{\namepartsuffix}} or test {\ifnameaffix{\namepartsuffix}} }%
{\usebibmacro{name:given-family}%
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}}%
{\usebibmacro{name:cjk-short}{\namepartfamily}{\namepartgiven}{\namepartsuffix}}%
\fi%
\usebibmacro{name:andothers}}
\DeclareFieldFormat{citetitle}{\mkbibemph{#1}\ifkeyword{law}{\addspace\printtext[parens]{\printfield{year}}}{}}
\AtEveryBibitem{\clearlist{language}}
\AtBeginBibliography{%
\renewcommand*{\multinamedelim}{\addsemicolon\addspace}%
}
\DefineBibliographyExtras{english}{%
\protected\def\mkbibdatelong#1#2#3{%
\iffieldundef{#3}
{}
{\stripzeros{\thefield{#3}}%
\iffieldundef{#2}{}{\nobreakspace}}%
\iffieldundef{#2}
{}
{\mkbibmonth{\thefield{#2}}%
\iffieldundef{#1}{}{\space}}%
\iffieldbibstring{#1}
{\bibstring{\thefield{#1}}}
{\stripzeros{\thefield{#1}}}%
}%
}
\addbibresource{example.bib}
\begin{document}
Some text.\footnote{\cite{Liu2008}, \cite{Liu2011}.}
\printbibliography
\end{document}
书目的输出是:
脚注的输出是: