babel 的语言选择破坏了 biblatex-chicago 的 @online 条目

babel 的语言选择破坏了 biblatex-chicago 的 @online 条目

在主要为单语(英语)的文档中,biblatex-chicago 在条目中的语言切换时会抛出错误Missing \endcsnameonline但不会misc,,,,,articlebooklegislationvideo任何其他条目均不会抛出错误)。使用 vanilla biblatex 不会发生这种情况。

我该如何实现这个功能?我需要切换语言,尤其是泰语条目。

\documentclass{article}

\usepackage[english]{babel}
\babelfont{rm}{FreeSerif}
\babelprovide[import]{thai}
\babeltags{thai = thai}
\babeltags{es = spanish}

% \usepackage[style=verbose]{biblatex}
\usepackage[notes,backend=biber]{biblatex-chicago}
\addbibresource{\jobname.bib}
\begin{filecontents}{\jobname.bib}
@online{SE:Lefurgy:When_is_it,
    author   = {Bill Lefurgy},
    title    = {When is it appropriate to use \enquote{scare quotes}?},
    organization = {Stack Exchange},
    url      = {https://english.stackexchange.com/q/69547/59745},
    date     = {2013-10-08},
    urldate  = {2022-03-06},
}

@online{SNSP::Victimas_de_Delitos,
    title    = {\textes{Víctimas de Delitos del Fuero Común 2020}},
    organization = {\textes{Secretariado Ejecutivo del Sistema Nacional de Seguridad Pública}},
    url      = {https://drive.google.com/file/d/1zoXcMNUUSChtT99FWY9LZAweqtEzIIgz/view},
    date     = {2021-08-20},
    urldate  = {2022-03-06},
}

@misc{BT::Prices_of_important,
    title    = {\textthai{ราคาสินค้าอุตสาหกรรมที่สำคัญ} \mkbibbrackets{Prices of important industial commodities}},
    organization = {Bank of Thailand},
    date     = {2022-02-28},
    url      = {https://www.bot.or.th/App/BTWS_STAT/statistics/BOTWEBSTAT.aspx?reportID=90&language=TH},
    urldate  = {2022-03-06},
}
\end{filecontents}


\usepackage[style=english]{csquotes}

\usepackage{hyperref}
\setcounter{biburllcpenalty}{9000}
\setcounter{biburlucpenalty}{9000}

\begin{document}

Good.\autocite{SE:Lefurgy:When_is_it}
Bad.\autocite{SNSP::Victimas_de_Delitos} % Doesn't work with biblatex-chicago
Good.\autocite{BT::Prices_of_important}

\end{document}

答案1

biblatex-chicago使用 xstring 包中的许多测试,例如

\IfBeginWith{\thefield{title}}{CCCCCC}

这非常脆弱,因为 xstring 会完全扩展,\edef因此各种命令可能会在经过此类测试的领域中以各种方式爆发。对于您的情况,您可以通过使 \textes 变得健壮来避免错误:

\documentclass{article}
\usepackage{xstring,etoolbox}
\usepackage[english]{babel}
\babeltags{es = spanish}
\begin{document}
%\robustify\textes %avoids the error
\IfBeginWith{\textes{abc}}{CCCCCC}{yes}{no}

\end{document}

相关内容