2

I would like to add automatically the information about the translator of a(n ancient) book, if there is no translator, it should be me as translator.

How can I check whether the bibtex-entry has defined a translator or not?

My approach fails:

\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}

enter image description here

  • @moewe you are right, but that would involve more work since I think the users would like to define the me individually. But it is an approach! – LukasCB Aug 10 '17 at 13:24
  • 1
    Have a look at my answer. It is absolutely no problem at all to say \printtext{\me} instead of \printtext{me} and define \me later (or earlier). – moewe Aug 10 '17 at 13:26
3

You can use \ifnameundef from 'within' biblatex (only in a bibmacro or \DeclareCiteCommand).

\DeclareCiteCommand{\mytrans}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifnameundef{translator}
     {\printtext{me}}
     {\printnames{translator}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.