使用练习包在索引中添加额外字符

使用练习包在索引中添加额外字符

我正在使用锻炼包,我想要索引中的锻炼列表。在 texlive2019 (mac) 中我没有遇到任何问题。现在,使用 texlive2020 (mac),我获得了索引中的锻炼列表,但是每个值后面都有一个“t”。这里是代码:

\documentclass[12pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
%
\usepackage{exercise} 
\renewcounter{Exercise}[chapter]% Reset counter every chapter
\renewcommand{\theExercise}{\thechapter.\arabic{Exercise}}%
\begin{document}
%
\author{Author Name}
%
\title{The proof}
%
\maketitle
%
\tableofcontents
%
\ListOfExerciseInToc
\ExerciseLevelInToc{section}
%
%
\chapter{gas}

\begin{Exercise}[difficulty=1]
bla
bla
bla
\end{Exercise}
\begin{Exercise}[difficulty=2]
blo
blo
blo
\end{Exercise}

\chapter{energy}

\begin{Exercise}[difficulty=3]
blu
blu
blu
\end{Exercise}
\begin{Exercise}[difficulty=1]
bli
bli
bli
\end{Exercise}

\end{document}

答案1

错误在于在两个地方exercise.sty有灾难性\expandafter

   \addcontentsline{\ext@exercise}{\toc@exercise}{\ExerciseName\
        \theExercise\ \expandafter{\itshape \ExerciseTitle}\hspace{.66em}}

此标记完全错误,应删除。其效果是不合时宜地扩展,\itshape而本应保持原样。LaTeX 的内部更改导致错误弹出;之前它纯粹是偶然被忽视的。

联系软件包维护者;同时您可以自行修复此问题。

\documentclass[12pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
%
\usepackage{exercise,etoolbox}
\renewcounter{Exercise}[chapter]% Reset counter every chapter
\renewcommand{\theExercise}{\thechapter.\arabic{Exercise}}%

% fix the wrong code in exercise.sty
\makeatletter
\patchcmd{\@@@ExeEnv}{\expandafter}{}{}{}
\patchcmd{\@@@Execmd}{\expandafter}{}{}{}
\makeatother

\begin{document}
%
\author{Author Name}
%
\title{The proof}
%
\maketitle
%
\tableofcontents
%
\ListOfExerciseInToc
\ExerciseLevelInToc{section}
%
%
\chapter{gas}

\begin{Exercise}[difficulty=1]
bla
bla
bla
\end{Exercise}
\begin{Exercise}[difficulty=2]
blo
blo
blo
\end{Exercise}

\chapter{energy}

\begin{Exercise}[difficulty=3]
blu
blu
blu
\end{Exercise}
\begin{Exercise}[difficulty=1]
bli
bli
bli
\end{Exercise}

\end{document}

相关内容