make4ht icon indicating copy to clipboard operation
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

Open cjohn001 opened this issue 1 year ago • 1 comments

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:

Bildschirm­foto 2023-03-07 um 18 53 11

Actual result in html:

Bildschirm­foto 2023-03-07 um 18 53 52

cjohn001 avatar Mar 07 '23 17:03 cjohn001

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"

michal-h21 avatar Nov 08 '23 14:11 michal-h21