3

Can \pbox{max width}{text} be used in tex4ht?

If it can't, is there an alternative that will let me wrap text (manually or automatically) in htlatex. In my reading there was an option \begin{tabular}{|p{1cm}|p{3cm}|} that I would prefer not to use (if it even works - I haven't tested this because I still need this level of control).

When I compile using htlatex I get:

! Argument of \g: Advance has an extra }.
<inserted text>
\par
...
?

This same MWE compiles fine in xelatex.

MWE:

\documentclass{report}
\usepackage[flushleft]{threeparttable}
\usepackage{tabularx}
\usepackage{pbox}
\makeatletter
\newlength\myheight
\setlength{\@fptop}{5pt}    
\def\hlinewd#1{\noalign{\ifnum0=`}\fi\hrule \@height #1     \futurelet\reserved@a\@xhline}   
\providecommand*\setfloatlocations[2]{\@namedef{fps@#1}{#2}}    
\setfloatlocations{table}{htbp} 
\makeatother
\newcommand{\showfontsize}{\f@size{} pt}
\begin{document}
Test document
\begin{table}   
\begin{threeparttable} 
\caption{Demo table}
\label{tbl:Demo}
\begin{tabular}[c]{l c c}

\ifdefined\HCode    \cline{1-3} \else   \hlinewd{1.5pt} \fi

TA & \pbox{3em}{TB NN} & TC \\

\ifdefined\HCode    \cline{1-3} \else   \hlinewd{1.5pt} \fi

$\beta$ & B & C \\

\ifdefined\HCode    \cline{1-3} \else   \hlinewd{1.5pt} \fi

\end{tabular}
\end{threeparttable}
\end{table}
\end{document}
EngBIRD
  • 3,985
  • Even \parbox doesn't work in a cell (without errors), so the cell won't split anyway in the HTML file. Use varwidth instead of \pbox: \usepackage{varwidth} and \begin{varwidth}{3em}TB NN\end{varwidth}. – egreg Jan 17 '15 at 21:26
  • What I'm saying is that \parbox{3em}{TB NN} wraps in pdflatex, but the same doesn't happen in HTML. – egreg Jan 17 '15 at 21:32
  • @egreg Thanks for such a rapid response. I indeed noticed that the 3em doesn't work in HTML but this environment is sufficient to permit a // wrap so at the moment, that will certainly suffice. – EngBIRD Jan 17 '15 at 21:38

1 Answers1

4

I don't know why \pbox doesn't work, but you can use varwidth, instead.

Here's an example:

\documentclass{report}
\usepackage[flushleft]{threeparttable}
\usepackage{tabularx}
\usepackage{varwidth}
\makeatletter
\newlength\myheight
\setlength{\@fptop}{5pt}    
\def\hlinewd#1{\noalign{\ifnum0=`}\fi\hrule \@height #1     \futurelet\reserved@a\@xhline}   
\providecommand*\setfloatlocations[2]{\@namedef{fps@#1}{#2}}    
\setfloatlocations{table}{htbp} 
\makeatother
\newcommand{\showfontsize}{\f@size{} pt}
\begin{document}
Test document
\begin{table}   
\begin{threeparttable} 
\caption{Demo table}
\label{tbl:Demo}
\begin{tabular}[c]{l c c}

\ifdefined\HCode    \cline{1-3} \else   \hlinewd{1.5pt} \fi

TA & \begin{varwidth}{3em}TB\\ NN\end{varwidth} & TC \\

\ifdefined\HCode    \cline{1-3} \else   \hlinewd{1.5pt} \fi

TA & \begin{varwidth}{20em}TB\\ NN\end{varwidth} & TC \\

\ifdefined\HCode    \cline{1-3} \else   \hlinewd{1.5pt} \fi

$\beta$ & B & C \\

\ifdefined\HCode    \cline{1-3} \else   \hlinewd{1.5pt} \fi

\end{tabular}
\end{threeparttable}
\end{table}
\end{document}

Note that the second case has a maximum width of 20em, but in the screenshot of the HTML rendering below it occupies the same space as the first instance.

enter image description here

egreg
  • 1,121,712