Biblatex를 사용한 참고문헌의 두 글자 또는 세 글자 이니셜

Biblatex를 사용한 참고문헌의 두 글자 또는 세 글자 이니셜

내 참고문헌에서는 이중문자와 삼중문자를 사용하여 이름을 축약해야 합니다.

  • John은 J로 줄여야 합니다.
  • Clare는 Cl로 축약되어야 합니다.
  • Charles는 Ch로 축약되어야 합니다.
  • Christine은 Chr로 축약되어야 합니다.
  • Philippe은 Ph.로 축약되어야 합니다.
  • 등.

해결책은 서지 데이터의 이름을 다음에서 수정하는 것입니다.

찰스

에게

{\relax Ch}아를스


다음 예에서는 \DeclareSourcemapBiblatex의 사용자 정의 매크로를 사용하여 변경 Charles하지만 {\relax Ch}arles두 개 또는 세 개의 자음으로 시작하는 모든 이름을 자동으로 수정하는 보다 일반적인 솔루션을 찾고 있습니다.

\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

가능한 출발점은 Yves de Saint-Pern이 수업 시간에 작성한 코드를 사용하는 것입니다.droit-fr, 아래에서 번역 중입니다.

편집하다 :여기에 제공된 정규식은 성(姓)도 포착하므로 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가 해당 범주에 속함).

관련 정보