我想自动添加一本(古)书的译者信息,如果没有译者,就由我来翻译。
我如何检查是否
bibtex-entry
已定义翻译器?
我的方法失败了:
\documentclass{scrbook}
\usepackage{filecontents,etoolbox}
\begin{filecontents}{\jobname.bib}
@Book{Varro_ling,
author = {Terentius Varro, Marcus},
editor = {William Heinemann},
title = {On the Latin Language},
location = {Cambridge and London},
year = {1993},
volume = {I--II},
series = {Loeb Classical Library},
number = {333--334},
edition = {3},
origtitle = {de lingua latina},
translator = {Kent, Roland G.},
shorthand = {Varro ling.},
shortauthor = {Varro},
keywords = {ancient},
options = {ancient},
origdate = {1938},
}
@Book{Varro_rust,
author = {Terentius Varro, Marcus},
origtitle = {de re rustica},
shorthand = {Varro rust.},
shortauthor = {Varro},
keywords = {ancient},
options = {ancient},
}
\end{filecontents}
\usepackage[
backend=biber,
style=archaeologie,
]{biblatex}
\addbibresource{\jobname.bib}
\makeatletter
\newcommand\mytrans[1]{Transl.
\def\thetranslator{\citetranslator{#1}}
\ifundef{\thetranslator}{by me}{\citetranslator{#1}}}
\makeatother
\begin{document}
Transl. (Varro ling): \citetranslator{Varro_ling}\par
Transl. (Varro rust): \citetranslator{Varro_rust}\par
\mytrans{Varro_ling}\par
\mytrans{Varro_rust}
\end{document}
答案1
您可以使用\ifnameundef
from 'within' biblatex
(仅在 abibmacro
或中\DeclareCiteCommand
)。
\DeclareCiteCommand{\mytrans}
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\ifnameundef{translator}
{\printtext{me}}
{\printnames{translator}}}
{\multicitedelim}
{\usebibmacro{postnote}}