make4ht
make4ht copied to clipboard
tabular, tabularx and tabular* all three cannot be set to fill entire linewidth if cell content is empty or less wide than linewidth
Somehow it looks like the column width I configure in the tabular environments is completely ignored in the generated html.
I use the following code. Tried with \begin{tabular} \begin{tabularx} and \begin{tabular*}{\linewidth}{}. The resulting html columns are always scaled to the width of the content if the cell content is not wide enough to force 100% linewidth.
\begin{table}[H]
\centering
\begin{tabular}{|>{\centering\arraybackslash}p{0.3\linewidth}|>{\centering\arraybackslash}p{0.3\linewidth}|>{\centering\arraybackslash}p{0.31\linewidth}|}
\hline
\textbf{Nutrient} & \textbf{kcal\,/\,g} & \textbf{kJ\,/\,g} \\ \hline
Carbohydrate & 4 & 17 \\ \hline
Protein & 4 & 17 \\ \hline
Fat & 9 & 37 \\ \hline
Ethanol & 7 & 29 \\ \hline
\end{tabular}
\caption{Energy equivalents of macronutrients~\cite{Eur:2011}.}
\label{tab:nutrients}
\end{table}
Expected result from pdf:

Actual result in html:

Sorry for the late reply. You can try the p-width
option, it saves the column width to the CSS file:
$ make4ht -m draft sample.tex "p-width"