正文和参考书目采用两种语言,但日期格式不同

正文和参考书目采用两种语言,但日期格式不同

我正在用美式英语和德语(新正字法)写一篇文章,所以我使用\usepackage[ngerman,USenglish]{babel}。biblatex 书目还包含英语和德语参考文献。我需要书目中每种语言的连字规则,因此我使用\usepackage[backend=biber,language=autobib,autolang=hyphen]{biblatex}然后指定各个书目条目的语言,如下所示:langid = {ngerman}

但我希望所有日期都采用澳大利亚格式 (dd Mon. YYYY)。我如何才能获得这种日期格式(尤其是在参考书目中)?

(如果我不需要参考书目中的德语连字符规则,我只需删除autolanglangid并使用\usepackage[backend=biber,language=australian{biblatex},尽管这也会将参考书目中的连字符、引号、逗号等的样式更改为australian样式。)

答案1

我不知道是否有一种简单的方法可以让整个文档中的所有日期都遵循澳大利亚格式,但我知道如何将澳大利亚日期格式应用于参考书目而不影响连字符样式。

您可以添加到 babel,然后在打印参考书目之前australian切换语言。然后参考书目中的所有日期都将是澳大利亚风格的。australian

请注意,此解决方案还会影响参考书目中的其他样式因素,例如连续逗号(如这里所述) 和引号格式。例如,以USenglish格式打印的文章引用使用双引号,并将结束标点符号保留在引号内,而以australian格式打印的文章引用使用单引号,并将结束标点符号保留在引号外:

“美式英语文章标题。”
“澳大利亚英语文章标题”。

以下代码举例说明了结果:

\documentclass{article}
\usepackage[ngerman,australian,USenglish]{babel}
\usepackage[autostyle]{csquotes}
\usepackage[backend=biber,language=autobib,autolang=hyphen,sorting=none]{biblatex}
\addbibresource{testbib.bib}

\begin{filecontents}{testbib.bib}
@article{default2014,
  author = {Vorname Nachname},
  title = {The German Rindfleischetikettierungs\"uberwachungsaufgaben\"ubertragungsgesetz},
  journaltitle = {Default Journal of Gastroenterology},
  date = {2014-03-20},
}
@article{au2014,
  author = {Vorname Nachname},
  title = {The German Rindfleischetikettierungs\"uberwachungsaufgaben\"ubertragungsgesetz},
  journaltitle = {Australian Journal of Gastroenterology},
  date = {2014-03-20},
  langid = {australian},
}
@article{us2014,
  author = {Vorname Nachname},
  title = {The German Rindfleischetikettierungs\"uberwachungsaufgaben\"ubertragungsgesetz},
  journaltitle = {American Journal of Gastroenterology},
  date = {2014-03-20},
  langid = {USenglish},
}
@article{de2014,
  author = {Vorname Nachname},
  title = {Das deutsche Rindfleischetikettierungs\"uberwachungsaufgaben\"ubertragungsgesetz},
  journaltitle = {Zeitschrift f\"ur Gastroenterologie},
  date = {2014-03-20},
  langid = {ngerman},
}
\end{filecontents}

\begin{document}
% main text here in USenglish (switch to ngerman when necessary)
The hyphenation rules of Australian English, American English, and German are\
different~\cite{default2014,au2014,us2014,de2014}.

\selectlanguage{australian} % for proper day/month order
\printbibliography
\end{document}

英语条目遵循英语连字规则。德语条目遵循德语连字规则。两个条目都遵循澳大利亚日期格式。

langid省略该字段时,连字符样式默认为当前选定的语言的样式(在此示例中为australian)。

答案2

谢谢moewe 的回答在这里,我能够弄清楚如何改变整个文档中的所有长日期澳大利亚格式。然后我弄清楚了如何显示所有短日期采用 d/m/y 格式(使用 中的代码british.lbx,其中australian.lbx继承了其短日期格式)。此答案更改了日期格式(短日期格式和长日期格式)仅此而已. 它将日前月份风格应用于用美式英语撰写的整个文档。

最简单的方法是将其插入到序言中:

\DefineBibliographyExtras{USenglish}{%

  % d-m-y format for long dates
  \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}}}}%

  % d-m-y format for short dates
  \protected\def\mkbibdateshort#1#2#3{%
    \iffieldundef{#3}
      {}
      {\mkdatezeros{\thefield{#3}}%
       \iffieldundef{#2}{}{/}}%
    \iffieldundef{#2}
      {}
      {\mkdatezeros{\thefield{#2}}%
       \iffieldundef{#1}{}{/}}%
    \iffieldbibstring{#1}{\bibstring{\thefield{#1}}}{\mkdatezeros{\thefield{#1}}}}%
}

我使用别名 编写了代码USenglish,但american如果您愿意,也可以将其替换为 。它们是同一风格的两个名称。不过,您需要确保它是调用 时使用的相同别名\usepackage{babel}。(如果您更改 的属性USenglish,请不要指望更改会转移到american!)

更优雅的解决方案是制作一个 .lbx 文件,使其更加井然有序,并使这种风格在未来的文档中更容易访问。代码仅在开头和结尾处有所不同。您需要\ProvidesFile在顶部和\endinput底部添加。然后添加两个\Inherit...命令并将任何命令更改\Define...Declare...命令。

\ProvidesFile{USenglish-dmy.lbx}[USenglish localization with d-m-y format for dates]

\InheritBibliographyExtras{USenglish}
\DeclareBibliographyExtras{%

  % d-m-y format for long dates
  \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}}}}%

  % d-m-y format for short dates
  \protected\def\mkbibdateshort#1#2#3{%
    \iffieldundef{#3}
      {}
      {\mkdatezeros{\thefield{#3}}%
       \iffieldundef{#2}{}{/}}%
    \iffieldundef{#2}
      {}
      {\mkdatezeros{\thefield{#2}}%
       \iffieldundef{#1}{}{/}}%
    \iffieldbibstring{#1}{\bibstring{\thefield{#1}}}{\mkdatezeros{\thefield{#1}}}}%
}

\InheritBibliographyStrings{USenglish}
\endinput

将其另存为USenglish-dmy.lbx,然后在您的序言中添加以下内容:\DeclareLanguageMapping{USenglish}{USenglish-dmy}。就是这样!现在所有日期都应在月份之前显示日期,并且不会影响任何其他内容(例如连字符或引号样式)。

答案3

必须使用\DefineBibliographyExtras{english}变通方法才能在我的设置(Biblatex + Polyglossia)上工作。

多语者通过选项处理,将澳大利亚语理解为英语的一种变体,

\setmainlanguage[variant=australian,ordinalmonthday=true]{english}

但这并没有改变任何东西。变体没有进入 Biblatex,不幸的是,gloss-english.ldf语言定义文件设置\english@ordinalmonthday为 false(也是\if@british@localefalse,因此\today被重新定义为美国格式)。

无论如何,Biblatex 将其english视为多语种语言,因此引用和参考文献中的日期排版为美国格式(这是的默认格式english)。

Biblatex 本身无需多语,就能理解澳大利亚的日期。

因此:由于语言的排版最终是一组用户选项或设计选择,就像“样式”或“主题”(连字符模式、月份和文档部分的名称、引号和标点符号、页面几何形状),并且由于 Biblatex 文档认为澳大利亚是一种语言(“多语种已知”),为什么不把它变成一种语言呢?

gloss-australian.ldf,只是gloss-english.ldf进行了一些细微的调整:

\ProvidesFile{gloss-australian.ldf}[polyglossia: module for australian english]%<=== changed for australian
\PolyglossiaSetup{australian}{%<=== changed for australian
  hyphennames={english,australian,american,usenglish,USenglish},%<=== changed for australian
  hyphenmins={2,3},
  fontsetup=true,
}

\newif\if@british@locale
\@british@localetrue %<=== changed for australian
\providebool{@british@hyphen}
\providebool{english@ordinalmonthday}

\define@boolkey{english}[english@]{ordinalmonthday}[true]{}

%% English is a special case in that \l@english is reserved for US English, so
%% we need to handle it differently
\define@key{english}{variant}{%
  %needs to be reset for loop over hyphennames below:
  \def\do##1{%
      \xpg@ifdefined{#1}%
        {\csletcs{l@english}{l@#1}\listbreak}%
        {}%
  }%
  \ifstrequal{#1}{uk}%
    {\@british@localetrue
     \xpg@info{Option: english variant=british}}%
    {\ifstrequal{#1}{british}%
      {\@british@localetrue
      \xpg@info{Option: english variant=british}}%
        {\ifstrequal{#1}{us}% these patterns are the default so we don't need to reset them
          {\@british@hyphenfalse\english@ordinalmonthdayfalse
           \xpg@info{Option: english variant=american}}%
          {\ifstrequal{#1}{american}%
            {\@british@hyphenfalse\english@ordinalmonthdayfalse
            \xpg@info{Option: english variant=american}}%
            {\ifstrequal{#1}{usmax}%
              {\@british@hyphenfalse\english@ordinalmonthdayfalse
                \ifluatex\else\setkeys[xpg@setup]{english}{hyphennames={usenglishmax}}\fi
                \xpg@info{Option: english variant=american (with additional patterns)}%
                \xpg@ifdefined{usenglishmax}{}%
                  {\xpg@warning{No hyphenation patterns were loaded for "US English Max"\MessageBreak
                    I will use the standard patterns for US English instead}%
                  \adddialect\l@usenglishmax\l@english\relax}%
                \gdef\english@language{\language=\l@usenglishmax}}%
                {\ifstrequal{#1}{australian}%
                  {\@british@hyphentrue\english@ordinalmonthdaytrue %<=== changed for australian
                  \xpg@info{Option: english variant=australian}}%
                  {\ifstrequal{#1}{newzealand}%
                    {\@british@hyphentrue\english@ordinalmonthdayfalse
                      \xpg@info{Option: english variant=newzealand}}%
                      {\xpg@warning{Unknown English variant `#1'}}%
  }}}}}}%
  \if@british@locale\@british@hyphentrue\english@ordinalmonthdaytrue\fi
  \if@british@hyphen
    \ifluatex\else\setkeys[xpg@setup]{english}{hyphennames={ukenglish,british,UKenglish}}\fi
    \xpg@ifdefined{ukenglish}{}%
      {\xpg@warning{No hyphenation patterns were loaded for British English\MessageBreak
         I will use the patterns for US English instead}%
       \adddialect\l@ukenglish\l@english\relax}%
    \gdef\english@language{\language=\l@ukenglish\xpg@set@language@luatex@ii{ukenglish}}%
  \fi
  % and we reset \do to its previous definition here:
  \def\do##1{\setotherlanguage{#1}}%
}

\def\captionsenglish{%
   \def\prefacename{Preface}%
   \def\refname{References}%
   \def\abstractname{Abstract}%
   \def\bibname{Bibliography}%
   \def\chaptername{Chapter}%
   \def\appendixname{Appendix}%
   \def\contentsname{Contents}%
   \def\listfigurename{List of Figures}%
   \def\listtablename{List of Tables}%
   \def\indexname{Index}%
   \def\figurename{Figure}%
   \def\tablename{Table}%
   \def\partname{Part}%
   \def\enclname{encl}%
   \def\ccname{cc}%
   \def\headtoname{To}%
   \def\pagename{Page}%
   \def\seename{see}%
   \def\alsoname{see also}%
   \def\proofname{Proof}%
}
\def\dateenglish{%
   \def\english@day{%
     \ifenglish@ordinalmonthday
       \ifcase\day\or
        1st\or 2nd\or 3rd\or 4th\or 5th\or
        6th\or 7th\or 8th\or 9th\or 10th\or
        11th\or 12th\or 13th\or 14th\or 15th\or
        16th\or 17th\or 18th\or 19th\or 20th\or
        21st\or 22nd\or 23rd\or 24th\or 25th\or
        26th\or 27th\or 28th\or 29th\or 30th\or
        31st\fi
     \else\number\day\fi}%
     \def\english@month{\ifcase\month\or
      January\or February\or March\or April\or May\or June\or
      July\or August\or September\or October\or November\or December\fi}%
   \def\today{%
    \if@british@locale
      \english@day\space\english@month\space\number\year
    \else
    \ifenglish@ordinalmonthday%<=== inserted for australian
        \english@day\space\english@month\space\number\year%<=== inserted for australian
    \else%<=== inserted for australian
      \english@month\space\english@day,\space\number\year
    \fi%<=== inserted for australian
    \fi}%
}

\endinput

MWE,australian在 Polyglossia 中将语言设置为 Biblatex 中的 DMY 格式,并datetime2使用包将其重置\today为应有的样子(对于标题),并csquotes使用包来设置引号。

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@periodical{jtest,journaltitle={The Martian Chronicle},location={Mars},date={2148-03-26},}
@article{atest,author={AI Author},title={Human professor explores Olympus},crossref={jtest},pages={para 9},}
\end{filecontents*}

\documentclass[12pt]{article}

% SETTINGS
%  ===================================
\newcommand\mytitle{A Title}
\newcommand\myauthorname{An Author}
\newcommand\mybibfilename{\jobname.bib}
%  ===================================
\usepackage{fontspec}
\setmainfont{Noto Serif} %arbitrary font
\usepackage{polyglossia}
\setmainlanguage{australian}
\usepackage[british]{datetime2} % for date formatting of \today: put after polyglossia

\usepackage[style=british]{csquotes}
\usepackage[style=oxnotes,    citereset=section, 
ibidtracker=true,    
sortlocale=en_AU,
scnames=true, 
%annotation = true,
indexing=cite,     
mincrossrefs=20,    
backend=biber, 
isbn=false,       
%backref=true,
language=australian,
abbreviate=true,
date=long,
%babel=hyphen
%autolang=true
]{biblatex}

\addbibresource{\mybibfilename}

\title{\mytitle} % provide title info
\author{\myauthorname}          % provide author info
\date{\today}           % provide date

\begin{document}
\maketitle 
Text\cite{atest}.
\printbibliography
\end{document}

结果: 澳大利亚枣

更改语言以english提供引用/bib MDY 格式

\setmainlanguage{english}

英语默认为美式英语

相关内容