BibLaTeX의 사용자 정의 필드

BibLaTeX의 사용자 정의 필드

내 .bib 항목에 선택적 사용자 정의 필드를 허용하고 싶습니다. 참고문헌의 일부가 되기 위해 이 필드가 필요하지는 않지만 다음을 통해 이러한 필드에 액세스할 수 있기를 원합니다.

\citefield{<entry-key>}{<custom-field-name>}

대답은 아마도 아래 나열된 참고 자료 어딘가에 있을 것입니다. 그러나 적응하려는 초기 시도 \DeclareSourcemap\DeclareFieldFormat실패했습니다.

참고자료:

암호:

\begin{filecontents}{mybib.bib}
@book{knuth1984texbook,
  title={The texbook},
  author={Knuth, D.E. and Knuth, A.D. and Bibby, D. and American Mathematical Society and Addison-Wesley Publishing Company and Addison-Wesley},
  isbn={9780201134483},
  lccn={85030845},
  series={Computers \& typesetting},
  url={https://books.google.com/books?id=hEYuAQAAIAAJ},
  year={1984},
  publisher={Addison-Wesley},
  myFieldA={Useful Book},
  myFieldB={on Shelf 4},
}
@book{goossens1994latex,
  title={The LaTeX Companion},
  author={Goossens, M. and Mittelbach, F. and Samarin, A.},
  isbn={9780201541991},
  lccn={lc93023150},
  series={Addison-Wesley series on tools and techniques for computer typesetting},
  url={https://books.google.com/books?id=54A3MuBzIrEC},
  year={1994},
  publisher={Addison-Wesley},
  myFieldA={Also Useful Book},
  myFieldB={on Shelf 5},
}
\end{filecontents}

%% -----------------

\documentclass{article}
\usepackage{biblatex}
\addbibresource{mybib.bib}

\begin{document}
    This should print ``Also Useful Book'':
    \citefield{goossens1994latex}{myFieldA}
\end{document}

답변1

몇 개의 필드만 필요하고 (인용을 위해) 마크업 의미를 조금만 희생하려는 경우 "사용자 정의 필드"를 사용하여 문제를 해결할 수 있습니다 biblatex(표준 스타일에서는 이를 사용하지 않지만, 비표준 것을 사용하고 있다면 그것이 정말로 "비어 있는지" 확인해야 할 수도 있습니다.)

필드에 대한 사용자 정의 이름을 원한다고 설명에서 언급한 경우 SourceMap을 사용하여 사용자 정의 필드의 값을 biblatex의 데이터 모델에서 사용 가능한 항목 중 하나로 복사하면 이를 달성할 수 있습니다. 즉, .bib파일에 사용자 정의 이름을 가질 수 있지만 실제로 인용할 때는 여전히 biblatex"knows" 필드를 사용해야 합니다.

이는 다음과 같이 진행될 수 있습니다.

\begin{filecontents}[overwrite]{mybib.bib}
@book{knuth1984texbook,
  title={The texbook},
  author={Knuth, D.E. and Knuth, A.D. and Bibby, D. and American Mathematical Society and Addison-Wesley Publishing Company and Addison-Wesley},
  isbn={9780201134483},
  lccn={85030845},
  series={Computers \& typesetting},
  url={https://books.google.com/books?id=hEYuAQAAIAAJ},
  year={1984},
  publisher={Addison-Wesley},
  myFieldA={Useful Book},
  myFieldB={on Shelf 4},
}
@book{goossens1994latex,
  title={The LaTeX Companion},
  author={Goossens, M. and Mittelbach, F. and Samarin, A.},
  isbn={9780201541991},
  lccn={lc93023150},
  series={Addison-Wesley series on tools and techniques for computer typesetting},
  url={https://books.google.com/books?id=54A3MuBzIrEC},
  year={1994},
  publisher={Addison-Wesley},
  myFieldA={Also Useful Book},
  myFieldB={on Shelf 5},
}
\end{filecontents}

%% -----------------

\documentclass{article}
\usepackage{biblatex}
\addbibresource{mybib.bib}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=myFieldA]
      \step[fieldset=usera, origfieldval]
      \step[fieldsource=myFieldB]
      \step[fieldset=userb, origfieldval]
    }
  }
}

\begin{document}
This should print ``Also Useful Book'':
\citefield{goossens1994latex}{usera}

This should print ``on Shelf 5'':
\citefield{goossens1994latex}{userb}
\end{document}

여기에 이미지 설명을 입력하세요

이 접근 방식의 장점은 데이터 모델을 확장할 필요가 없으므로 더 간단하다는 것입니다. 그러나 정말로 양쪽에서 사용자 정의 필드 이름을 사용해야 한다면 제가 아는 한 유일한 방법은 필드를 포함하도록 데이터 모델을 확장하는 것입니다. 이 경우 정식 답변은 @moewe의 답변입니다.BibLaTeX/Biber를 사용하여 완전히 새로운 데이터 유형을 만들려면 어떻게 해야 합니까?.

관련 정보