# How to make title appear the same with tex4ht as in PDF?

according to How to make tex4ht output a title an answer says

tex4ht works in the same way as ordinary LaTeX with regard to titles

But I want to make title where there is second line in it, with smaller text size. This MWE below works in PDF (using lualatex) but not in tex4ht HTML. With the HTML, the letter sizes all show the same large title size.

\documentclass[12pt,titlepage]{book}
\begin{document}

\title{Top title here\\\vspace{8pt}{\normalsize Summer 2022 edition}\\
\vspace{30pt}{\Large second title below }}
\author{me}
\date{\today}
\maketitle

\end{document}


The PDF is

Compiling using

  make4ht  -ulm default -a debug report.tex "mathjax,htm"


gives this HTML

The issue is not the spacing between the lines in the title. It is that the font size is all the same compared to PDF. It looks like tex4ht ignores the fontsize commands.

Here is the raw HTML generated

<!DOCTYPE html>
<html lang='en-US' xml:lang='en-US'>
Summer 2022 edition
second title below </title>
<meta charset='utf-8' />
<meta content='TeX4ht (https://tug.org/tex4ht/)' name='generator' />
<meta content='width=device-width,initial-scale=1' name='viewport' />
<meta content='report.tex' name='src' />
<script>window.MathJax = { tex: { tags: "ams", }, }; </script>
<script async='async' id='MathJax-script' src='https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js' type='text/javascript'></script>
<div class='maketitle'>

Summer 2022 edition<br />
second title below </h2>
<div class='author'><span class='ec-lmr-12x-x-120'>me</span></div><br />
<div class='date'><span class='ec-lmr-12x-x-120'>April 11, 2022</span></div>

</div>

</body>
</html>


What is needed to make tex4ht accept the different font sizes in the title like with the PDF version?

TL 2021

• That sounds like a futile attempt to me, because HTML can't be predicted, how it is rendered on different machines, in different browsers, under different OSs. If you want to go this route anyway, you'll need to write or adapt your own .css file (Cascaded Style Sheets). Even then the result will remain unpredictable, unless you do it just for yourself. Apr 11 at 18:16

TeX4ht disables HT fonts in titles, so you won't get any formatting information for used fonts. Even if you enabled it, you still won't get vertical spaces. So I would use custom commands that can be configured by TeX4ht instead.

This is a modified TeX file:

\documentclass[12pt,titlepage]{book}
\newcommand\midletitle[1]{\\\vspace{8pt}{\normalsize #1}}
\newcommand\bottomtitle[1]{\\\vspace{30pt}{\Large #1}}

\begin{document}

\title{%
Top title here%
\midletitle{Summer 2022 edition}%
\bottomtitle{second title below }%
}
\author{me}
\date{\today}
\maketitle

\end{document}


And corresponding configuration file:

\Preamble{xhtml}
\renewcommand\midletitle[1]{\space\HCode{\Hnewline<div class="midletitle">}#1\HCode{</div>}}
\renewcommand\bottomtitle[1]{\space\HCode{\Hnewline<div class="bottomtitle">}#1\HCode{</div>}}
\Css{.midletitle{font-size:1rem;margin-top:0.5rem;}}
\Css{.bottomtitle{font-size:1.6rem;margin-top:2rem;}}

\begin{document}
\EndPreamble


It redefines the commands to produce HTML tags that can be styled using CSS. Feel free to modify the CSS code to use font sizes and vertical spaces that suits you.

This is the result: