<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to HowTo_ChapterAtLists</title><link>https://sourceforge.net/p/koma-script/wiki-en/HowTo_ChapterAtLists/</link><description>Recent changes to HowTo_ChapterAtLists</description><atom:link href="https://sourceforge.net/p/koma-script/wiki-en/HowTo_ChapterAtLists/feed" rel="self"/><language>en</language><lastBuildDate>Tue, 22 Jul 2025 10:02:11 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/koma-script/wiki-en/HowTo_ChapterAtLists/feed" rel="self" type="application/rss+xml"/><item><title>HowTo_ChapterAtLists modified by Markus Kohm</title><link>https://sourceforge.net/p/koma-script/wiki-en/HowTo_ChapterAtLists/</link><description>&lt;div class="markdown_content"&gt;&lt;h1 id="how-to-output-chapter-headings-in-the-list-of-figures-and-list-of-tables-and-in-other-directories-of-floating-environments"&gt;How to output chapter headings in the list of figures and list of tables and in other directories of floating environments&lt;/h1&gt;
&lt;p&gt;Anyone who has read the &lt;a class="" href="http://mirrors.ctan.org/macros/latex/contrib/koma-script/doc/scrguide-en.pdf" rel="nofollow"&gt;KOMA-Script user guide&lt;/a&gt; knows that with &lt;code&gt;scrbook&lt;/code&gt; and &lt;code&gt;scrreprt&lt;/code&gt; the chapter headings can also be displayed in all directories of floating environments using the option &lt;code&gt;chapteratlists=entry&lt;/code&gt; in addition to the table of contents. However, the option works very consistently and adds the chapter heading to the list of figures, for example, even if the corresponding chapter has no figures at all and therefore the list of figures for this chapter does not display any figures. However, it is often desired that the chapter heading is only displayed if this chapter also has a corresponding floating environment entry.&lt;/p&gt;
&lt;p&gt;The chapter entries are written to the directories in both classes within &lt;code&gt;\addchaptertocentry&lt;/code&gt;. This instruction is called by &lt;code&gt;\chapter&lt;/code&gt; (or &lt;code&gt;\addchap&lt;/code&gt;), i.e. at a time when it is not yet known whether the chapter will subsequently have a corresponding floating environment. So we first need an indicator for this. Since all entries are written via &lt;code&gt;\addcontentsline&lt;/code&gt;, the idea of generating this indicator within &lt;code&gt;\addcontentsline&lt;/code&gt; is obvious. As the indicator must be available in the next LaTeX run, it is written to the &lt;code&gt;aux&lt;/code&gt; file. The easiest way to do this is to generate a label:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;\AddToHookWithArguments&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;cmd/addcontentsline/before&lt;span class="nb"&gt;}{&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
  &lt;span class="k"&gt;\Ifstr&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;#1&lt;span class="nb"&gt;}{&lt;/span&gt;&lt;span class="k"&gt;\ext@toc&lt;/span&gt;&lt;span class="nb"&gt;}{}{&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
    &lt;span class="k"&gt;\@ifundefined&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;chapter@&lt;span class="k"&gt;\thechapter&lt;/span&gt; @has@#1@done&lt;span class="nb"&gt;}{&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
      &lt;span class="k"&gt;\expandafter\global\@namedef&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;chapter@thechapter @has@#1@done&lt;span class="nb"&gt;}{&lt;/span&gt;true&lt;span class="nb"&gt;}&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
      &lt;span class="k"&gt;\label&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;chapter@&lt;span class="k"&gt;\thechapter&lt;/span&gt; @has@#1&lt;span class="nb"&gt;}&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
    &lt;span class="nb"&gt;}{}&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
  &lt;span class="nb"&gt;}&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Here we use a generic LaTeX hook for the beginning of the &lt;code&gt;\addcontentsline&lt;/code&gt; command, which also receives all arguments of &lt;code&gt;\addcontentsline&lt;/code&gt;. The first argument is the file extension of the respective directory. Here we first test that it is not the table of contents itself and only then generate the indicator. Although this is not absolutely necessary, it does make sense.&lt;/p&gt;
&lt;p&gt;We use a label as an indicator because in current LaTeX versions we can very easily test for its existence with &lt;code&gt;\IfLabelExists:TF&lt;/code&gt; and at the same time LaTeX automatically issues a message at the end of the LaTeX run in the event of changes, so that we know that another LaTeX run is necessary. The name of the label is simply made up of the chapter number and the file extension of the respective directory as well as some meaningful strings. We get the number of the chapter (in this first version) simply via &lt;code&gt;\thechapter&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;However, as multiple defined labels lead to warnings, we use a second indicator to decide whether the label still needs to be defined or whether a label has already been created for the current chapter. To do this, we define another macro globally and only set the label if this macro has not yet been defined.&lt;/p&gt;
&lt;p&gt;Next, we must ensure that the chapter entry is only written if the label for this chapter exists. To do this, we only need to set or delete the ToC feature &lt;code&gt;chapteratlist&lt;/code&gt; depending on whether the indicator label exists. We do not have to completely redefine &lt;code&gt;\addchaptertocentry&lt;/code&gt; for this either, but can use a generic LaTeX hook at the beginning of the command:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;\AddToHook&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;cmd/addchaptertocentry/before&lt;span class="nb"&gt;}{&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
  &lt;span class="k"&gt;\if@chaptertolists&lt;/span&gt;
    &lt;span class="k"&gt;\doforeachtocfile&lt;/span&gt;&lt;span class="na"&gt;[float]&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
      &lt;span class="k"&gt;\IfLabelExistsTF&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;chapter@&lt;span class="k"&gt;\thechapter&lt;/span&gt; @has@&lt;span class="k"&gt;\@currext&lt;/span&gt;&lt;span class="nb"&gt;}{&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
        &lt;span class="k"&gt;\setuptoc&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;&lt;span class="k"&gt;\@currext&lt;/span&gt;&lt;span class="nb"&gt;}{&lt;/span&gt;chapteratlist&lt;span class="nb"&gt;}&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
      &lt;span class="nb"&gt;}{&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
        &lt;span class="k"&gt;\unsettoc&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;&lt;span class="k"&gt;\@currext&lt;/span&gt;&lt;span class="nb"&gt;}{&lt;/span&gt;chapteratlist&lt;span class="nb"&gt;}&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
      &lt;span class="nb"&gt;}&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
    &lt;span class="nb"&gt;}&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
  &lt;span class="k"&gt;\fi&lt;/span&gt;
&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;We use &lt;code&gt;\if@chaptertolists&lt;/code&gt; to check whether the &lt;code&gt;chapteratlists&lt;/code&gt; option is used at all. Strictly speaking, we could do without this test. We then check for each auxiliary file in the &lt;code&gt;float&lt;/code&gt; category whether the corresponding indicator label exists for the current chapter. If this is the case, we set the &lt;code&gt;chapteratlist&lt;/code&gt; feature for the corresponding file extension. If this is not the case, we delete the feature.&lt;/p&gt;
&lt;p&gt;That was actually all. However, the use of &lt;code&gt;\thechapter&lt;/code&gt; has a decisive disadvantage. The whole thing does not work correctly if not only &lt;code&gt;\chapter&lt;/code&gt; but also &lt;code&gt;\addchap&lt;/code&gt; is used. Other unnumbered chapters, for example in the area of &lt;code&gt;\frontmatter&lt;/code&gt; or &lt;code&gt;\backmatter&lt;/code&gt;, also pose a problem. To solve the problem, we can use an absolute chapter counter &lt;code&gt;abschapter&lt;/code&gt;, which also counts unnumbered chapters. This can also be incremented using a generic hook for each &lt;code&gt;\chapter&lt;/code&gt; (and therefore also each &lt;code&gt;\chapter*&lt;/code&gt; and each &lt;code&gt;\addchap&lt;/code&gt; or &lt;code&gt;\addchap*&lt;/code&gt;). Then only &lt;code&gt;\thechapter&lt;/code&gt; needs to be replaced by &lt;code&gt;\theabschapter&lt;/code&gt; in the above definitions.&lt;/p&gt;
&lt;p&gt;Here a complete example:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;\documentclass&lt;/span&gt;&lt;span class="na"&gt;[chapteratlists=entry]&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;scrbook&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;span class="c"&gt;% Code to limit chapteratlists=entry to chapters with float entries.&lt;/span&gt;
&lt;span class="c"&gt;% → https://sf.net/p/koma-script/wiki-en/HowTo_ChapterAtLists&lt;/span&gt;
&lt;span class="k"&gt;\makeatletter&lt;/span&gt;
&lt;span class="k"&gt;\newcounter&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;abschapter&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;\AddToHook&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;cmd/chapter/before&lt;span class="nb"&gt;}{&lt;/span&gt;&lt;span class="k"&gt;\stepcounter&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;abschapter&lt;span class="nb"&gt;}}&lt;/span&gt;
&lt;span class="k"&gt;\AddToHookWithArguments&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;cmd/addcontentsline/before&lt;span class="nb"&gt;}{&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
  &lt;span class="k"&gt;\Ifstr&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;#1&lt;span class="nb"&gt;}{&lt;/span&gt;&lt;span class="k"&gt;\ext@toc&lt;/span&gt;&lt;span class="nb"&gt;}{}{&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
    &lt;span class="k"&gt;\@ifundefined&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;chapter@&lt;span class="k"&gt;\theabschapter&lt;/span&gt; @has@#1@done&lt;span class="nb"&gt;}{&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
      &lt;span class="k"&gt;\expandafter\global\@namedef&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;chapter@&lt;span class="k"&gt;\theabschapter&lt;/span&gt; @has@#1@done&lt;span class="nb"&gt;}{&lt;/span&gt;true&lt;span class="nb"&gt;}&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
      &lt;span class="k"&gt;\label&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;chapter@&lt;span class="k"&gt;\theabschapter&lt;/span&gt; @has@#1&lt;span class="nb"&gt;}&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
    &lt;span class="nb"&gt;}{}&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
  &lt;span class="nb"&gt;}&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;\AddToHook&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;cmd/addchaptertocentry/before&lt;span class="nb"&gt;}{&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
  &lt;span class="k"&gt;\if@chaptertolists&lt;/span&gt;
    &lt;span class="k"&gt;\doforeachtocfile&lt;/span&gt;&lt;span class="na"&gt;[float]&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
      &lt;span class="k"&gt;\IfLabelExistsTF&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;chapter@&lt;span class="k"&gt;\theabschapter&lt;/span&gt; @has@&lt;span class="k"&gt;\@currext&lt;/span&gt;&lt;span class="nb"&gt;}{&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
        &lt;span class="k"&gt;\setuptoc&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;&lt;span class="k"&gt;\@currext&lt;/span&gt;&lt;span class="nb"&gt;}{&lt;/span&gt;chapteratlist&lt;span class="nb"&gt;}&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
      &lt;span class="nb"&gt;}{&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
        &lt;span class="k"&gt;\unsettoc&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;&lt;span class="k"&gt;\@currext&lt;/span&gt;&lt;span class="nb"&gt;}{&lt;/span&gt;chapteratlist&lt;span class="nb"&gt;}&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
      &lt;span class="nb"&gt;}&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
    &lt;span class="nb"&gt;}&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
  &lt;span class="k"&gt;\fi&lt;/span&gt;
&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;\makeatother&lt;/span&gt;
&lt;span class="k"&gt;\usepackage&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;mwe&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;\begin&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;document&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;\tableofcontents&lt;/span&gt;
&lt;span class="k"&gt;\listoffigures&lt;/span&gt;
&lt;span class="k"&gt;\listoftables&lt;/span&gt;
&lt;span class="k"&gt;\Blinddocument&lt;/span&gt;
&lt;span class="k"&gt;\begin&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;figure&lt;span class="nb"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;\centering&lt;/span&gt;
  &lt;span class="k"&gt;\includegraphics&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;example-image&lt;span class="nb"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;\caption&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;Test Figure&lt;span class="nb"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;\label&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;fig:test&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;\end&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;figure&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;\Blinddocument&lt;/span&gt;
&lt;span class="k"&gt;\begin&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;table&lt;span class="nb"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;\centering&lt;/span&gt;
  &lt;span class="k"&gt;\begin&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;tabular&lt;span class="nb"&gt;}{&lt;/span&gt;ll&lt;span class="nb"&gt;}&lt;/span&gt;
    test &lt;span class="nb"&gt;&amp;amp;&lt;/span&gt; table
  &lt;span class="k"&gt;\end&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;tabular&lt;span class="nb"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;\caption&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;Test Table&lt;span class="nb"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;\label&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;tab:test&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;\end&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;table&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;\Blinddocument&lt;/span&gt;
&lt;span class="k"&gt;\Blinddocument&lt;/span&gt;
&lt;span class="k"&gt;\begin&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;figure&lt;span class="nb"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;\centering&lt;/span&gt;
  &lt;span class="k"&gt;\includegraphics&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;example-image-a&lt;span class="nb"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;\caption&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;Test Figure A&lt;span class="nb"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;\label&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;fig:testA&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;\end&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;figure&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;\Blinddocument&lt;/span&gt;
&lt;span class="k"&gt;\begin&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;table&lt;span class="nb"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;\centering&lt;/span&gt;
  &lt;span class="k"&gt;\begin&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;tabular&lt;span class="nb"&gt;}{&lt;/span&gt;ll&lt;span class="nb"&gt;}&lt;/span&gt;
    test &lt;span class="nb"&gt;&amp;amp;&lt;/span&gt; table
  &lt;span class="k"&gt;\end&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;tabular&lt;span class="nb"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;\caption&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;Test Table A&lt;span class="nb"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;\label&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;tab:testA&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;\end&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;table&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;\addchap&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;Test addchap&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;\begin&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;table&lt;span class="nb"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;\renewcommand*&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;&lt;span class="k"&gt;\thetable&lt;/span&gt;&lt;span class="nb"&gt;}{&lt;/span&gt;&lt;span class="k"&gt;\arabic&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;table&lt;span class="nb"&gt;}}&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
  &lt;span class="k"&gt;\renewcommand*&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;&lt;span class="k"&gt;\theHtable&lt;/span&gt;&lt;span class="nb"&gt;}{&lt;/span&gt;&lt;span class="k"&gt;\theabschapter&lt;/span&gt;.&lt;span class="k"&gt;\arabic&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;table&lt;span class="nb"&gt;}}&lt;/span&gt;&lt;span class="c"&gt;%&lt;/span&gt;
  &lt;span class="k"&gt;\centering&lt;/span&gt;
  &lt;span class="k"&gt;\begin&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;tabular&lt;span class="nb"&gt;}{&lt;/span&gt;ll&lt;span class="nb"&gt;}&lt;/span&gt;
    test &lt;span class="nb"&gt;&amp;amp;&lt;/span&gt; test
  &lt;span class="k"&gt;\end&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;tabular&lt;span class="nb"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;\caption&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;Test Table addchap&lt;span class="nb"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;\label&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;tab:addchap&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;\end&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;table&lt;span class="nb"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;\addchap&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;Another addchap&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;\blindtext&lt;/span&gt;

&lt;span class="k"&gt;\appendix&lt;/span&gt;
&lt;span class="k"&gt;\Blinddocument&lt;/span&gt;
&lt;span class="k"&gt;\begin&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;table&lt;span class="nb"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;\centering&lt;/span&gt;
  &lt;span class="k"&gt;\begin&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;tabular&lt;span class="nb"&gt;}{&lt;/span&gt;ll&lt;span class="nb"&gt;}&lt;/span&gt;
    test &lt;span class="nb"&gt;&amp;amp;&lt;/span&gt; table
  &lt;span class="k"&gt;\end&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;tabular&lt;span class="nb"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;\caption&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;Test Table B&lt;span class="nb"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;\label&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;tab:testB&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;\end&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;table&lt;span class="nb"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;\Blinddocument&lt;/span&gt;

&lt;span class="k"&gt;\end&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;document&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Incidentally, the example still works if you load &lt;a class="" href="https://www.ctan.org/pkg/hyperref" rel="nofollow"&gt;&lt;code&gt;hyperref&lt;/code&gt;&lt;/a&gt;, whereby it does not matter whether you load the package before or after the additional preamble code.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Markus Kohm</dc:creator><pubDate>Tue, 22 Jul 2025 10:02:11 -0000</pubDate><guid>https://sourceforge.netc0ebb202939dbd2f3f9ee83895ec7df7cef6ba81</guid></item></channel></rss>