Using texlive 2013. The following MWE compiles fine with pdflatex, but gives the error:
./foo.aux) [1]
Chapter 1.
! LaTeX Error: \theHchapter undefined.
when I run it using the command:
htlatex foo.tex
Here is the file
\documentclass[12pt]{report}
\usepackage[toc,page]{appendix}
\usepackage{hyperref}
\begin{document}
\chapter{first}
some text
\begin{appendices}
\chapter{some chapter}
some text again
\end{appendices}
\end{document}
I really do not have to use the appendix package if that is the problem, I just wanted a way to obtain an Appendix
title, before each chapter I add as an appendix. Without this package, I do not get this Appendix
title on its own.
>htlatex foo.tex
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013)
restricted \write18 enabled.
entering extended mode
Update
Putting the new file appendix.4ht
(thanks to michal.h21
answer below) in $TEXMFHOME/tex/latex/tex4ht
worked. Strange why /usr/local/texlive/2013/texmf-dist/tex/generic/tex4ht
does not work since that is where all the other .4ht files are?
But there are still issues with toc.
The table of contents links is not formatted correctly. Clicking on the appendix link from toc opens a web page that also contains the last section from the main body inside it. And clicking on the last section of the body opens a page that contains the appendix in it. So it seems that appendix is treated as part of the last section that appears in the body, instead of being a separate section on its own web page.
Here is a MWE example:
\documentclass{article}
\usepackage[toc,page]{appendix}
\usepackage{hyperref}
\begin{document}
\author{me}
\title{title}
\date{\today}
\maketitle
\tableofcontents
\section{first}
some text
\section{two}
some text in section 2
\begin{appendices}
\section{somesection inside appendices}
some text again
\end{appendices}
\end{document}
Now compiled with
htlatex foo.tex "htm,2" %now split 2 option to see the problem
update: To answer @egreg on using mktexlsr
, I did now use that. As root, but still htlatex does not see the file appendix.4ht when this file is in /usr/local/texlive/2013/texmf-dist/tex/generic/tex4ht
with all the other .4ht files. It only works when this file is in local $TEXMFHOME/tex/latex/tex4ht
which is really strange. Here is screen shot:
Best Answer
It means that
\theHchapter
in undefined whentex4ht
is running andappendix.sty
tries to redefine it. Quick fix is to provideappendix.4ht
file, where\theHchapter
is defined:\ifdefined
is used to prevent defining of the commands if they are already defined. Also\theHsection
is defined as it would probably also raise issues.We can also provide some redefinitions for providing configurable hooks, so final version of
appendix.4ht
is:Generated code:
Edit: Version which prints Appendices as
\section*
or\chapter*