Subject: Re: bug#71364: Fix Table.el export

From: Eli Zaretskii <[email-masked]>
Date: Fri, 07 Jun 2024 13:54:48 +0300

> From: Pranshu <[email-masked]>
> Cc: [email-masked]
> Date: Fri, 07 Jun 2024 17:00:13 +1000
> 
> Now, the problem is if you have a table like the following:
> +---------+-------+--------+
> |$\delta$ |x      |y       |
> +---------+-------+--------+
> |x        | $x^2$ |$xy$    |
> +---------+-------+--------+
> |y        | $xy$  | $y^2$  |
> +---------+-------+--------+
> 
> Now if you export to latex using "C-^" or M-x table-generate-source you
> get:
> 
> % This LaTeX table template is generated by emacs 30.0.50
> \begin{tabular}{|l|l|l|}
> \hline
> \$$\backslash$delta\$ & x & y \\
> \hline
> x & \$x\^2\$ & \$xy\$ \\
> \hline
> y & \$xy\$ & \$y\^2\$ \\
> \hline
> \end{tabular}
> 
> The problem with this is that since the all the dollar and caret signs
> are all escaped, the maths will not render.

So you are saying that exporting to latex is basically completely
broken in the current code?  Is that command use to export only to
latex, or is the fact that the export is to latex is just one of the
possibilities?

> What the diff does, is that it adds a variable that allows the user to
> change what will be escaped.  Also as you can see in the above latex
> table, the backslash had to be escaped in a different way, so using one
> regexp variable would not be enough.  That is why the solution contains
> a variable called 'table-source-latex-escape-characters', which is a
> cons cell with the documentation:

Why would a user need to customize this on the level of characters?
Shouldn't there be a single boolean that causes latex-specific
characters to be escape or not to be escaped, all of them or none?

> A cons cell containing which charecters to escape in the latex source
> of ‘table-generate-source’.  The head of the list, if non-nil contains a
> regexp that matches all text that is to be adding a preceding backslash
> to the matching text. If nil, no non-backslash charecters will be
> escaped.  The tail, if non-nil, escapes all the backslashes in the latex
> source.

What is the purpose of the "tail", i.e. why would a user want to
escape all the backslashes?

Thanks.