Biblatex の参考文献の 2 文字または 3 文字の頭文字

Biblatex の参考文献の 2 文字または 3 文字の頭文字

私の参考文献では、二重音字と三重音字を維持しながら、名前を省略する必要があります。

  • John は J と略記する必要があります。
  • Clare は Cl と略記します。
  • Charles は Ch と略記します。
  • Christine は Chr と略記します。
  • Philippe は Ph と略記します。

解決策は、書誌データの最初の名前を

チャールズ

{\relax チャールズ


次の例では、\DeclareSourcemapBiblatex のカスタマイズ マクロを使用して変更していますCharles{\relax Ch}arles、2 つまたは 3 つの子音で始まるすべての名前を自動的に変更する、より一般的なソリューションを探しています。

\documentclass{article}
\usepackage{filecontents}
 \begin{filecontents}{\jobname.bib}
  @book{Book1,
  author = {Doe, Charles},
  title  = {An Important Book},
  publisher = {Publisher},
  date = {2012},
}
@book{Book2,
  author = {Doe, Charlotte},
  title  = {Another Important Book},
  publisher = {Publisher},
  date = {2014},
}
@book{Book3,
  author = {Smith, Theodore},
  title  = {A very Important Book},
  publisher = {Publisher},
  date = {2016},
}
\end{filecontents}
\usepackage[style=verbose,firstinits=true, backend=biber]{biblatex}
\DeclareSourcemap{
 \maps[datatype=bibtex]{
    \map{
    \step[fieldsource=author, 
            match={Charles},
            replace=\regexp{\{\\relax \x20Ch\}arles}]
  }
 }
}
\addbibresource{\jobname.bib}
\begin{document}

\cite{Book1}

\cite{Book2}

\cite{Book3}

\end{document}

結果

答え1

出発点としては、イヴ・ド・サン=ペルンが授業で書いたコードを使うことが考えられる。フランス語以下に翻訳します。

編集 :ここで提供される正規表現は姓も捉えるため、Biblatex以外、例えば で作成された索引では問題を引き起こす可能性がありますimakeidx。この問題の暫定的な解決策はここに提供

これをファイル内で使用しbiber.confたり、 に組み込んだりすることができます.bbx

言語によっては、ファーストネームに追加の正規表現パターンが必要な場合がありますが、追加するのは非常に簡単です。

\DeclareStyleSourcemap{%
  \maps[datatype=bibtex]{%
    \map{%
        % Author field
      \step[fieldsource=author,%
        match={\regexp{\b(Chr|Ch|Th|Ph|[B-DF-HJ-NP-TV-XZ](l|r))(\S*,)}},%
        replace={\regexp{\{$1\}$3}}]% Protect last names (first last)
      \step[fieldsource=author,%
        match={\regexp{([^,]\s)\b(Chr|Ch|Th|Ph|[B-DF-HJ-NP-TV-XZ](l|r))}},%
        replace={\regexp{$1\{$2\}}}]% Protect last names (last, first)
      \step[fieldsource=author,%
        match={\regexp{\b(Chr|Ch|Th|Ph|[B-DF-HJ-NP-TV-XZ](l|r))([^\}])}},%
        replace={\regexp{\{\\relax\{\}$1\}$3}}]% Insert \relax after abbreviating
      % Editor field
      \step[fieldsource=editor,%
        match={\regexp{\b(Chr|Ch|Th|Ph|[B-DF-HJ-NP-TV-XZ](l|r))(\S*,)}},%
        replace={\regexp{\{$1\}$3}}]% Protect last names (first last)
      \step[fieldsource=editor,%
        match={\regexp{([^,]\s)\b(Chr|Ch|Th|Ph|[B-DF-HJ-NP-TV-XZ](l|r))}},%
        replace={\regexp{$1\{$2\}}}]% Protect last names (last, first)
      \step[fieldsource=editor,%
        match={\regexp{\b(Chr|Ch|Th|Ph|[B-DF-HJ-NP-TV-XZ](l|r))([^\}])}},%
        replace={\regexp{\{\\relax\{\}$1\}$3}}]% Insert \relax after abbreviating
}}}%

正規表現に関しては、私は専門家ではありませんが、この表現は次のような意味であると思われます。

\b(Chr|Ch|Th|Ph|[B-DF-HJ-NP-TV-XZ](l|r))(\S*,)

\b( ) で始まる単語 ( ) は\S*、任意の数のスペース以外の文字で終わることを意味しますChr(Chris) またはCh(Charles) またはTh(Thomas) またはPh(Philippe)、あるいは子音で始まり ([B-DF-HJ-NP-TV-XZ部分は B ~ D、F ~ H、J ~ N、P ~ T、V ~ X、Z の文字の範囲のセット)、その後にlまたは が続く任意の組み合わせr(Bruno または Claire がこのカテゴリに該当します)。

関連情報