michal-h21 / make4ht

Build system for tex4ht
137 stars 15 forks source link

tabular, tabularx and tabular* all three cannot be set to fill entire linewidth if cell content is empty or less wide than linewidth #112

Open cjohn001 opened 1 year ago

cjohn001 commented 1 year ago

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
michal-h21 commented 11 months ago

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"