summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
Diffstat (limited to 'support')
-rw-r--r--support/TeX4ht/source/ChangeLog6
-rw-r--r--support/TeX4ht/source/tex4ht-4ht.tex30
2 files changed, 34 insertions, 2 deletions
diff --git a/support/TeX4ht/source/ChangeLog b/support/TeX4ht/source/ChangeLog
index 5dfc905668..ef9c5510f6 100644
--- a/support/TeX4ht/source/ChangeLog
+++ b/support/TeX4ht/source/ChangeLog
@@ -1,3 +1,9 @@
+2022-06-21 Michal Hoftich <michal.h21@gmail.com>
+
+ * tex4ht-4ht.tex (latex.4ht): fixed support for \index commands
+ inside \caption.
+ https://tex.stackexchange.com/a/647924/2891
+
2022-06-20 Michal Hoftich <michal.h21@gmail.com>
* tex4ht-4ht.tex (pdfpages.4ht): added support for the Pdfpages
diff --git a/support/TeX4ht/source/tex4ht-4ht.tex b/support/TeX4ht/source/tex4ht-4ht.tex
index 0c2e94ba1b..0c2bd00913 100644
--- a/support/TeX4ht/source/tex4ht-4ht.tex
+++ b/support/TeX4ht/source/tex4ht-4ht.tex
@@ -1,4 +1,4 @@
-% $Id: tex4ht-4ht.tex 1157 2022-06-20 13:49:01Z michal_h21 $
+% $Id: tex4ht-4ht.tex 1158 2022-06-21 15:56:07Z michal_h21 $
% tex tex4ht-4ht or ht tex tex4ht-4ht
%
% Copyright 2009-2022 TeX Users Group
@@ -11487,15 +11487,41 @@ The following has been changed for getting links in \`'.aux' files to
\`'.lot' (list of tables) and \`'lof' (list of figures) files.
\<latex ltfloat\><<<
+|<latex caption index|>
\long\def\:tempc#1[#2]#3{\par \cur:lbl{}%
|<write caption to toc|>\begingroup
+ |<latex caption index save|>
\@parboxrestore \normalsize
\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
- \endgroup |<cancel if-label anchors|>}
+ \endgroup
+|<latex caption index print|>
+|<cancel if-label anchors|>}
\def\numberline#1{\hbox to\@tempdima{#1\hfil} }
\HLet\@caption|=\:tempc
>>>
+The index commands used inside caption may result in fatal error.
+We use the LaTeX 3 sequences to save their contents inside caption,
+and print them when it is safe.
+
+\<latex caption index\><<<
+\ExplSyntaxOn
+\seq_new:N\:savedindex
+\def\:initsaveindex{\seq_gclear:N\:savedindex}
+\def\:saveindex#1{\seq_gput_right:Nn\:savedindex{#1}}
+\def\:printsavedindex{\seq_map_inline:Nn\:savedindex{\index{##1}}}
+\ExplSyntaxOff
+>>>
+
+\<latex caption index save\><<<
+\:initsaveindex%
+\let\index\:saveindex%
+>>>
+
+\<latex caption index print\><<<
+\:printsavedindex%
+>>>
+
The \''|<cancel if-label anchors|>' request no
the \''\label' commands to avoid duplicating the anchor already set by the
\''\caption' command.