[tex4ht] future support for multicols in htlatex?

Nasser M. Abbasi nma at 12000.org
Fri Jul 12 11:56:46 CEST 2013


On 7/12/2013 3:53 AM, Jagath AR wrote:
> 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
>

Thanks!

But I think there is a small issue. Your code is too advanced for me
to know where it is, so I'll show the final result.

When I run this example latex file, using your update .cfg above,
the resulting HTML shows both items of an numeration on the
same line, instead of on separate lines:

--------------------------------
\documentclass{article}%
\usepackage{lipsum}
\usepackage{multicol}
\setlength{\columnsep}{20pt}
\setlength{\columnseprule}{0.01pt}
% notice no need to add \newenvironment{newspaper}{}{} now
% it is in the updated .cfg file
\begin{document}

\begin{multicols}{2}

   \begin{enumerate}
     \item A
     \item B
    \end{enumerate}
    \lipsum[1-10]
    
\end{multicols}

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

Compiled using

htlatex foo.tex "Jagath.cfg"

Where Jagath.cfg is your .cfg code above.

But when I compile the same latex file above using my earlier
.cfg, then the items appear on separate lines as expected.

I am using TL 2013 on Linux.

thanks,
--Nasser


>
> 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
>>
>



More information about the tex4ht mailing list