[tex4ht] How to make tex4ht insert <BR> without adding <P> also?

Nasser M. Abbasi nma at 12000.org
Mon Sep 23 06:57:27 CEST 2024


I want to insert <BR> at specific place in HTML. Directly into the html.

tex4ht does that using \HCode, but it puts the <BR> inside <P> which now
makes the vertical space much larger than it would be with just <BR> on
its own.

Here is MWE. I do not want to use .cfg or .4ht or any other tricks.
I simply want to insert raw <BR> directly from the latex at the location
I want.

----------------
\documentclass[12pt]{article}%	
\begin{document}
\ifdefined\HCode	
\TocAt{section,subsection}
\fi
\section{A}
% want <BR> here in HTML which will be below TOC of section
\ifdefined\HCode
\HCode{<BR>}
\fi
%
\subsection{A1}
some text
  	
\end{document}
------------------------

Compiled using

make4ht -ulm default -a debug A.tex 'mathjax,htm'

Gives the A.htm as this

<div class='sectionTOCS'>
<span class='subsectionToc'>1.1 <a href='#a1' id='QQ2-1-2'>A1</a></span>
</div>
<!-- l. 13 --><p class='indent'>   <BR /></p>

The TOC is because I asked it to generate toc for each section.

THe problem is the line below which is

<!-- l. 13 --><p class='indent'>   <BR /></p>

I wanted it to be just

       <BR>

Why? Becuase now the vertical space is less. Which is what I want.

<p class='indent'>   <BR /></p>

Makes the vertical space more. I also did not ask it to put <BR>
inside <P> so why did it do it?

Is there a way to tell tex4ht to insert <BR> using \HCode from
inside latex like I did, without it being inside <P> also?

Thank you,
--Nasser


More information about the tex4ht mailing list.