5

I am generating lots of tables one after the other, and noticed the tables in HTML generated by tex4ht are touching each others, and wanted to have some vertical white space between them to separate them a little.

In PDF, I can use \bigskip or \vspace{\baselineskip} and these work with no problem, but they have no effect in the HTML page produces by tex4ht.

Is there a trick to tell tex4ht to please add some extra vertical space? MWE:

\documentclass[12pt]{scrbook}% 
\usepackage{longtable}
\begin{document}       

\begin{longtable}{|p{.5\textwidth}|}\hline
test
\\\hline
\end{longtable}
\bigskip
\begin{longtable}{|p{.5\textwidth}|}\hline
test
\\\hline
\end{longtable}

\end{document}

The pdf is

Mathematica graphics

And the HTML is make4ht foo.tex

Mathematica graphics

I probably can fix this using .cfg and add some CSS commands or such, but first I wanted to see if it is possible to do in all in LaTeX.

Looking the HTML generated, shows that the \bigskip is just ignored in HTML and has no effect.

TL 2015

5

It is possible to redefine \bigskip to produce empty paragraph with some height. The problem is that \bigskip etc. is used internally in some LaTeX commands and environments, so it could break quite a lot of configurations. It is best to suppress it by default. I would use custom spacing commands instead.

% myspaces.sty 
\newcommand\mybigskip{\bigskip}
\newcommand\mymedskip{\medskip}
\newcommand\mysmallskip{\smallskip}

tex4ht configuration

% myspaces.4ht
\newcommand\:myskip[1]{\ifvmode\HCode{<span class="#1">}\:nbsp\HCode{</span>}\fi}
\renewcommand\mybigskip{\:myskip{bigskip}}
\renewcommand\mymedskip{\:myskip{medskip}}
\renewcommand\mysmallskip{\:myskip{smallskip}}
\Css{span.bigskip{height:2em;margin:0;}}
\Css{span.medskip{height:1em;margin:0;}}
\Css{span.smallskip{height:0:5em;margin:0;}}

modified TeX file:

\documentclass[12pt]{scrbook}% 
\usepackage{longtable}
\usepackage{myspaces}
\begin{document}       

\begin{longtable}{|p{.5\textwidth}|}\hline
test
\\\hline
\end{longtable}
\mybigskip
\begin{longtable}{|p{.5\textwidth}|}\hline
test
\\\hline
\end{longtable}
\mymedskip
hello

\mysmallskip
world
\end{document}

and the result:

enter image description here

3
  • Thanks for the idea but the space generated seems to be the same as ~ (i.e. paragraph) for all settings. i.e. changing the values of heights has no effect. It seems that just emitting a span there causing the space to be generated, period, which is the same amount of space one gets using nbsp. I also think you'd need to make it display: inline-block; to change the margin, but I am no CSS expert by any means :) ps. I think there is a typo there, in the smallskip. 0:5em? I changed it to 0.5em which I think what you meant there.
    – Nasser
    Jun 15 '16 at 21:40
  • @Nasser you are right, it should be inline-block. the constant space is caused by paragraph margins
    – michal.h21
    Jun 15 '16 at 21:51
  • Yes, that worked! thanks for both answers given. Both are good answers.
    – Nasser
    Jun 16 '16 at 10:35
3

You can insert a paragraph containing a blank space ~ which will be converted to the equivalent of &nbsp;.

PDF:

enter image description here

HTML:

enter image description here

\documentclass{article}
\usepackage{longtable}
\begin{document}       

\begin{longtable}{|p{.5\textwidth}|}
  \hline
  test \\
  \hline
\end{longtable}

~

\begin{longtable}{|p{.5\textwidth}|}
  \hline
  test \\
  \hline
\end{longtable}

\end{document}

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.