2

I'm using exercise package and I want the list of the exercise in the index. In texlive2019 (mac) I did not have any problem. Now, with texlive2020 (mac), I get the list of the exercises in the index, however each value is followed by a "t". Here the code:

\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}
egreg
  • 1,121,712

1 Answers1

1

The error is in exercise.sty that has a disastrous \expandafter in two places

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

This token is completely wrong and should be removed. Its effect is to untimely expand \itshape that should instead remain as is. An internal change in LaTeX made the error pop up; previously it went unnoticed by pure chance.

Contact the package maintainer; in the meantime you can fix it yourself.

\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}
egreg
  • 1,121,712