4

I am trying convert my document to HTML using htlatex. Everything my document (70+ pages) works fine until I look at the tables. The tables generated do not actually follow any kind of table format.

Here is my minimal example to reproduce the problem:

\documentclass[12pt,letter]{memoir}
\begin{document}
\begin{center}
\begin{tabular}{| l | p{9cm} |}
\hline
\textbf{Column Name} & \textbf{Column Description} \\ \hline
Test line 1 & Insert text here (line 1)\\ \hline
Test line 2 & Insert text here (line 2)\\ \hline
Test line 3 & Insert text here (line 3) \\ \hline
\end{tabular}
\end{center}
\end{document}

In command prompt, I use:

htlatex.exe MinimalTest.tex "html,3,info" "" "-dhtml" "--interaction=nonstopmode"

Note: If I run the same command without "nonstopmode", I receive warning that \halign is translated to linear text and an error saying that there is a missing number, which is then treated as zero. I have tried searching for both of these errors, but did not find solutions that worked.

Edit:
So I can't believe I haven't tried it before, but I changed the document class type and it works as it should. However, the problem is that I need to use memoir for the layout of my PDF. Does anyone know of a workaround to make the HTML generation with memoir work correctly?

0

1 Answer 1

1

The problem is that memoir redefines lot of internal latex commands and environments. As tex4ht also redefines these commands and environments with hooks to put the html codes, the two packages clashes. Best solution would be to create memoir configuration for tex4ht, but this would be huge task.

Solution at the moment is to switch to article class when tex4ht is running:

\ifcsname HCode\endcsname%
\documentclass{article}
\else
\documentclass[12pt,letter]{memoir}
\fi
\begin{document}
\begin{center}
\begin{tabular}{| l | p{9cm} |}
\hline
\textbf{Column Name} & \textbf{Column Description} \\ \hline
Test line 1 & Insert text here (line 1)\\ \hline
Test line 2 & Insert text here (line 2)\\ \hline
Test line 3 & Insert text here (line 3) \\ \hline
\end{tabular}
\end{center}
\end{document}

We check for existence of \HCode command, defined by tex4ht.

As memoir defines some new commands, if you use some of them in your document, you also need to provide some definition for them here. For example:

\ifcsname HCode\endcsname%
\documentclass{article}
% If you need to add some xml structure, you can use xml tags right here
\newcommand\sample[1]{%
\leavevmode%
\Tg<strong>#1\Tg</strong>%
}
% But it should suffice to use only normal LaTeX commands
\newcommand\simple[1]{%
\textit{#1}
}
\else
\documentclass[12pt,letter]{memoir}
\fi
\begin{document}
\sample{Hello world} and \simple{hello world}
\end{document}

which produces following paragraph:

<!--l. 16--><p class="noindent" ><strong>Hello world</strong> and <span 
class="cmti-10">hello world</span>
</p>

Note that this is not a clean solution, best option would be to collect these commands in package and create packagename.4ht file with redefinitions for tex4ht, but in the case of simpler documents showed solution should suffice

2
  • Thank you so much! That's exactly the information I needed!
    – Ryan
    May 3, 2012 at 17:18
  • Haha sorry I looked to upvote it but it wouldn't allow me because I didn't have enough reputation. Totally missed the checkmark...
    – Ryan
    May 3, 2012 at 19:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .