[tex4ht] future support for multicols in htlatex?

Jagath AR jagathar at gmail.com
Fri Jul 12 10:53:33 CEST 2013


Hi Nasser,
Your configuration file can be slightly modified as given below to get *
multicols* work as you have expected. The optional argument of *multicols *is
not take care of at the moment.

----------------
\Preamble{ext=htm,pic-align}

\begin{document}
\EndPreamble

\catcode`\:11
\catcode`\@11

% Added to fix the opening and closing <p> tags
\Configure{HtmlPar}
  {\EndP\HCode{<!--l. \the\inputlineno-->%
<p \csname a:!P\endcsname
         class="no\ifHCond par\else indent\fi" \a:LRdir>}}
  {\EndP\HCode{<!--l. \the\inputlineno-->%
<p \csname a:!P\endcsname
        class="\ifdim \parindent=\z@ no\fi indent" \a:LRdir>}}
  {{\Tg</p>}}
  {{\Tg</p>}}%

\renewenvironment{multicols}[1]{\IgnorePar\EndP%
\HCode{<div class="newspaper}#1\HCode{">}
\expandafter\ifx\csname .newspaper#1\endcsname\relax%
\Css{.newspaper#1 p:first-child { margin-top: 0em; }}
\Css{.newspaper#1 {
   -moz-column-count:#1; /* Firefox */
   -webkit-column-count:#1; /* Safari and Chrome */
   column-count:#1;
   -moz-column-gap:10px; /* Firefox */
   -webkit-column-gap:10px; /* Safari and Chrome */
   column-gap:10px;
   -moz-column-rule:1px outset \#F8F8F8 ; /* Firefox */
   -webkit-column-rule:1px outset \#000000; /* Safari and Chrome */
   column-rule:1px outset \#000000;
}}
\expandafter\gdef\csname .newspaper#1\endcsname{1}%
\fi\ShowPar\par}
{\EndP\HCode{</div>}}
\ConfigureEnv{multicols}{}{}{}{}

\endinput
----------------

I have tested this with the following TeX code:

-----------------
\documentclass{article}%
\usepackage{lipsum}
\usepackage{multicol}
\setlength{\columnsep}{20pt}
\setlength{\columnseprule}{0.01pt}
\newenvironment{newspaper}{}{}
\begin{document}

    \lipsum[1-2]

  \begin{multicols}{6}
    \lipsum[1-5]
  \end{multicols}

    \lipsum[1-2]

  \begin{multicols}{4}
    \lipsum[1-5]
  \end{multicols}

    \lipsum[1-2]

  \begin{multicols}{2}
    \lipsum[1-5]
  \end{multicols}

    \lipsum[1-2]

  \begin{multicols}{4}
    \lipsum[1-5]
  \end{multicols}

\end{document}
-----------------

You can use this workaround, while the developers came up with possible fix.

Regards
Jagath


On 12 July 2013 13:02, Nasser M. Abbasi <nma at 12000.org> wrote:

> Ok, here is my poor's man implementation of multiple columns
> support in htlatex.
>
> compile using
>
>         htlatex foo.tex "my.cfg"
>
> where my.cfg is
>
> ---------------------
> \Preamble{ext=htm,pic-align}
>
> \ConfigureEnv{newspaper}
> {\HCode{<div class="newspaper">}}
> {\HCode{</div>}}
> {}{}
> \begin{document}
> \EndPreamble
>
> \Css{.newspaper {
>    -moz-column-count:2; /* Firefox */
>    -webkit-column-count:2; /* Safari and Chrome */
>
>    column-count:2;
>    -moz-column-gap:10px; /* Firefox */
>    -webkit-column-gap:10px; /* Safari and Chrome */
>    column-gap:10px;
>    -moz-column-rule:1px outset \#F8F8F8 ; /* Firefox */
>    -webkit-column-rule:1px outset \#000000; /* Safari and Chrome */
>    column-rule:1px outset \#000000;
> }}
> ---------------------------
>
> and foo.tex is
>
>
> -------------------
> \documentclass{article}%
> \usepackage{lipsum}
> \usepackage{multicol}
> \setlength{\columnsep}{20pt}
> \setlength{\columnseprule}{0.**01pt}
> \newenvironment{newspaper}{}{}
> \begin{document}
>
> \ifdefined\HCode
>   \begin{newspaper}
> \else
>   \begin{multicols}{2}
> \fi
>
>     \lipsum[1-10]
>
> \ifdefined\HCode
>   \end{newspaper}
> \else
>   \end{multicols}
> \fi
>
> \end{document}
> -----------------------
>
> The div is hardcoded to 2 columns in HTML for now and the
> other properties are hardcoded.
>
> One can make newenv. for 3 columns, or pass the number of
> columns as argument, but I am not good in Latex to do that
> yet.
>
> So, the above now generates HTML with 2 columns. I tried
> it on firefox, chrome and IE and it all works. And pdflatex
> works as before.
>
> This is better for me than having to use tabular with 2 columns
> to get the same effect in HTML.
>
> --Nasser
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/tex4ht/attachments/20130712/fa0d46a0/attachment-0001.html>


More information about the tex4ht mailing list