1

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

enter image description here

Compiling using

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

gives this HTML

enter image description here

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'> 
<head><title>Top title here
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' /> 
<link href='report.css' rel='stylesheet' type='text/css' /> 
<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>  
</head><body>
<div class='maketitle'>

<h2 class='titleHead'>Top title here<br />
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

1
  • 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.
    – MS-SPO
    Apr 11 at 18:16

1 Answer 1

1

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:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.