以下代码因使用 而损坏\usepackage[french]{babel}
。可以轻松修复吗?
\documentclass[12pt]{article}
\usepackage[french]{babel} % The character ; becomes active...
\ExplSyntaxOn
\NewDocumentEnvironment{env-KO}{ b }{%
\pmbc_splitsemicolon:n { #1 } %
}{}
\cs_new:Npn \pmbc_splitsemicolon:n #1 {
\seq_set_split_keep_spaces:Nnn \l_tmpa_seq { ; } { #1 }
\seq_use:Nn \l_tmpa_seq { \par\smallskip }
}
\ExplSyntaxOff
\begin{document}
\begin{env-KO}
a ;
b ; c ; d
\end{env-KO}
\end{document}
我尝试了以下补丁,但没有成功。
\documentclass[12pt]{article}
\usepackage[french]{babel} % The character ; becomes active...
\ExplSyntaxOn
\NewDocumentEnvironment{env-KO}{ b }{%
\shorthandoff{;}
\pmbc_splitsemicolon:n { #1 } %
}{}
\cs_new:Npn \pmbc_splitsemicolon:n #1 {
\seq_set_split_keep_spaces:Nnn \l_tmpa_seq { ; } { #1 }
\seq_use:Nn \l_tmpa_seq { \par\smallskip }
}
\ExplSyntaxOff
\begin{document}
\begin{env-KO}
a ;
b ; c ; d
\end{env-KO}
\end{document}
答案1
您想重新扫描文档开头的分号。
\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\ExplSyntaxOn
\NewDocumentEnvironment{env-KO}{ b }
{
\pmbc_splitsemicolon:n { #1 }
}{}
\tl_new:N \g_pmbc_splitsemicolon_semicolon_tl
\tl_gset:Nn \g_pmbc_splitsemicolon_semicolon_tl { ; }
\cs_generate_variant:Nn \seq_set_split_keep_spaces:Nnn { NV }
\AtBeginDocument
{
\tl_gset_rescan:NnV \g_pmbc_splitsemicolon_semicolon_tl {} \g_pmbc_splitsemicolon_semicolon_tl
}
\cs_new:Npn \pmbc_splitsemicolon:n #1
{
\seq_set_split_keep_spaces:NVn \l_tmpa_seq \g_pmbc_splitsemicolon_semicolon_tl { #1 }
\seq_use:Nn \l_tmpa_seq { \par\smallskip }
}
\ExplSyntaxOff
\begin{document}
\begin{env-KO}
a ;
b ; c ; d
\end{env-KO}
\end{document}