michal-h21 / make4ht

Build system for tex4ht
132 stars 15 forks source link

tcolorbox and mybox don't works #62

Closed danielezambelli closed 9 months ago

danielezambelli commented 2 years ago

Compiling this document with "pdflatex" works fine, but compiling with "make4ht" (make4ht testmybox.tex -l -u -s -d dist "mathml") produces an error.

I don't understand this error since, some time ago, similar code was compiling correctly.

%----------------------------------------------------- Begin document \documentclass[10pt,a4paper]{memoir} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[italian]{babel}

\usepackage{tcolorbox} \tcbuselibrary{most} % \tcbuselibrary{listingsutf8} % \usepackage{lipsum}

\newtcolorbox{mybox}[2][]{colback=red!5, colframe=red!75!black,fonttitle=\bfseries, colbacktitle=red!75!black,enhanced, attach boxed title to top center={yshift=-1mm}, title={#2},#1}

\newcommand{\inicapitolo}[1]{ \begin{mybox}{In questo capitolo incontrerai:}

1

\end{mybox} }

\begin{document}

\chapter{Problem with tcolorbox}

Before ``mybox''.

\inicapitolo{ In ``mybox''. }

After ``mybox''.

\bigskip \hrule \bigskip Compiling with "pdflatex" works fine, but compiling with "make4ht" (make4ht testmybox.tex -l -u -s -d dist "mathml") produces the error:

\begin{verbatim} [STATUS] make4ht: Conversion started [STATUS] make4ht: Input file: testmybox.tex [WARNING] tocid: char-def module not found [WARNING] tocid: cannot fix section id's [ERROR] htlatex: Compilation errors in the htlatex run [ERROR] htlatex: Filename Line Message [ERROR] htlatex: ./testmybox.tex 31 Missing } inserted. [ERROR] htlatex: ./testmybox.tex 31 Extra }, or forgotten \endgroup. [ERROR] htlatex: ./testmybox.tex 31 Undefined control sequence. [ERROR] htlatex: ? ? File ended while scanning use of \n:@iiiparbox:. [ERROR] htlatex: ? ? Emergency stop. [ERROR] htlatex: ? ? ==> Fatal error occurred, bad output DVI file produced! [FATAL] make4ht-lib: Fatal error. Command htlatex returned exit code 1 \end{verbatim}

I don't understand this error since, some time ago, similar code was compiling correctly.

\end{document}

%----------------------------------------------------- End document

Thank you for your attention and for the helpfulness.

Daniele

michal-h21 commented 2 years ago

Recent update to Tcolobox resulted in fatal error in TeX4ht, but fix for this issue should already be available in TeX Live. I can compile your test file without error, but with a DOM warning. Also the title is missing. The following version of tcolorbox.4ht should fix these issues:

% tcolorbox.4ht (2022-01-09-07:36), generated from tex4ht-4ht.tex
% Copyright 2020-2022 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
% and version 1.3c or later is part of all distributions
% of LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work
% is the TeX4ht Project <http://tug.org/tex4ht>.
%
% If you modify this program, changing the
% version identification would be appreciated.
\immediate\write-1{version 2022-01-09-07:36}

% use custom counter that increments for every \tcolorbox
\newcounter{:tcbcolcount}

\def\:tempa{%
  \stepcounter{:tcbcolcount}%
  % save text and background colors for use in CSS
  \get:xcolorcss{tcbcolbacktitle}\:tcbcolbacktitle%
  \get:xcolorcss{tcbcoltitle}\:tcbcoltitle%
  \get:xcolorcss{tcbcolback}\:tcbcolback%
  \get:xcolorcss{tcbcolframe}\:tcbcolframe%
  \get:xcolorcss{tcbcolupper}\:tcbcolupper%
  % make unique ID for this box
  \def\:tcbcolid{tcolobox-\arabic{:tcbcolcount}}
  % Open box
  \a:tcolorbox%
  % save label, if it is set
  \ifdefined\tcolorbox:label:key%
    \AnchorLabel% save cross-ref destination
    \label{\tcolorbox:label:key}%
    \global\let\tcolorbox:label:key\undefined%
  \fi%
  % open title
  \b:tcolorbox%
  \kvtcb@before@title\kvtcb@title\kvtcb@after@title%
  % close title and open main box
  \c:tcolorbox%
  \box\tcb@upperbox%
  % deal with lower box, if it is set
  \iftcb@hasLower%
    \a:tcolorlowerbox%
    \box\tcb@lowerbox%
    \b:tcolorlowerbox%
  \fi%
  % We need to close box in \tcb@endboxanddraw
}

\HLet\tcb@drawcolorbox\:tempa
% overwrite other versions of box drawing macros
\HLet\tcb@drawcolorbox@standalone\:tempa

% we need to close tcolorbox environment here,
% in the box. otherwise, last paragraph end
% would be ignored and we would get invalid XML
\def\:tempb{\d:tcolorbox\o:tcb@endboxanddraw:}
\HLet\tcb@endboxanddraw\:tempb

% this code prevents emptying of the box title when
% some Tcolorbox options are used
\def\:tempb{}
\HLet\tcb@detach@title@code\:tempb

% require end of paragraph before Tcolorbox
\long\def\:tempb[#1]{\EndP\o:tcb@@icolorbox:[#1]}
\HLet\tcb@@icolorbox\:tempb

\NewConfigure{tcolorbox}{4}
\NewConfigure{tcolorlowerbox}{2}

% we need to save label for a later use
\def\:tempa#1{%
  \xdef\tcolorbox:label:key{#1}%
  \o:tcb@set@label:{#1}%
}
\HLet\tcb@set@label\:tempa

\pend:def\tcb@minipage{\SaveEndP}
\pend:def\tcb@minipage@top{\SaveEndP}
\pend:def\tcb@minipage@bottom{\SaveEndP}
\pend:def\tcb@minipage@center{\SaveEndP}

\Hinput{tcolorbox}
\endinput