Unicode→LaTeX export produces unbraced stacked accents for precomposed Vietnamese letters (`ễ`, `ắ`), which biber then half-decodes into invalid input
Debug log ID
2FC9N2GZ-refs-euc/✓/✓
What happened?
| Zotero | 10.0.1 |
| Better BibTeX | 9.0.63 |
| biber / biblatex | biber 2.19, biblatex 3.19 |
| engine | pdfLaTeX, TeX Live 2023 |
| system | Linux 6.14 |
What happens
An author name stored in Zotero as plain Unicode:
Nguyễn, Xuân Thắngis exported by Better BibTeX as:
author = {Nguy{\~\^e}n, Xu{\^a}n Th{\'\\\u a}ng and Tran, Huu Tam and ...}Two characters are involved, both of which need two stacked accents:
| character | codepoint | decomposition | BBT output |
|---|---|---|---|
ễ |
U+1EC5 | e + circumflex + tilde |
{\~\^e} |
ắ |
U+1EAF | a + breve + acute |
{\'\\\u a} |
In both cases the inner accent command is not braced: BBT emits \~\^e, not \~{\^e}.
Why it breaks downstream
Feeding that .bib to biber (3.19 / biber 2.19) and pdfLaTeX with
\\\usepackage[utf8]{inputenc} and \\\usepackage[T1]{fontenc}:
biber's LaTeX→Unicode decoding resolves only the inner accent, and writes into
main.bbl:family={Nguy{\~ê}n}, given={Xuân\bibnamedelima Th{\'ă}ng},i.e. an accent command applied to an already-composed UTF-8 character.
inputencmakes the lead byte ofê(0xC3) an active character that reads the byte after it.\~grabs that active character as its argument, so the trailing byte is left alone and pdfLaTeX stops:./file.tex:83: LaTeX Error: Invalid UTF-8 byte sequence (^^c3\global). ./file.tex:83: LaTeX Error: Invalid UTF-8 byte "AA.
The braced form is not a workaround either: writing Nguy{\~{\^e}}n in the .bib by hand
produces exactly the same main.bbl as the unbraced form, and the same failure. Only a
.bib holding the precomposed characters themselves compiles, once \DeclareUnicodeCharacter
declares them:
\DeclareUnicodeCharacter{1EC5}{\~{\^e}}
\DeclareUnicodeCharacter{1EAF}{\'{\\\u a}}Minimal reproduction
t.bib — the three encodings, and what biber makes of each:
@article{a1, title={A}, author={Nguy{\~\^e}n, Xu{\^a}n Th{\'\\\u a}ng}, year=2015, journal={J}}
@article{a2, title={B}, author={Nguy{\~{\^e}}n, Xu{\^a}n Th{\'{\\\u a}}ng}, year=2015, journal={J}}
@article{a3, title={C}, author={Nguyễn, Xuân Thắng}, year=2015, journal={J}}a1 → family={Nguy{\~ê}n} given={Xuân Th{\'ă}ng} pdfLaTeX: error
a2 → family={Nguy{\~ê}n} given={Xuân Th{\'ă}ng} pdfLaTeX: error
a3 → family={Nguyễn} given={Xuân Thắng} pdfLaTeX: okWhat I would expect
Either of these would fix it, and the second looks more robust:
- brace nested accent commands —
{\~{\^e}},{\'{\\\u a}}— which at least makes the exported LaTeX well-formed, though it does not survive the biber round-trip; or - leave precomposed characters that require stacked accents as Unicode in the export, the
way
a3above works. They are the only form the whole chain accepts.
The same question applies to the rest of the Vietnamese block (U+1EA0–U+1EF9) and to any other script whose letters decompose into two or more accents.
Workaround in use
Strip the diacritics from the name in Zotero, which loses the correct spelling of a colleague's name.
Source: retorquere/zotero-better-bibtex