[tex4ht] tex4ht + hyperref + mwbk + secnumdepth issue

Deimantas Galcius deimi at vtex.lt
Wed Jun 18 08:02:01 CEST 2014


Sylwester,
I think it's a bug  that should be fixed in mwbk.4ht.
(probably also reported as such at https://puszcza.gnu.org.ua/projects/tex4ht/)

Tracing down the error, I see that \mw at normalheading macro gives trouble.

\newcommand*\mw at normalheading{%
   \if\mw at HeadingBreakBefore \hrule\@height\z@\nobreak
      \else \addpenalty\@secpenalty \fi
   \addvspace{\csname \mw at HeadingType @preskip\endcsname}%
................

The condition is TRUE if section is numbered, and FALSE if section is unnumbered.
In latter case \addpenalty is excuted and gives error if section is not in vertical mode.
(and most probably hyperref's hooks introduce code that puts section in horizontal mode).

possible fix in /mwbk.4ht/:
\let\:o:mw at normalheading\mw at normalheading
\pend:def\mw at normalheading{\def\mw at HeadingBreakBefore{00}}

This fix  sets  the if statement to be always TRUE.
Another possible fix would be redefine \mw at normalheading macro
dropping first two lines (I assume that these two lines are irrelevant to html output)

MWE for testing:
\documentclass{mwbk}
\usepackage{hyperref}
\begin{document}
\section*{bug}
\subsection*{foo}
\subsubsection*{bar}
\end{document}


Regards,

-- 
Deimantas

On 6/17/2014 11:59 AM, Sylwester Arabas wrote:
> Hi Deimantas,
>
> Thanks a lot! It works!
> For the record: I had to also add:
>
> \def\subsection at flags{0100}
> \def\subsubsection at flags{0100}
>
> Is it (or should it be) documented anywhere?
>
> Regards,
> Sylwester
>
> On 17/06/14 07:10, Deimantas Galcius wrote:
> > Hi Sylwester,
> >
> > try this way:
> >
> >   \documentclass{mwbk}
> >      \usepackage[tex4ht]{hyperref}
> >      \setcounter{secnumdepth}{0}
> > *\makeatletter**
> > **  \def\section at flags{0100}**
> > **  \makeatother*
> >      \begin{document}
> >        \section{bug}
> >      \end{document}
> >
> > --
> > Deimantas
> >
> > On 6/16/2014 2:39 PM, Sylwester Arabas wrote:
> >> Dear All,
> >>
> >> Having a problem compiling a large "mwbk" document with tex4ht using
> >> hyperref, I've managed to track down the problem to the following
> >> short code:
> >>
> >>     \documentclass{mwbk}
> >>     \usepackage[tex4ht]{hyperref}
> >>     \setcounter{secnumdepth}{0}
> >>     \begin{document}
> >>       \section{bug}
> >>     \end{document}
> >>
> >> When trying to compile using htlatex, it gives the following error:
> >>
> >>     ...
> >>     No file bug.aux.
> >>     ! LaTeX Error: Something's wrong--perhaps a missing \item.
> >>     See the LaTeX manual or LaTeX Companion for explanation.
> >>     Type  H <return>  for immediate help.
> >>      ...
> >>     l.5   \section{bug}
> >>
> >>
> >> Changing mwbk into book helps. Removing hyperref inclusion helps.
> >> Removing setcounter helps as well. Compiling with "pdflatex" instead
> >> of htlatex helps.
> >>
> >> Any help very welcome!
> >> Thanks,
> >> Sylwester
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/tex4ht/attachments/20140618/5bf5842d/attachment.html>


More information about the tex4ht mailing list