TeX4ht and Multicolumn Layout

Nasser M. Abbassi had filed a feature request at TeX4ht project for multicolumn support in TeX4ht which is lacking at the moment. This link provides the latest specifications of W3C relating to multicolumn layout in HTML which some of the mainstream browsers support in varying degrees. Our initial efforts are pointed towards multicol package so that TeX4ht provides enough hooks to generate output with multicolumn layout as envisaged in LATEX by multicol package. Support for \twocolumn still remains to be done, though.

Approach to the Problem

W3C provides different kinds of CSS properties to bring about multicolumn layout in HTML. These are briefly listed below:

  1. column-count: number of columns
  2. column-width: width of the columns
  3. column-gap: gap between columns
  4. column-rule-color: color of separator rule
  5. column-rule-width: width of separator rule
  6. column-rule-style: style of separator rule
  7. column-span: should the entry span all columns
  8. column-fill: should the multicolumn layout be balanced or ragged
  9. column-break: directive for breaks in print media

We have more or less equivalent commands in multicol package and are listed below:

  1. \columnbreak: forced break in a column
  2. \columnsep: gap between columns
  3. \columnseprule: rule width
  4. \columnseprulecolor: rule color
  5. \flushcolumns: balanced columns
  6. \raggedcolumns: unbalanced columns
  7. \begin{multicols}{<num>}: beginning of multicolumn enviromnemt
  8. \end{multicols}: end of multicolumn environment
  9. \multicoltolerance: no effect on HTML output

Some of the CSS properties do not have equivalent commands in multicol package. For instance, column-width can be specified in CSS as either auto or as a legal dimension, but in multicol, it is always automatically computed. Hence, we can safely ignore such properties. Conversely, certain multicol commands like \multicoltolerance has no effect in HTML, so we can ignore such commands in the source documents.

We have written the multicol.4ht to redefine the related multicol commands to generate the equivalent CSS properties for HTML output so that multicolumn layout is visually similar to PDF output.

Usage

The multicolumn layout can be tailored using \Configure command on various items as given below:

\Configure{columngap}{\thecolumnsep}

\columngap will default to the dimension provided by multicol’s \columnsep command. However, if you want to override, you can make use of the above command. The legal values admissible are any valid \dimen or simply \normal which is considered to be 1em.

\Configure{columnrulewidth}{\thecolumnseprule}

\columnrulewidth defaults to LATEX dimension provided by \columnseprule which can be overridden by the above command. The legal values are thin | medium | thick or any valid dimension.

\Configure{columnrulecolor}{#555;}

You can specify any valid color for \columnrulecolor. Default is provided above.

\Configure{columnrulestyle}{outset}

\columnrulestyle has no equivalent in multicol. Specify rule style with the above hook. Legal values are provided below: none, hidden, dotted, dashed, solid, double, groove, ridge, inset, outset,

\Configure{columnspan}{none}

\columnspan has no equivalent command in multicol. This is to provide CSS directive of any column spanning all the columns, the default value being none. Alternate value is all.

\Configure{columnfill}{balance}

\columnfill does the job what \raggedcolumns and \flushcolumns do in multicol. balance, meaning, balanced columns is the default value, the other being auto.

\Configure{multicols}{columns}

This command provides the name of class attribute of the multicolumn chunk of text. You can assign any string of your choice, the default is columns.

Example

Here is an example of a working document that can be used to test these newly introduced features.

\documentclass[a4paper]{article}
\usepackage{xspace}
\usepackage{lipsum}
\usepackage[margin=1cm,ignoreall]{geometry}
\usepackage{multicol}
\columnseprule=.1pt
\columnsep=1em

\begin{document}

\parindent=0pt
% For webkit browsers Chrome, for example,
% kindly remove comment marks from two lines below:
%
% \Configure{columnrulecolor}{#000;}
% \Configure{columnrulewidth}{1px}

\title{Support for Multicolumn Layout in TeX4ht}
\author{TeX4ht Project Team}
\maketitle

\lipsum[1]
\begin{multicols}{2}[section{Testing the Section Heading}]
\lipsum[2-8]
\end{multicols}
\lipsum[1]
\begin{multicols}{3}[section{Three Column Layout}]
\lipsum[2-8]
\end{multicols}
\lipsum[1]
\begin{multicols}{4}[section{Four Column Layout}]
\lipsum[2-8]
\end{multicols}
\lipsum[1]
\ifx\HCode\undefined\raggedright\fi
\begin{multicols}{11}[section{More Than Ten Columns limit of
    multicol package}]
\lipsum[2-8]
\end{multicols}

\end{document}

The HTML output can be viewed here.

A tarball of all required *.4ht files, source, auxiliary and output files can be downloaded from here.

W3C References

More detailed information is available at Property Index page provided at Word Wide Web Consortium web site. (Generated by Org mode 8.0.6 in Emacs 24.3.1.)

2 Responses to “TeX4ht and Multicolumn Layout”


  • Keep me in the loop as necessary as I’m currently again looking further into multicol enhancements or in general into multi column typesetting questions – frank

  • Frank Mittelbach: Keep me in the loop as necessary as I’m currently again looking further into multicol enhancements or in general into multi column typesetting questions – frank

     

    Sure, I will. The immediate point that comes to my mind is the floats management. Floats spanning only single column in a multi column environment is not supported. Similarly, floats spanning two columns in a three column situation will be a great asset. Not sure, if this shall be assigned to floats package or multicol package. This could be too much demanding, but if these supports are brought into multicol, that would eliminate some of the nagging problems in TeX that we face nowadays. — cvr

Leave a Reply