pandoc icon indicating copy to clipboard operation
pandoc copied to clipboard

Support `\newcolumntype` for LaTeX input

Open Skyost opened this issue 3 years ago • 2 comments

Describe your proposed improvement and the problem it solves.

Currently, Pandoc doesn't support custom column types defined in LaTeX using \newcolumntype. Here's an example.

\newcolumntype{Y}{>{\centering\arraybackslash}X}

\begin{tabularx}{\textwidth}{|l|Y|Y|Y|Y|}
	\hline
	\textbf{Nombre de repas} & 1 & 2 & 3 & 5 \\
	\hline
	\textbf{Prix (en €)} & & & & \\
	\hline
\end{tabularx}

Which, once converted to HTML, gives the following :

<div class="tabularx">
	<p>
		<span>\|l\|X\|X\|X\|X\|</span>
		<strong>Nombre de repas</strong> & 1 & 2 & 3 & 5
		<br>
		<strong>Prix (en €)</strong> & & & &
		<br>
	</p>
</div>

As we can see, it's not converted into a regular HTML table.

Describe alternatives you've considered.

I've tried various hacky things, for example :

\newcolumntype{Y}{>{\centering\arraybackslash}X}
\newcolumntype{\colY}{Y}

\newcommand{\colY}{X} % ONLY PASSED TO PANDOC

\begin{tabularx}{\textwidth}{|l|\colY|\colY|\colY|\colY|}
	\hline
	\textbf{Nombre de repas} & 1 & 2 & 3 & 5 \\
	\hline
	\textbf{Prix (en €)} & & & & \\
	\hline
\end{tabularx}

But it doesn't work. I've also tried to use filters, but unfortunately, it seems that it should be added directly to the reader.

Skyost avatar Jun 06 '22 11:06 Skyost

Pandoc doesn't support whitetabularx either.

does \newcolumntype work with standard LaTeX tables, or is it a tabularx feature?

jgm avatar Jun 06 '22 16:06 jgm

@jgm

Pandoc doesn't support whitetabularx either.

Oh yeah sorry, I meant tabularx ! whitetabularx is just a personal environment (that I don't use with Pandoc). I've edited my question.

does \newcolumntype work with standard LaTeX tables, or is it a tabularx feature?

I think it's part of the array package, but I'm pretty sure that tabularx uses it too.

Skyost avatar Jun 06 '22 16:06 Skyost