texlive[73568] Master/texmf-dist: list of listings fix, tex4ht r1632

commits+karl at tug.org commits+karl at tug.org
Thu Jan 23 21:59:03 CET 2025


Revision: 73568
          https://tug.org/svn/texlive?view=revision&revision=73568
Author:   karl
Date:     2025-01-23 21:59:03 +0100 (Thu, 23 Jan 2025)
Log Message:
-----------
list of listings fix, tex4ht r1632

Revision Links:
--------------
    https://tug.org/svn/texlive?view=revision&revision=1632

Modified Paths:
--------------
    trunk/Master/texmf-dist/source/generic/tex4ht/ChangeLog
    trunk/Master/texmf-dist/source/generic/tex4ht/tex4ht-4ht.tex
    trunk/Master/texmf-dist/tex/generic/tex4ht/listings.4ht

Modified: trunk/Master/texmf-dist/source/generic/tex4ht/ChangeLog
===================================================================
--- trunk/Master/texmf-dist/source/generic/tex4ht/ChangeLog	2025-01-23 20:37:11 UTC (rev 73567)
+++ trunk/Master/texmf-dist/source/generic/tex4ht/ChangeLog	2025-01-23 20:59:03 UTC (rev 73568)
@@ -1,3 +1,9 @@
+2025-01-23  Michal Hoftich  <michal.h21 at gmail.com>
+
+	* tex4ht-4ht.tex (listigns.4ht): fixed support for the list of
+	listings.
+	https://tex.stackexchange.com/a/734717/2891
+	
 2025-01-21  Michal Hoftich  <michal.h21 at gmail.com>
 
 	* tex4ht-fonts-modern.tex

Modified: trunk/Master/texmf-dist/source/generic/tex4ht/tex4ht-4ht.tex
===================================================================
--- trunk/Master/texmf-dist/source/generic/tex4ht/tex4ht-4ht.tex	2025-01-23 20:37:11 UTC (rev 73567)
+++ trunk/Master/texmf-dist/source/generic/tex4ht/tex4ht-4ht.tex	2025-01-23 20:59:03 UTC (rev 73568)
@@ -1,4 +1,4 @@
-% $Id: tex4ht-4ht.tex 1628 2025-01-18 17:47:47Z michal_h21 $
+% $Id: tex4ht-4ht.tex 1632 2025-01-23 12:34:17Z michal_h21 $
 % tex tex4ht-4ht   or   ht tex tex4ht-4ht
 %
 % Copyright 2009-2025 TeX Users Group    
@@ -20646,6 +20646,39 @@
 >>> 
 
 %%%%%%%%%%%%%%%%
+\Chapter{Standalone}
+%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%
+\Section{standalone}
+%%%%%%%%%%%%%%%%%%%%%%%%
+
+\<standalone.4ht\><<< 
+% standalone.4ht (|version), generated from |jobname.tex
+% Copyright 2025 TeX Users Group
+|<TeX4ht license text|> 
+|<standalone standaloneenv|>
+
+\Hinput{standalone} 
+\endinput
+>>> \AddFile{}{standalone}
+
+The \Verb'\standaloneenv' command patches an environment in a way that the
+environment produces a separate page. This can cause issues with environments that
+are also patched by TeX4ht, for example tikzpicture. This happens with the 
+tikz class option for Stadnalone. The result is that TikZ pictures are not 
+converted to images correctly.
+
+I think we can just disable this command.
+
+\<standalone standaloneenv\><<<
+% save the original meaning if we want to use it eventually
+\let\:standaloneenv\standaloneenv
+% but disable if by default
+\let\standaloneenv\@gobble
+>>>
+
+%%%%%%%%%%%%%%%%
 \Part{AMS}
 %%%%%%%%%%%%%%%%
 
@@ -34035,6 +34068,7 @@
 % Copyright |CopyYear.2001. Eitan M. Gurari
 |<TeX4ht copywrite|>
 |<listings sty|>
+|<listings list of|>
 |<lstmisc sty|>
 \Hinput{listings}
 \endinput
@@ -34104,17 +34138,48 @@
 \NewConfigure{lstinline}{2}
 >>>
 
-\<listings sty\><<<
+It seems that \Verb|\addcontentsline| is redefined in listings, which prevents 
+correct handling of \Verb|\lstlistoflistings|. We need to pass our definition 
+of \Verb|\addcontentsline| which can then be used to write the correct TOC
+information to the .4tc file.
+
+\<listings list of\><<<
+\def\lst:newaddcontentsline#1#2#3{\gHAdvance\TitleCount by 1
+  {\protect:wrtoc%
+  \protected at edef\:temp{#3}%
+   \protected at edef\:temp{\the\:tokwrite{\string\doTocEntry%
+   \string\toclol% identify this entry as list of listings
+   {\thetable}{\string\csname\space a:TocLink\string\endcsname%
+     {\FileNumber}{\cur:th \:currentlabel}{}{\ifx\:temp\empty\else \ignorespaces #3\fi}}%
+       {}\relax}}\:temp%
+}}%
+>>>
+
+We need to redefine \Verb|\addcontentsline| inside of Listing's version of MakeCaption.
+
+\<listings list of\><<<
 \pend:defI\lst at MakeCaption{%
-  \let\lst:addcontentsline\addcontentsline
-  \def\addcontentsline{\gHAdvance\TitleCount by 1
-                       \lst:addcontentsline}%
+  \let\lst:addcontentsline\addcontentsline%
+  \let\addcontentsline\lst:newaddcontentsline%
 }
 \append:defI\lst at MakeCaption{%
+  % insert destination ID for the list of listings
+  \Link{}{\cur:th\:currentlabel}\EndLink
   \let\addcontentsline\lst:addcontentsline
 }
 >>>
 
+And lastly, we need to use TeX4ht commands to print th elist of listings.
+
+\<listings list of\><<<
+\ConfigureToc{lol} {}{\empty}{}{\newline}
+\AtBeginDocument{%
+\def\lstlistoflistings{\bgroup%
+    \ifdefined\chapter\chapter*{\lstlistlistingname}\else\section*{\lstlistlistingname}\fi%
+    \TableOfContents[lol]%
+  \egroup}}
+>>>
+
 \<lstmisc sty\><<<
 \HLet\lst at frameInit=\empty
 \HLet\lst at frameExit=\empty

Modified: trunk/Master/texmf-dist/tex/generic/tex4ht/listings.4ht
===================================================================
--- trunk/Master/texmf-dist/tex/generic/tex4ht/listings.4ht	2025-01-23 20:37:11 UTC (rev 73567)
+++ trunk/Master/texmf-dist/tex/generic/tex4ht/listings.4ht	2025-01-23 20:59:03 UTC (rev 73568)
@@ -1,12 +1,12 @@
-% listings.4ht (2024-06-10-14:03), generated from tex4ht-4ht.tex
+% listings.4ht (2025-01-23-12:56), generated from tex4ht-4ht.tex
 % Copyright 2001-2009 Eitan M. Gurari
-% Copyright 2009-2024 TeX Users Group
+% Copyright 2009-2025 TeX Users Group
 %
 % This work may be distributed and/or modified under the
 % conditions of the LaTeX Project Public License, either
 % version 1.3c of this license or (at your option) any
 % later version. The latest version of this license is in
-%   http://www.latex-project.org/lppl.txt
+%   https://www.latex-project.org/lppl.txt
 % and version 1.3c or later is part of all distributions
 % of LaTeX version 2005/12/01 or later.
 %
@@ -13,11 +13,11 @@
 % This work has the LPPL maintenance status "maintained".
 %
 % The Current Maintainer of this work
-% is the TeX4ht Project <http://tug.org/tex4ht>.
+% is the TeX4ht Project <https://tug.org/tex4ht>.
 %
 % If you modify this program, changing the
 % version identification would be appreciated.
-\immediate\write-1{version 2024-06-10-14:03}
+\immediate\write-1{version 2025-01-23-12:56}
 
 \@ifpackageloaded{xcolor}{}{%
 \RequirePackage{xcolor}
@@ -51,14 +51,6 @@
    \fi%
   }
 \NewConfigure{lstinline}{2}
-\pend:defI\lst at MakeCaption{%
-  \let\lst:addcontentsline\addcontentsline
-  \def\addcontentsline{\gHAdvance\TitleCount by 1
-                       \lst:addcontentsline}%
-}
-\append:defI\lst at MakeCaption{%
-  \let\addcontentsline\lst:addcontentsline
-}
 \ConfigureToc{lol} {}{\empty}{}{\newline}
 \lst at UserCommand\lstlistoflistings{\bgroup%
     \ifdefined\chapter\chapter*{\lstlistlistingname}\else\section*{\lstlistlistingname}\fi%
@@ -105,6 +97,31 @@
 \Configure{lst at Kern}{0.499em}{0.1em}
 \def\lst at outputspace{\HCode{ }}
 
+\def\lst:newaddcontentsline#1#2#3{\gHAdvance\TitleCount by 1
+  {\protect:wrtoc%
+  \protected at edef\:temp{#3}%
+   \protected at edef\:temp{\the\:tokwrite{\string\doTocEntry%
+   \string\toclol% identify this entry as list of listings
+   {\thetable}{\string\csname\space a:TocLink\string\endcsname%
+     {\FileNumber}{\cur:th \:currentlabel}{}{\ifx\:temp\empty\else \ignorespaces #3\fi}}%
+       {}\relax}}\:temp%
+}}%
+\pend:defI\lst at MakeCaption{%
+  \let\lst:addcontentsline\addcontentsline%
+  \let\addcontentsline\lst:newaddcontentsline%
+}
+\append:defI\lst at MakeCaption{%
+  % insert destination ID for the list of listings
+  \Link{}{\cur:th\:currentlabel}\EndLink
+  \let\addcontentsline\lst:addcontentsline
+}
+\ConfigureToc{lol} {}{\empty}{}{\newline}
+\AtBeginDocument{%
+\def\lstlistoflistings{\bgroup%
+    \ifdefined\chapter\chapter*{\lstlistlistingname}\else\section*{\lstlistlistingname}\fi%
+    \TableOfContents[lol]%
+  \egroup}}
+
 \HLet\lst at frameInit=\empty
 \HLet\lst at frameExit=\empty
 



More information about the tex-live-commits mailing list.