TeX - LaTeX Asked by HelloEdit on April 22, 2021
I wanted to know if it was possible to insert the list of exercises in the table of contents via tableofcontent
.
For each of my exercises, I use a template like this:
begin{exercise}[subtitle=title I would like to see in the TOC]
blablabla
end{exercise}
Yes, you can do this with xsim
and tocbasic
: here's a working example.
Here's what we need:
DeclareTOCStyleEntry
;DeclareExerciseEnvironmentTemplate
(telling xsim
that we want to typeset exercises our way).addxcontentsline{toc}{exercise}
command inside the template, where you can specify what to write in that TOC entry.GetExerciseProperty{subtitle}
Cheers.
Correct answer by J. Brown on April 22, 2021
You have three choices:
default
template,subsection*
with the halp of environment hooks, orexercise/heading
to choose a suitable command instead of the default subsection*
.Before I show the last and easiest choice there are other considerations to make: if we simply change subsection*
to subsection
the exercises will get subsection numbers and exercise numbers:
I don't think that this is a satisfying solution. Something like
newcommandaddsubsec[1]{%
subsection*{#1}%
addcontentsline{toc}{subsection}{#1}%
}
with xsimsetup{exercise/heading=addsubsec}
seems a better solution:
documentclass{article}
usepackage{xsim}
newcommandaddsubsec[1]{%
subsection*{#1}%
addcontentsline{toc}{subsection}{#1}%
}
xsimsetup{exercise/heading=addsubsec}
begin{document}
tableofcontents
section{Exercises}
begin{exercise}
This is the first problem.
end{exercise}
begin{exercise}[subtitle=Another Problem]
This is the second problem.
end{exercise}
end{document}
Answered by cgnieder on April 22, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP