事实上,\NewDocumentCommand{\xsameword}{m}
@nox 在他的在这里回答,存在编译时错误。
! Missing \endcsname inserted.
<to be read again>
:
l.74 \end{frame}
\errorcontextlines=5
按照@DonHosek 的要求,使用 LaTeX3 命令摘录了日志(我希望是经过精心挑选的)
! Missing \endcsname inserted.
<to be read again>
:
\l__regex_internal_a_tl ...word_format\exp_not:N :
n\cs_end: \exp_after:wN {\...
<argument> ...}\fi: }\fi: \l__regex_internal_a_tl
\if_int_compare:w \l__rege...
\use:x ...cs_set_nopar:Npx \l__exp_internal_tl {#1
}\l__exp_internal_tl
\__maieul_xsameword_start:n ..._xsameword_list_tl
\tl_use:N \l__maieul_xsame...
\beamer@doifinframe ...té d'aire est appelée le}
\keepword {\og \textit {\...
...
l.74 \end{frame}
The control sequence marked <to be read again> should
not appear between \csname and \endcsname.
! Missing \endcsname inserted.
<to be read again>
:
\l__regex_internal_a_tl ...word_format\exp_not:N :
n\cs_end: \exp_after:wN {\...
<argument> ...}\fi: }\fi: \l__regex_internal_a_tl
\if_int_compare:w \l__rege...
\use:x ...cs_set_nopar:Npx \l__exp_internal_tl {#1
}\l__exp_internal_tl
\__maieul_xsameword_start:n ..._xsameword_list_tl
\tl_use:N \l__maieul_xsame...
\beamer@doifinframe ...té d'aire est appelée le}
\keepword {\og \textit {\...
当 babel 包未加载,没有更多错误。
- 问题是什么?
- 怎么解决呢?
\documentclass[aspectratio=1610]{beamer}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath, amsfonts, amssymb}
\usefonttheme[onlymath]{serif}
% from egreg's answer at
%https://tex.stackexchange.com/a/280981/97512
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\xsameword}{m}
{
\leavevmode\maieul_xsameword:n { #1 }
}
\tl_new:N \l__maieul_xsameword_list_tl
\cs_new_protected:Nn \maieul_xsameword:n
{
\tl_set:Nn \l__maieul_xsameword_list_tl
{
\__maieul_xsameword_start:n { #1 }
}
\regex_replace_all:nnN
{ (\c{footnote}\cB..*?\cE.) }
{ \cE\} \1 \c{__maieul_xsameword_start:n} \cB\{ }
\l__maieul_xsameword_list_tl
\tl_use:N \l__maieul_xsameword_list_tl
}
\cs_new_protected:Nn \__maieul_xsameword_start:n
{
\tl_set:Nn \l__maieul_xsameword_list_tl { #1 }
\regex_replace_all:nnN
{ ([^\s,.!?]+) }% Delete what should not be printed again here
{ \c{maieul_xsameword_format:n} \cB\{ \1 \cE\} }
\l__maieul_xsameword_list_tl
\tl_use:N \l__maieul_xsameword_list_tl
}
\NewDocumentCommand{\setxsamewordformat}{m}
{
\cs_set_protected:Nn \maieul_xsameword_format:n { #1 }
}
\ExplSyntaxOff
%%%%%%%%%%%%%%%%%%%%%
\newbox\mytmpbox
\newcommand{\repword}[1]{%
\sbox{\mytmpbox}{#1}%
\hbox to \wd\mytmpbox{\hss\hspace{.2em}''\hss}%
}
\setxsamewordformat{\repword{#1}}
\newcommand{\keepword}[2]{%
\sbox{\mytmpbox}{#2}%
\hbox to \wd\mytmpbox{\hss#1\hss}%
}
\begin{document}
\begin{frame}
Lorsque le \og \textit{carreau carré} \fg{} mesure:
\begin{itemize}
\item {1}\,$cm$ de côté, l'unité d'aire est appelée le \og \textit{\textrm{centimètre carré}} \fg{} et est noté $cm^2$;
\item 1\,\keepword{$dm$}{$cm$} \xsameword{de côté, l'unité d'aire est appelée le} \keepword{\og \textit{\textrm{décimètre carré}} \fg{}}{\og \textit{\textrm{centimètre carré}} \fg{}} \xsameword{et est noté} $cm^2$;
\item 1\,\keepword{$m$}{$cm$} \xsameword{de côté, l'unité d'aire est appelée le} \keepword{\og \textit{\textrm{mètre carré}} \fg{}}{\og \textit{\textrm{centimètre carré}} \fg{}} \xsameword{et est noté} \keepword{$m^2$}{$cm^2$};
\end{itemize}
\end{frame}
\end{document}
答案1
这是一个错误。我昨天报告了它,它已在源代码中修复。