XmacsLabs / mogan

Mogan STEM Suite (based on GNU TeXmacs): Enjoy exploring science and technology!
https://mogan.app
GNU General Public License v3.0
386 stars 31 forks source link

[43_6] `cwith` tags in TeXmacs blocks are not translated properly when exporting to LaTeX #483

Open yzh119 opened 1 year ago

yzh119 commented 1 year ago

Problem

In TeXmacs, we can use "Join selected cells" to join several cells to form a large cell in a block(table), this is a common operation in scientific papers.

e.g. here is the original block:

image

after joining c/d and e/f together, the block looks like this:

image

if we look into the source .tm code before and after the join operation:

before-join:

<block|<tformat|<cwith|1|1|3|3|cell-row-span|1>|<cwith|1|1|3|3|cell-col-span|1>|<cwith|2|2|1|1|cell-row-span|1>|<cwith|2|2|1|1|cell-col-span|1>|<table|<row|<cell|a>|<cell|b>|<cell|c>|<cell|d>>|<row|<cell|e>|<cell|f>|<cell|g>|<cell|h>>>>>

after-join:

<block|<tformat|<cwith|1|1|3|3|cell-row-span|1>|<cwith|1|1|3|3|cell-col-span|2>|<cwith|2|2|1|1|cell-row-span|1>|<cwith|2|2|1|1|cell-col-span|2>|<table|<row|<cell|a>|<cell|b>|<cell|c>|<cell|d>>|<row|<cell|e>|<cell|f>|<cell|g>|<cell|h>>>>>

The only difference exists in cell-col-span where the "after-join" block indicates the cell at (1,3) and (2,1) should have column width 2. Both blocks have the same content: <table|<row|<cell|a>|<cell|b>|<cell|c>|<cell|d>>|<row|<cell|e>|<cell|f>|<cell|g>|<cell|h>>> though f and d didn't appear in "after-join" block when viewed in Texmacs.

However, when exporting to LaTeX, the generated LaTeX file does not reflect the column width specified by cwith tags, here is the generated LaTeX tabular:

\begin{tabular}{|l|l|l|l|}
  \hline
  a & b & c & d\\
  \hline
  e & f & g & h\\
  \hline
\end{tabular}

Expected Behavior

LaTeX has multicolumn and multirow commands which could precisely describe the semantics of joined cells:

\begin{tabular}{|l|l|l|l|}
  \hline
  a & b & \multicolumn{2}{l|}{c} \\
  \hline
  \multicolumn{2}{|l}{e} & g & h\\
  \hline
\end{tabular}

p.s. I know the problem also exists in upstream TeXmacs but I'd love to contribute a fix to Mogan first if we can confirm it's a real issue.

YiqiXu commented 1 year ago

I believe it's a real issue. We would love to have your fix.

da-liii commented 1 year ago

For Mogan Editor 1.2.x, LaTeX support will be maintained as a built-in plugin. In this way, it is community driven. We could release the LaTeX conversion plugin more often.

yzh119 commented 1 year ago

Sounds good to me.

da-liii commented 9 months ago

documented in https://github.com/XmacsLabs/mogan/blob/branch-1.2/devel/43_6.tm now

da-liii commented 2 months ago

For Mogan Editor 1.2.x, LaTeX support will be maintained as a built-in plugin.

Here is the latex plugin: https://github.com/XmacsLabs/latex