Explorar o código

LaTeX export: Fix bug with longtable export.

Karl Stump writes:

> When exporting a table with a horizontal line the column count is wrong.
>
> Output from pdflatex run:
>
> ! Extra alignment tab has been changed to \cr.
> <template> \endtemplate
>
> l.32 ....\multicolumn{4}{r}{Continued on next page}
>                                                   \
> ?
>
> Here's the table in the tex file:
>
> \begin{longtable}{||lll||}
> \caption{This is a long table with lines around and between cells}\\
>  Heading1  &  Heading2  &  Heading3 \\
> \hline
> \endhead
> \hline\multicolumn{4}{r}{Continued on next page}\
> \endfoot
> \endlastfoot
> \hline
>  alpha     &  beta      &  gamma     \\
>            &            &            \\
> \end{longtable}
>
> Here's the org file:
>
> ** table export test
>
> #+CAPTION: This is a long table with lines around and between cells
> #+LATEX_HEADER: \usepackage[landscape]{geometry}
> #+LATEX_HEADER: \geometry{left=0.12in,right=0.12in,top=0.25in,bottom=0.25in}
> #+ATTR_LaTeX: longtable align=||lll||
>
>     | / | <30>     | <10>     | <10>     |
>     |   | Heading1 | Heading2 | Heading3 |
>     |---+----------+----------+----------|
>     |   | alpha    | beta     | gamma    |
>     |   |          |          |          |

Nick Dokos replies:

> I believe it's because of the dummy "calculation-mark" column,
> which is not exported. However, the variable org-table-last-alignment
> (a list, whose length becomes the value of the \multicolumn argument)
> ends up having the value (nil nil nil nil), i.e. it counts the dummy
> column as well. What the proper place to adjust the value is, I don't
> know, but it should be easy for Carsten to fix it. For the time being,
> you can either get rid of the dummy row and column (e.g. if you don't
> need the widths) or fix it by hand in the LaTeX file.

Indeed, and this commit pops `org-table-last-alignment' if the first
column has been removed by `org-table-clean-before-export'.  The same
problem must have caused a one-off error when setting the alignment in
LaTeX tables, bu it seems nobody has noticed this so far.  Anyway,
also this is fixed now.
Carsten Dominik %!s(int64=16) %!d(string=hai) anos
pai
achega
8a0ae0d3e5
Modificáronse 2 ficheiros con 12 adicións e 0 borrados
  1. 6 0
      lisp/ChangeLog
  2. 6 0
      lisp/org-latex.el

+ 6 - 0
lisp/ChangeLog

@@ -1,3 +1,9 @@
+2009-08-29  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-latex.el (org-export-latex-tables): Fix
+	`org-table-last-alignment' and `org-table-last-column-widths' if
+	the first column has been removed.
+
 2009-08-28  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org.el (org-remove-timestamp-with-keyword): Only remove in

+ 6 - 0
lisp/org-latex.el

@@ -1328,6 +1328,9 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
     (let* ((beg (org-table-begin))
 	   (end (org-table-end))
 	   (raw-table (buffer-substring beg end))
+	   (org-table-last-alignment (copy-sequence org-table-last-alignment))
+	   (org-table-last-column-widths (copy-sequence
+					  org-table-last-column-widths))
 	   fnum fields line lines olines gr colgropen line-fmt align
 	   caption label attr floatp longtblp)
       (if org-export-latex-tables-verbatim
@@ -1352,6 +1355,9 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
 	  (apply 'delete-region (list beg end))
 	  (when org-export-table-remove-special-lines
 	    (setq lines (org-table-clean-before-export lines 'maybe-quoted)))
+	  (when org-table-clean-did-remove-column
+	      (pop org-table-last-alignment)
+	      (pop org-table-last-column-widths))
 	  ;; make a formatting string to reflect aligment
 	  (setq olines lines)
 	  (while (and (not line-fmt) (setq line (pop olines)))