使用 biblatex 为不同语言添加前缀书目标签

使用 biblatex 为不同语言添加前缀书目标签

我使用 moderncv 来编写我的简历,我知道最好的解决方案是biblatex,所以我遵循此解决方案使其能够正常地工作moderncv

我的参考书目中有三种不同语言(英语、法语和希腊语)的条目,我想在参考列表中保留条目的语言。我发现此解决方案。我想对我的论文使用不同的 .bib 文件,并以类别为前缀并反向编号(即第一篇论文的编号为 1,但放在底部)。

我成功地将它们全部放在一起,但只漏掉了一件事:文档的主要语言是希腊语,但我需要前缀为拉丁字符,即 D 而不是 Δ。我尝试使用 和\latintext\foreignlanguage{english}{...}但显然我不能使用以 a 开头的任何内容\作为 的值prefixnumbers

梅威瑟:

 
\documentclass[11pt,a4paper,sans]{moderncv}

\usepackage[francais,english,greek]{babel}

\usepackage[LGR,OT1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{csquotes}

\usepackage{filecontents}
\begin{filecontents}{theses.bib}
@article{gp01,
    author  = {Georgiou, George and Poulios, John},
    title   = {A very interesting {P}aper},
    year    = {2001},
    journal = {Science},
    volume  = {12},
    number  = {9},
    pages   = {390--451},
    hyphenation = {english}
}
@book{pg13,
    author    = {Poulios, John and Georgiou, George},
    title     = {Une livre très importante},
    year      = {2013},
    publisher = {Springer},
    address   = {Paris},
    hyphenation = {francais}
}
\end{filecontents}

\begin{filecontents}{journals.bib}
@CONFERENCE{CP15,
    author      = {Makridis, Andreas and Poulios, John},
    title       = {Assembly 2015 (Poster)},
    booktitle   = {Astronomical Conference},
    address     = {Athens, Greece},
    date        = {28 June -- 7 July,},
    year        = {2015},
    pages       = {54},
    hyphenation = {english}
}
@ARTICLE{CAgr,
    author      = {Πούλιος, Ιωάννης and Μακρίδης, Ανδρέας},
    title       = {Ελληνικό συνέδριο},
    journal     = {Χρονικά},
    year        = {2014},
    volume      = {54},
    pages       = {043018},
    hyphenation = {greek}
}
\end{filecontents}

\usepackage[sorting=ydnt,%      Sort by year (descending), name, title
            style=numeric,%
            firstinits=true,%   Initials on first names
            defernumbers=true,% Required to use 'prefixnumbers' option in \printbibliography
            maxnames=99,%       Show all authors            
            autolang=other%
           ]{biblatex}

% Reverse numbering
% SRC: https://tex.stackexchange.com/a/37850/51724
\AtDataInput{%
  \csnumgdef{entrycount:\strfield{prefixnumber}}{%
    \csuse{entrycount:\strfield{prefixnumber}}+1}}
\DeclareFieldFormat{labelnumber}{\mkbibdesc{#1}}    
\newrobustcmd*{\mkbibdesc}[1]{%
  \number\numexpr\csuse{entrycount:\strfield{prefixnumber}}+1-#1\relax}

% biblatex for moderncv
% SRC: https://tex.stackexchange.com/a/123809/51724
\defbibenvironment{bibliography}
  {\list
     {\printtext[labelnumberwidth]{% label format from numeric.bbx
        \printfield{prefixnumber}%
        \printfield{labelnumber}}}
     {\setlength{\topsep}{0pt}% layout parameters from moderncvstyleclassic.sty
      \setlength{\labelwidth}{\hintscolumnwidth}%
      \setlength{\labelsep}{\separatorcolumnwidth}%
      \leftmargin\labelwidth%
      \advance\leftmargin\labelsep}%
      \sloppy\clubpenalty4000\widowpenalty4000}
  {\endlist}
  {\item}

% Make one author bold
% SRC: https://tex.stackexchange.com/a/211821/51724
\newcommand{\makeauthorbold}[1]{%
\DeclareNameFormat{author}{%
  \ifnumequal{\value{listcount}}{1}
    {\ifnumequal{\value{liststop}}{1}
      {\expandafter\ifstrequal{##1}{#1}{\textbf{##1\addcomma\addspace ##4\addcomma\isdot}}{##1\addcomma\addspace ##4\addcomma\isdot}}
      {\expandafter\ifstrequal{##1}{#1}{\textbf{##1\addcomma\addspace ##4}}{##1\addcomma\addspace ##4}}}
    {\ifnumless{\value{listcount}}{\value{liststop}}
      {\expandafter\ifstrequal{##1}{#1}{\textbf{\addcomma\addspace ##1\addcomma\addspace ##4}}{\addcomma\addspace ##1\addcomma\addspace ##4}}
      {\expandafter\ifstrequal{##1}{#1}{\textbf{\addcomma\addspace ##1\addcomma\addspace ##4\addcomma\isdot}}{\addcomma\addspace ##1\addcomma\addspace ##4\addcomma\isdot}}%
    }%
}%
}

\addbibresource[label=T]{theses.bib}
\addbibresource[label=J]{journals.bib}

% moderncv themes
\moderncvstyle{casual}
\moderncvcolor{blue}
\firstname{Εγώ}
\familyname{Επώνυμο}
\title{Βιογραφικό Σημείωμα}
\address{Εδώ}
\email{[email protected]}

\usepackage{xpatch}
\xapptocmd\emailsymbol{\latintext}{}{}  % email address written in latin characters
%----------------------------------------------------------------------------------
%            content
%----------------------------------------------------------------------------------
\begin{document}
\makecvtitle

\makeauthorbold{Poulios}
\begin{refsection}[J]
\nocite{*}
\printbibliography[heading=subbibliography, title={Δημοσιεύσεις},prefixnumbers={J}]
\end{refsection}
\begin{refsection}[T]
\nocite{*}
\printbibliography[heading=subbibliography, title={Διατριβές},prefixnumbers={D}]
\end{refsection}

\end{document}

 

答案1

你写了:

... 我尝试使用\latintext\foreignlanguage{english}{...},但显然我不能使用以 a 开头的任何内容\作为 的值 prefixnumbers

诀窍在于用以下内容括\printfield{prefixnumber}起来\foreignlanguage

\foreignlanguage{english}{\printfield{prefixnumber}}

完整代码(我改为francaisfrench消除错误消息;我不会说法语,所以我的系统没有配置,但french没问题。我添加\jobname到 bib 文件并将 bib 文件移动到 MWE 的开头):

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname-theses.bib}
@article{gp01,
    author  = {Georgiou, George and Poulios, John},
    title   = {A very interesting {P}aper},
    year    = {2001},
    journal = {Science},
    volume  = {12},
    number  = {9},
    pages   = {390--451},
    language    = {english},
    hyphenation = {english},
}
@book{pg13,
    author    = {Poulios, John and Georgiou, George},
    title     = {Une livre très importante},
    year      = {2013},
    publisher = {Springer},
    address   = {Paris},
    language    = {french},
    hyphenation = {french},
}
\end{filecontents*}

\begin{filecontents*}{\jobname-journals.bib}
@CONFERENCE{CP15,
    author      = {Makridis, Andreas and Poulios, John},
    title       = {Assembly 2015 (Poster)},
    booktitle   = {Astronomical Conference},
    address     = {Athens, Greece},
    date        = {28 June -- 7 July,},
    year        = {2015},
    pages       = {54},
    language    = {english},
    hyphenation = {english},
}
@ARTICLE{CAgr,
    author      = {Πούλιος, Ιωάννης and Μακρίδης, Ανδρέας},
    title       = {Ελληνικό συνέδριο},
    journal     = {Χρονικά},
    year        = {2014},
    volume      = {54},
    pages       = {043018},
    language    = {greek},
    hyphenation = {greek},
}
\end{filecontents*}


\documentclass[11pt,a4paper,sans]{moderncv}

\usepackage[%
% francais,
  french,
  english,
  greek
]{babel}

\usepackage[LGR,OT1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{csquotes}

\usepackage[%
  backend=biber,%     use biber to create bibliography ...
  sorting=ydnt,%      Sort by year (descending), name, title
  style=numeric,%
  firstinits=true,%   Initials on first names
  defernumbers=true,% Required to use 'prefixnumbers' option in \printbibliography
  maxnames=99,%       Show all authors            
  autolang=other%
]{biblatex}

% Reverse numbering
% SRC: http://tex.stackexchange.com/a/37850/51724
\AtDataInput{%
  \csnumgdef{entrycount:\strfield{prefixnumber}}{%
    \csuse{entrycount:\strfield{prefixnumber}}+1}}
\DeclareFieldFormat{labelnumber}{\mkbibdesc{#1}}    
\newrobustcmd*{\mkbibdesc}[1]{%
  \number\numexpr\csuse{entrycount:\strfield{prefixnumber}}+1-#1\relax}

% biblatex for moderncv
% SRC: http://tex.stackexchange.com/a/123809/51724
\defbibenvironment{bibliography}
  {\list
     {\printtext[labelnumberwidth]{% label format from numeric.bbx
        \foreignlanguage{english}{\printfield{prefixnumber}}% <========================
        \printfield{labelnumber}}}
     {\setlength{\topsep}{0pt}% layout parameters from moderncvstyleclassic.sty
      \setlength{\labelwidth}{\hintscolumnwidth}%
      \setlength{\labelsep}{\separatorcolumnwidth}%
      \leftmargin\labelwidth%
      \advance\leftmargin\labelsep}%
      \sloppy\clubpenalty4000\widowpenalty4000}
  {\endlist}
  {\item}

% Make one author bold
% SRC: http://tex.stackexchange.com/a/211821/51724
\newcommand{\makeauthorbold}[1]{%
\DeclareNameFormat{author}{%
  \ifnumequal{\value{listcount}}{1}
    {\ifnumequal{\value{liststop}}{1}
      {\expandafter\ifstrequal{##1}{#1}{\textbf{##1\addcomma\addspace ##4\addcomma\isdot}}{##1\addcomma\addspace ##4\addcomma\isdot}}
      {\expandafter\ifstrequal{##1}{#1}{\textbf{##1\addcomma\addspace ##4}}{##1\addcomma\addspace ##4}}}
    {\ifnumless{\value{listcount}}{\value{liststop}}
      {\expandafter\ifstrequal{##1}{#1}{\textbf{\addcomma\addspace ##1\addcomma\addspace ##4}}{\addcomma\addspace ##1\addcomma\addspace ##4}}
      {\expandafter\ifstrequal{##1}{#1}{\textbf{\addcomma\addspace ##1\addcomma\addspace ##4\addcomma\isdot}}{\addcomma\addspace ##1\addcomma\addspace ##4\addcomma\isdot}}%
    }%
}%
}

\addbibresource[label=T]{\jobname-theses.bib}
\addbibresource[label=J]{\jobname-journals.bib}

% moderncv themes
\moderncvstyle{casual}
\moderncvcolor{blue}
\firstname{Εγώ}
\familyname{Επώνυμο}
\title{Βιογραφικό Σημείωμα}
\address{Εδώ}
\email{[email protected]}

\usepackage{xpatch}
\xapptocmd\emailsymbol{\latintext}{}{}  % email address written in latin characters
%----------------------------------------------------------------------------------
%            content
%----------------------------------------------------------------------------------
\begin{document}
\makecvtitle

\makeauthorbold{Poulios}
\begin{refsection}[J]
\nocite{*}
\printbibliography[heading=subbibliography, title={Δημοσιεύσεις},prefixnumbers={J}]
\end{refsection}
\begin{refsection}[T]
\nocite{*}
\printbibliography[heading=subbibliography, title={Διατριβές},prefixnumbers={D}]
\end{refsection}

\end{document}

结果如下:

在此处输入图片描述

顺便说一句:\latintext已经贬值了......

相关内容