1

It doesn't work out of the box: it's treats first and last name as last name. I guess "expand after" comes into play, but long time since I used this feature.

\documentclass{article}
\usepackage[french]{babel}
\usepackage{expl3}
\usepackage{glossaries}
\usepackage{csquotes}
\usepackage[backend=biber,autolang=other]{biblatex}

\DefineBibliographyStrings{french}{
  in = {dans},
}

\newglossary*{cont}{Contact}

\newglossaryentry{dupont}
{
  type=cont,
  name={Dupont, Michel},
  description={}
}    

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{lefoo
  ,author =       {Dupond, Marie}
  ,title =        "TITRE"
  ,journal =      "LE JOUR"
  ,year =         "AAAA"
  ,language={french}
  ,hyphenation={french}
}
@article{lebar
  ,author =       {\gls{dupont}}
  ,title =        "TITRE"
  ,journal =      "LE JOUR"
  ,year =         "AAAA"
  ,language={french}
  ,hyphenation={french}
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\begin{document}

Une citation: \autocite{lefoo}.

Une citation au milieu du texte: Comme \textcite{lebar} a dit \dots

\printbibliography
\end{document}

Print

1
  • 1
    I don't think this is going to work. By the time biblatex gets access to the author, the bib file has been processed by biber and the author name has been broken apart. You could potentially hack the data model to replace things ...
    – StrongBad
    Sep 19, 2019 at 19:16

1 Answer 1

1

I'm afraid this simply won't work.

Name fields need to be parsed by Biber (or BibTeX) to extract the different name parts (given name, family name, suffix and prefix), since Biber does not know about LaTeX macros in general (it knows about some macros for single non-ASCII characters) there is no way \gls{dupont} would be treated like Dupont, Michel.

In the example \gls{dupont} is treated as the sole family name of the author and the macro is only later expanded to produce the output you see.

There are no amounts of \expandafter s that could help you to pass the expected name to Biber. You could use a source map to replace the macro again, but that appears a bit backwards and you lose all other benefits of \gls.

\documentclass{article}
\usepackage[french]{babel}
\usepackage{expl3}
\usepackage{glossaries}
\usepackage{csquotes}
\usepackage[backend=biber,autolang=other]{biblatex}

\DefineBibliographyStrings{french}{
  in = {dans},
}

\newglossary*{cont}{Contact}

\newglossaryentry{dupont}
{
  type=cont,
  name={Dupont, Michel},
  description={}
}    

\DeclareSourcemap{
  \maps[datatype=bibtex, overwrite]{
    \map{
      \step[fieldsource=author, match=\regexp{\\gls\{dupont\}}, replace={Dupont, Michel}]
    }
  }
}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{lefoo
  ,author =       {Dupond, Marie}
  ,title =        "TITRE"
  ,journal =      "LE JOUR"
  ,year =         "AAAA"
  ,language={french}
  ,hyphenation={french}
}
@article{lebar
  ,author =       {\gls{dupont}}
  ,title =        "TITRE"
  ,journal =      "LE JOUR"
  ,year =         "AAAA"
  ,language={french}
  ,hyphenation={french}
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\begin{document}
Une citation: \autocite{lefoo}.

Une citation au milieu du texte: Comme \textcite{lebar} a dit \dots

\printbibliography
\end{document}

Correctly formatted names.

You probably need a different way to achieve what you want to do with \gls.

4
  • I feel like with some nasty expandafter and regexp trickery you might be able to match all \gls{*} and make the "replace" be essentially \expandafter\gls{*}, but it is so not worth it.
    – StrongBad
    Sep 24, 2019 at 13:39
  • @StrongBad Nice idea. The replacement text is accessible expandably in \glo@<label>@name. But I couldn't get this to work since I would need Biber to match the regexp in \gls{.*} and then pass the captured group back to LaTeX to resolve \glo@$1@name.
    – moewe
    Sep 24, 2019 at 15:58
  • At a minimum you could change replace={Dupont, Michel} to something like replace={\glo@dupont@name} with a whole bunch of expandafter trickery to get \glo@dupont@name to actually be expanded.
    – StrongBad
    Sep 24, 2019 at 16:06
  • 1
    @StrongBad True replace={\csname glo@dupont@name\endcsname} would work, but might explode when you have non-ASCII chars in non Unicode-engines, so finer expansion control is needed.
    – moewe
    Sep 24, 2019 at 16:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .
https://tex.stackexchange.com/questions/508979/invoking-glossaries-to-fill-author-field-of-bib-entries
tex.stackexchange.com
CC-MAIN-2024-18
148160
application/http; msgtype=response
sha1:OTNXNR7LIYZROP2WVWTKM2CU4W3JBR4B
<urn:uuid:8ca37570-d910-4242-97c4-30dfebbc1155>
2024-04-13T01:17:29Z
104.18.43.226
text/html
sha1:HK72ABVPEYHF5JL23NXS2QEZ6XA42V5W
<urn:uuid:376f02b7-2e3f-48cc-bde3-caadeb37900d>
https://tex.stackexchange.com/questions/508979/invoking-glossaries-to-fill-author-field-of-bib-entries
response
<urn:uuid:f2f7db85-4797-468c-a35a-ed0ee5179013>
isPartOf: CC-MAIN-2024-18
publisher: Common Crawl
description: Wide crawl of the web for April 2024
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-150
software: Apache Nutch 1.19 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.5-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/