# htlatex - need help converting latex to html

I am trying to convert a set of tex file to html. The attached code generates perfect pdf. While it gives the following error with htlatex.

error:

l.259 --- TeX4ht warning --- \halign translated into linear text ---
! Missing number, treated as zero.
\ar:cnt
l.259 ...rigraph.sequences}{Trigraph}{Replacement}


related files can be seen at https://github.com/ramneek-handa/draft/source

Here is the minimal example:

\documentclass[ebook,10pt,oneside,openany,final]{memoir}

\usepackage[american]
{babel}        % needed for iso dates
\usepackage[iso,american]
{isodate}      % use iso format for dates
\usepackage[final]
{listings}     % code listings

\setcounter{totalnumber}{10}

% Base definitions for tables
\newenvironment{TableBase}
{
\renewcommand{\tcode}[1]{{\CodeStylex{##1}}}
\newcommand{\topline}{\hline}
\newcommand{\capsep}{\hline\hline}
\newcommand{\rowsep}{\hline}
\newcommand{\bottomline}{\hline}

%% vertical alignment
\newcommand{\rb}[1]{\raisebox{1.5ex}[0pt]{##1}}    % move argument up half a row

\newcommand{\lhdr}[1]{\lhdrx{1}{##1}}              % set header for single left column
\newcommand{\chdr}[1]{\chdrx{1}{##1}}              % set header for single center column
\newcommand{\rhdr}[1]{\rhdrx{1}{##1}}              % set header for single right column
\newcommand{\ohdr}[1]{\ohdrx{1}{##1}}
\newcommand{\br}{\hfill\break}                     % force newline within table entry

%% column styles
\newcolumntype{x}[1]{>{\raggedright\let\\=\tabularnewline}p{##1}}  % word-wrapped ragged-right
% column, width specified by #1
% \newcolumntype{m}[1]{>{\CodeStyle}l{##1}}              % variable width column, all entries in CodeStyle
\newcolumntype{m}[1]{l{##1}}                           % variable width column, all entries in CodeStyle
}
{
}

% General Usage: TITLE is the title of the table, XREF is the
% cross-reference for the table. LAYOUT is a sequence of column
% type specifiers (e.g. cp{1.0}c), without '|' for the left edge
% or right edge.

% usage: \begin{floattablebase}{TITLE}{XREF}{COLUMNS}{PLACEMENT}
% produces floating table, location determined within limits
% by LaTeX.
\newenvironment{floattablebase}[4]
{
\begin{TableBase}
\begin{table}[#4]
\caption{\label{#2}#1}
\begin{center}
\begin{tabular}{|#3|}
}
{
\bottomline
\end{tabular}
\end{center}
\end{table}
\end{TableBase}
}

% usage: \begin{floattable}{TITLE}{XREF}{COLUMNS}
% produces floating table, location determined within limits
% by LaTeX.
\newenvironment{floattable}[3]
{
\begin{floattablebase}{#1}{#2}{#3}{htbp}
}
{
\end{floattablebase}
}

\newcommand{\CodeStylex}[1]{\texttt{#1}}
\newcommand{\tcode}[1]{\CodeStylex{#1}}

\begin{document}
\begin{floattable}
{Potential \tcode{setlocale} data races}
{tab:setlocale.data.races}
{lllll}
\topline

\tcode{fprintf}     &
\tcode{isprint}     &
\tcode{iswdigit}    &
\tcode{localeconv}  &
\tcode{tolower}     \\

\end{floattable}

\end{document}

-
Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. Please also include details on how exactly you're doing the conversion. –  doncherry Dec 3 '12 at 7:36
Thanks! Unfortunately, this is by no means a minimal working example. Please remove all packages that are not strictly necessary to reproduce the problem, and don't use any \input statements, since they just unnecessarily complicate the document for debugging. (If the problem should turn out to be related to \input, that'd be different, of course.) A MWE will look very different from your actual document. Since your document seems to be pretty big, take a look at the link on MWEs I posted, it'll tell you how to efficiently boil your document down to a MWE. –  doncherry Dec 3 '12 at 7:53
thanks.. i will try to work on the MWE in coming few days and update the question.. –  RamneekHanda Dec 3 '12 at 8:46
added the MWE.. any help please? –  RamneekHanda Dec 4 '12 at 15:12
so i figured if i replace \hline with blanks it ourputs as table but doesnt show the bounding lines.. any help on how to replace them so that the table is correctly formatted for html? –  RamneekHanda Dec 4 '12 at 16:48

Well, there are some errors caused by the lack of support for memoir in tex4ht. We fixed that in another question. Now you need to add support for your macros. To do that, you should separate them in package, for example ramneek.sty

\setcounter{totalnumber}{10}

% Base definitions for tables
\newenvironment{TableBase}
{
\renewcommand{\tcode}[1]{{\CodeStylex{##1}}}
\newcommand{\topline}{\hline}
\newcommand{\capsep}{\hline\hline}
\newcommand{\rowsep}{\hline}
\newcommand{\bottomline}{\hline}

%% vertical alignment
\newcommand{\rb}[1]{\raisebox{1.5ex}[0pt]{##1}}    % move argument up half a row

\newcommand{\lhdr}[1]{\lhdrx{1}{##1}}              % set header for single left column
\newcommand{\chdr}[1]{\chdrx{1}{##1}}              % set header for single center column
\newcommand{\rhdr}[1]{\rhdrx{1}{##1}}              % set header for single right column
\newcommand{\ohdr}[1]{\ohdrx{1}{##1}}
\newcommand{\br}{\hfill\break}                     % force newline within table entry

%% column styles
\newcolumntype{x}[1]{>{\raggedright\let\\=\tabularnewline}p{##1}}  % word-wrapped ragged-right
% column, width specified by #1
% \newcolumntype{m}[1]{>{\CodeStyle}l{##1}}              % variable width column, all entries in CodeStyle
\newcolumntype{m}[1]{l{##1}}                           % variable width column, all entries in CodeStyle
}
{
}

% General Usage: TITLE is the title of the table, XREF is the
% cross-reference for the table. LAYOUT is a sequence of column
% type specifiers (e.g. cp{1.0}c), without '|' for the left edge
% or right edge.

% usage: \begin{floattablebase}{TITLE}{XREF}{COLUMNS}{PLACEMENT}
% produces floating table, location determined within limits
% by LaTeX.
\newenvironment{floattablebase}[4]
{
\begin{TableBase}
\begin{table}[#4]
\caption{\label{#2}#1}
\begin{center}
\begin{tabular}{|#3|}
}
{
% \bottomline
\end{tabular}
\end{center}
\end{table}
\end{TableBase}
}

% usage: \begin{floattable}{TITLE}{XREF}{COLUMNS}
% produces floating table, location determined within limits
% by LaTeX.
\newenvironment{floattable}[3]
{
\begin{floattablebase}{#1}{#2}{#3}{htbp}
}
{
\end{floattablebase}
}

\newcommand{\CodeStylex}[1]{\texttt{#1}}
\newcommand{\tcode}[1]{\CodeStylex{#1}}


Now you need to add configuration for tex4ht, so create file ramneek.4ht. This file is loaded automatically when you use package ramneek.

\NewConfigure{TableBase}{2}
\ConfigureEnv{TableBase}{%
\a:TableBase
}{\b:TableBase}{
\renewcommand\topline{}
\renewcommand\bottomline{}
}{}

\Configure{TableBase}{\HCode{<div class="TableBase">\Hnewline}}{\HCode{</div>\Hnewline}}

\Css{
.TableBase .tabular td{
border-top:1px solid black;
border-bottom:1px solid black;
}
}


This code patches environment TableBase, it redefines macros \topline and \bottomline which caused problems and it insert configurable hooks. With \Configure{TableBase} we configure this hook to insert <div class=TableBase> and with \Css command you can configure appereance of the table using cascading stylesheets however you want.

-
thanks.. will check it tomorrow and accept if it works.. –  RamneekHanda Dec 5 '12 at 14:04
Did i tell you - you are awesome? :). tx so much.. –  RamneekHanda Dec 6 '12 at 9:42