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

From: Pranshu <[email-masked]>
Date: Fri, 07 Jun 2024 17:00:13 +1000

[1. application/pdf; thing.pdf]...

All good, basiclly in latex a equation is formatted in something like:
$\Delta Q = r^2$
Will become something like: "ΔQ = r²"

The key takeway is the dollar symbol is needed to tell the latex
compiler that it is typesetting maths.

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.  The rendered pdf from the
above latex is attached, you can see that the equations were not
rendered properly.  This is because the dollar signs and carets were
automaticly escaped

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:

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.

Kind Regards
Pranshu

Eli Zaretskii <[email-masked]> writes:

>> Cc: [email-masked]
>> From: Pranshu <[email-masked]>
>> Date: Tue, 04 Jun 2024 21:22:00 +1000
>> 
>> When table.el exports to latex, charecters like '$' are all escaped.
>> This makes table.el tables practically useless for any sorts of latex
>> export.
>> 
>> Attached is a diff that adds a variable that controls what should be
>> escaped.
>
> Could you please explain in some more details the problem and the
> solution?  I'm afraid I couldn't follow your logic, perhaps because
> I'm not a frequent user of LaTeX.
>
> Thanks.