maranget / hevea

Hevea is a fast latex to html translator
http://hevea.inria.fr
Other
97 stars 12 forks source link

Handle empty \chaptername #30

Closed cspiel closed 3 years ago

cspiel commented 4 years ago

If we define an empty \chaptername with LaTeX in styles report or book, the (non-breaking) space between \chaptername and \thechapter goes away, too. That way chapter numbers are set flush right as are all section numbers. Hevea keeps the space, which skews the layout. The following patch fixes this problem.

The patch is so minute that it does not warrant a PR -- IMHO.

--- a/html/book.hva
+++ b/html/book.hva
@@ -1,5 +1,6 @@
 \ifstyleloaded\relax
 \else
+\input{ifthen.hva}
 \input{bookcommon.hva}
 \newcommand{\@book@attr}[1]{\@secid\envclass@attr{#1}}
 \@makesection
@@ -10,7 +11,8 @@
 \newstyle{.part}{margin:2ex auto;text-align:center}
 \@makesection
   {\chapter}{-1}{chapter}
-   {\@open{h1}{\@book@attr{chapter}}}{\chaptername~\thechapter}{\quad}{\@close{h1}}
+   {\@open{h1}{\@book@attr{chapter}}}%
+   {\ifthenelse{\equal{\chaptername}{}}{}{\chaptername~}\thechapter}{\quad}{\@close{h1}}
 \@makesection
   {\section}{0}{section}
   {\@open{h2}{\@book@attr{section}}}{\thesection}{\quad}{\@close{h2}}%