主要文本和參考書目採用兩種語言,但具有備用日期格式

主要文本和參考書目採用兩種語言,但具有備用日期格式

我正在用美式英語和德語(新正字法)編寫文本,因此我使用\usepackage[ngerman,USenglish]{babel}. biblatex 參考書目也包含英語和德語參考文獻。我需要參考書目中每種語言的連字符規則,因此我使用\usepackage[backend=biber,language=autobib,autolang=hyphen]{biblatex}然後指定各個參考書目條目的語言,如下所示:langid = {ngerman}

不過,我希望所有日期都採用澳洲格式(dd Mon. YYYY)。我怎麼才能得到這個日期格式(特別是在參考書目中)?

(如果我不需要參考書目中的德語連字符規則,我只需刪除autolangandlangid並使用\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}}}}%
}

我使用 alias 編寫了程式碼,但如果您願意,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)。

Polyglossia 透過選項處理,將澳洲語理解為英語的變體,

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

但這並沒有改變任何事情。該變體不會進入 Biblatex,不幸的是,gloss-english.ldf語言定義檔設定\english@ordinalmonthday為 false(並且也是\if@british@localefalse,因此\today重新定義為美國格式)。

無論如何,Biblatex 將其english視為多語種語言,因此引文和參考文獻中的日期以美國格式排版(這是 的預設格式english)。

Biblatex 本身無需多語言即可理解澳洲日期。

因此:由於語言的排版最終是一組使用者選項或設計選擇,例如「樣式」或「主題」(連字符模式、月份和文件部分的名稱、引號和標點符號、頁面幾何),並且既然Biblatex 文件認為澳洲語是一種語言(「為Polyglossia 所熟知」),為什麼不將其設為一種語言呢?

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,australianPolyglossia 中的語言設定為 Biblatex 中的 DMY 格式,帶有用於重置回其應有狀態(對於標題)的datetime2包,以及用於引號的包。\todaycsquotes

\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提供 cite/bib MDY 格式

\setmainlanguage{english}

英語預設為美式

相關內容