0

I use biblatex to build:

As discussed in the comments of this last answer, the solutions work very independently, but I get the following error when trying to mix both:

! Undefined control sequence.
\blx@nameparser@i ...pandafter {\mblx@currentname
}{\mblx@exemptfields } {\b...
l.142 \footcite{compagnon}

I tried to "exempt" the author field from the patch, without success. Is this achievable or would the patch become unreasonable?

Here's a test code, commenting the long patch allows to build the index:

\documentclass{article}
\usepackage[english,french]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{makeidx}

\usepackage[backend=biber,
    style=verbose-trad2,
    singletitle=true,
    indexing=cite,
]{biblatex}

\makeindex
\renewbibmacro*{citeindex}{
  \ifciteindex
    {\indexnames{labelname}}
    {}}

\makeatletter
\newcommand*{\mblx@exemptfields}{}
\newrobustcmd*{\ExemptFromLanguageSwitching}{%
  \forcsvlist{\listgadd\mblx@exemptfields}}

\def\blx@thefakelangenv{otherlanguage}%

\def\blx@beglang@fake{%
  \blx@clearlang
  \begingroup
  \ifdef\abx@field@langid
    {\def\blx@endlang@fake{%
       \end{otherlanguage*}%
       \endgroup}%
     \begin{otherlanguage*}{\abx@field@langid}}
    {}}

\let\blx@endlang@fake\relax

\renewrobustcmd*{\blx@imc@printfield}[2][]{%
  \blx@imc@iffieldundef{#2}
    {\blx@nounit}
    {\blx@getformat\blx@theformat{ffd}{#1}{#2}%
     \ifdefvoid\blx@theformat
       {\blx@nounit}
       {\blx@begunit
        \ifinlist{#2}{\mblx@exemptfields}
          {}
          {\let\blx@theformat@outer\blx@theformat
           \def\blx@theformat##1{\blx@theformat@outer{\blx@beglang@fake ##1\blx@endlang@fake}}}%
        \edef\currentfield{#2}%
        \expandafter\expandafter
        \expandafter\blx@theformat
        \expandafter\expandafter
        \expandafter{\csname abx@field@#2\endcsname}%
        \blx@endunit}}}

\catcode`\&=3
\def\blx@printnames#1#2#3#4{%
  \blx@imc@ifnameundef{#4}
    {\blx@nounit}
    {\def\mblx@currentname{#4}%
     \blx@getformat\blx@thewrapperformat{nwd}{#1}{#4}%
     \ifdefvoid\blx@thewrapperformat
       {\blx@nounit}
       {\blx@getformat\blx@theformat{nfd}{#1}{#4}%
        \ifdefvoid\blx@theformat
          {\blx@nounit}
          {\blx@begunit
           \blx@namesetup{#2}{#3}{#4}%
           \blx@thewrapperformat{\expandafter\blx@nameparser\blx@thedata{}&}%
           \blx@endunit}}}}

\long\def\blx@nameparser@i#1#2{%
  \begingroup
  \ifblank{#1}
    {}
    {\setkeys{blx@opt@name}{#1}}%
  \setkeys{blx@opt@namepart}{#2}%
  \expandafter\ifinlist\expandafter{\mblx@currentname}{\mblx@exemptfields}
    {\blx@theformat{#2}}
    {\blx@beglang@fake\blx@theformat{#2}\blx@endlang@fake}%
  \endgroup}

\def\blx@printlist#1#2#3#4{%
  \blx@imc@iflistundef{#4}
    {\blx@nounit}
    {\def\mblx@currentlist{#4}%
     \blx@getformat\blx@thewrapperformat{lwd}{#1}{#4}%
     \ifdefvoid\blx@thewrapperformat
       {\blx@nounit}
       {\blx@getformat\blx@theformat{lfd}{#1}{#4}%
        \ifdefvoid\blx@theformat
          {\blx@nounit}
          {\blx@begunit
           \blx@listsetup{#2}{#3}{#4}%
           \blx@thewrapperformat{\expandafter\blx@listparser\blx@thedata{}&}%
           \blx@endunit}}}}

\long\def\blx@listparser#1{%
  \ifblank{#1}
    {\blx@listbreak}
    {\ifnum\c@listcount<\c@liststart
     \else
       \expandafter\ifinlist\expandafter{\mblx@currentlist}{\mblx@exemptfields}
         {\blx@theformat{#1}}
         {\blx@beglang@fake\blx@theformat{#1}\blx@endlang@fake}%
     \fi
     \advance\c@listcount\@ne
     \ifnum\c@listcount>\c@liststop
       \expandafter\blx@listbreak
     \fi
     \blx@listparser}}
\makeatother
\catcode`\&=4

\ExemptFromLanguageSwitching{url,doi,eprint,pages}


\begin{filecontents}[force]{\jobname.bib}
@book{compagnon,
  author     = {Compagnon, Antoine and Someone Else},
  translator = {Même, Moi},
  date       = {1998},
  title      = {Titre: aléatoire?},
  pages      = {306-723},
  langid     = {french},
  url        = {https://example.com/~stuff/more.pdf},
}
@book{glashow,
  author       = {Glashow, Sheldon and Someone Else},
  title        = {Random: title?},
  translator   = {Self, My},
  date         = {1961},
  pages        = {579-588},
  langid       = {english},
  url          = {https://example.com/~stuff/more.pdf},
}
\end{filecontents} 
\addbibresource{\jobname.bib}

\begin{document}
\footcite{compagnon}
\footcite{glashow}
\printindex
\printbibliography
\end{document}

1 Answer 1

1

The code in Punctuations rules in multilingual bilbiography should have probably not only patched \printnames and \printlist, but also \indexnames and \indexlist. (This is now fixed there as well.)

The following code should compile.

\documentclass{article}
\usepackage[english,french]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{makeidx}

\usepackage[backend=biber,
    style=verbose-trad2,
    singletitle=true,
    indexing=cite,
]{biblatex}

\makeindex
\renewbibmacro*{citeindex}{
  \ifciteindex
    {\indexnames{labelname}}
    {}}

\makeatletter
\newcommand*{\mblx@exemptfields}{}
\newrobustcmd*{\ExemptFromLanguageSwitching}{%
  \forcsvlist{\listgadd\mblx@exemptfields}}

\def\blx@thefakelangenv{otherlanguage}%

\def\blx@beglang@fake{%
  \blx@clearlang
  \begingroup
  \ifdef\abx@field@langid
    {\def\blx@endlang@fake{%
       \end{otherlanguage*}%
       \endgroup}%
     \begin{otherlanguage*}{\abx@field@langid}}
    {}}

\let\blx@endlang@fake\relax

\renewrobustcmd*{\blx@imc@printfield}[2][]{%
  \blx@imc@iffieldundef{#2}
    {\blx@nounit}
    {\blx@getformat\blx@theformat{ffd}{#1}{#2}%
     \ifdefvoid\blx@theformat
       {\blx@nounit}
       {\blx@begunit
        \ifinlist{#2}{\mblx@exemptfields}
          {}
          {\let\blx@theformat@outer\blx@theformat
           \def\blx@theformat##1{\blx@theformat@outer{\blx@beglang@fake ##1\blx@endlang@fake}}}%
        \edef\currentfield{#2}%
        \expandafter\expandafter
        \expandafter\blx@theformat
        \expandafter\expandafter
        \expandafter{\csname abx@field@#2\endcsname}%
        \blx@endunit}}}


\catcode`\&=3
\def\blx@printnames#1#2#3#4{%
  \blx@imc@ifnameundef{#4}
    {\blx@nounit}
    {\def\mblx@currentname{#4}%
     \blx@getformat\blx@thewrapperformat{nwd}{#1}{#4}%
     \ifdefvoid\blx@thewrapperformat
       {\blx@nounit}
       {\blx@getformat\blx@theformat{nfd}{#1}{#4}%
        \ifdefvoid\blx@theformat
          {\blx@nounit}
          {\blx@begunit
           \blx@namesetup{#2}{#3}{#4}%
           \blx@thewrapperformat{\expandafter\blx@nameparser\blx@thedata{}&}%
           \blx@endunit}}}}

\def\blx@indexnames#1#2#3#4{%
  \blx@imc@ifnameundef{#4}
    {}
    {\def\mblx@currentname{#4}%
     \blx@getformat\blx@theformat{nid}{#1}{#4}%
     \ifdefvoid\blx@theformat
       {}
       {\begingroup
        \blx@namesetup{#2}{#3}{#4}%
        \blx@indexnamesetup
        \expandafter\blx@nameparser\blx@thedata{}&%
        \endgroup}}}

\long\def\blx@nameparser@i#1#2{%
  \begingroup
  \ifblank{#1}
    {}
    {\setkeys{blx@opt@name}{#1}}%
  \setkeys{blx@opt@namepart}{#2}%
  \expandafter\ifinlist\expandafter{\mblx@currentname}{\mblx@exemptfields}
    {\blx@theformat{#2}}
    {\blx@beglang@fake\blx@theformat{#2}\blx@endlang@fake}%
  \endgroup}


\def\blx@printlist#1#2#3#4{%
  \blx@imc@iflistundef{#4}
    {\blx@nounit}
    {\def\mblx@currentlist{#4}%
     \blx@getformat\blx@thewrapperformat{lwd}{#1}{#4}%
     \ifdefvoid\blx@thewrapperformat
       {\blx@nounit}
       {\blx@getformat\blx@theformat{lfd}{#1}{#4}%
        \ifdefvoid\blx@theformat
          {\blx@nounit}
          {\blx@begunit
           \blx@listsetup{#2}{#3}{#4}%
           \blx@thewrapperformat{\expandafter\blx@listparser\blx@thedata{}&}%
           \blx@endunit}}}}

\def\blx@indexlist#1#2#3#4{%
  \blx@imc@iflistundef{#4}
    {}
    {\def\mblx@currentlist{#4}%
     \blx@getformat\blx@theformat{lid}{#1}{#4}%
     \ifdefvoid\blx@theformat
       {}
       {\begingroup
        \blx@listsetup{#2}{#3}{#4}%
        \expandafter\blx@listparser\blx@thedata{}&%
        \endgroup}}}

\long\def\blx@listparser#1{%
  \ifblank{#1}
    {\blx@listbreak}
    {\ifnum\c@listcount<\c@liststart
     \else
       \expandafter\ifinlist\expandafter{\mblx@currentlist}{\mblx@exemptfields}
         {\blx@theformat{#1}}
         {\blx@beglang@fake\blx@theformat{#1}\blx@endlang@fake}%
     \fi
     \advance\c@listcount\@ne
     \ifnum\c@listcount>\c@liststop
       \expandafter\blx@listbreak
     \fi
     \blx@listparser}}
\makeatother
\catcode`\&=4

\ExemptFromLanguageSwitching{url,doi,eprint,pages}


\begin{filecontents}{\jobname.bib}
@book{compagnon,
  author     = {Compagnon, Antoine and Someone Else},
  translator = {Même, Moi},
  date       = {1998},
  title      = {Titre: aléatoire?},
  pages      = {306-723},
  langid     = {french},
  url        = {https://example.com/~stuff/more.pdf},
}
@book{glashow,
  author       = {Glashow, Sheldon and Someone Else},
  title        = {Random: title?},
  translator   = {Self, My},
  date         = {1961},
  pages        = {579-588},
  langid       = {english},
  url          = {https://example.com/~stuff/more.pdf},
}
\end{filecontents} 
\addbibresource{\jobname.bib}

\begin{document}
\footcite{compagnon}
\footcite{glashow}
\printindex
\printbibliography
\end{document}
4
  • As always, you post answers faster than I can post questions! I'm checking for side effects. Thanks again.
    – letax
    Mar 9, 2022 at 17:00
  • An unwanted side effect was finally spotted: the "p." for the page range appears when needed in the bibliography, but never in the footnote where the reference is called. This can be seen in the example calling eg. \footcite[36]{compagnon}
    – letax
    Mar 15, 2022 at 17:45
  • 1
    @letax You need to also exempt the postnote field from the language switching.
    – moewe
    Mar 15, 2022 at 19:29
  • Great! Many thanks again.
    – letax
    Mar 15, 2022 at 19:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .