I’m working on my thesis which is (of course) written in (Xe)LaTeX and which extensively uses the natbib package and bibtex for citations, including features such as \citeauthor{reference}. Since my thesis will be in German, I ran into a problem as described in this question (replace BibTeX’s standard and output with a native word) and independently arrived at a solution along the lines of this question’s answer — copy the .bst file, search and replace the function that outputs and.
I thought I could take this a step further. Rather than adding a plain text German und into the function, I thought about putting a macro there: \undbefehl (German for and command). First tests were successful, the macro expanded properly as I defined it in the preamble of my document. The initial definition was \newcommand\undbefehl{und\ }.
Now my thesis’ abstract is supposed to be written in English, for which I intend to use polyglossia and its language selection features. I came across this question, which suggests the code \iflanguage{english}{and\ }{und\ }. Unfortunately, the results are not what I anticipated. Compare the following MWE:
\documentclass[12pt,a4paper,twoside]{scrreprt}
\usepackage{xunicode}
\usepackage{polyglossia} % for languages
\setmainlanguage[babelshorthands=true,spelling=new]{german} % sets the main language
\setotherlanguage[variant=british]{english} % sets the other language
\usepackage[square, super, sort&compress, comma, numbers]{natbib} % for citations
\setmainfont[Mapping=tex-text]{LiberationSerif} % set a font
\newcommand\undbefehl{\iflanguage{english}{and\ }{und\ }} % create the \undbefehl command
\begin{document}
The first paper was written by \citeauthor{MyersAlkylierung}.\\
The second paper was written by \citeauthor{Gieseler_PBu3}.\\
\undbefehl.
\begin{english}
The first paper was written by \citeauthor{MyersAlkylierung}.\\
The second paper was written by \citeauthor{Gieseler_PBu3}.\\
\undbefehl.
\end{english} % commented out in the second MWE
\bibliographystyle{myangew2} % derived from angew.bst as supplied by the rsc package.
\bibliography{literatur} % includes my literatur.bib
\end{english} % commented out in the first MWE
\end{document}
The first MWE compiles to give this output:
The second one gave this output:
Clearly, \undbefehl gets interpreted at the level of \bibliography{literatur}. I assume that the \citeauthor macro grabs the expanded text to enter into the document itself.
Is there any way in which I can modify the macro, either by adding stuff to the .bst file or by modifying the definition accordingly, so that it can evaluate the language environment is in and expand to and or und depending on the language?
The two relevant entries of the literatur.bib file (the actual file paths are redacted due to privacy):
@article{MyersAlkylierung,
author = {Myers, Andrew G and Yang, Bryant H and Chen, Hou and McKinstry, Lydia and Kopecky, David J and Gleason, James L},
doi = {10.1021/ja970402f},
file = {(redacted)},
issn = {0002-7863},
journal = {J. Am. Chem. Soc.},
month = {jul},
number = {28},
pages = {6496--6511},
title = {{Pseudoephedrine as a Practical Chiral Auxiliary for the Synthesis of Highly Enantiomerically Enriched Carboxylic Acids, Alcohols, Aldehydes, and Ketones}},
url = {http://pubs.acs.org/doi/abs/10.1021/ja970402f},
volume = {119},
year = {1997}
}
@article{Gieseler_PBu3,
abstract = {The first total synthesis of angiolam A has been accomplished in 18 steps. Key steps include vinylogous Mukaiyama aldol reactions of aldehyde-derived dienol ethers, conjugate reduction of the resulting double bond followed by diastereoselective protonation and the Witzeman protocol for macrolactamization. Comparison of the optical rotation of the synthesized material with the isolation data established that the absolute configuration of angiolam A is opposite from the proposed structure.},
author = {Gieseler, Marc Timo and Kalesse, Markus},
doi = {10.1021/ol403423r},
file = {(redacted)},
issn = {1523-7060},
journal = {Org. Lett.},
month = {jan},
number = {2},
pages = {548--551},
pmid = {24341445},
title = {{Synthesis of Angiolam A}},
url = {http://pubs.acs.org/doi/abs/10.1021/ol403423r},
volume = {16},
year = {2014}
}
The file myangew2.bst is a copy of angew.bst as supplied by the rsc package. I modified exactly one line:
FUNCTION {bbl.and}
{ "and" }
became
FUNCTION {bbl.and}
{ "\undbefehl" }



.bibentries, too. – jon Jun 26 '16 at 20:53myangew2.bstdoes; please, also supply a bib entry. – egreg Jun 26 '16 at 20:53.bib-file usingfilecontentsSee example here: Problems with bibliography filecontents – Runar Jun 26 '16 at 21:01myangew2.bstI also supplied the two bib entries that are grabbed in the MWE. – Jan Jun 26 '16 at 21:11