From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arik Mitschang Subject: Re: Bug: org-table latex export does not honour alignment [7.5] Date: Thu, 8 Sep 2011 07:02:52 +0000 (UTC) Message-ID: References: <874o0o7q2u.fsf@ucl.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([140.186.70.92]:51951) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1YkV-0003aS-L3 for emacs-orgmode@gnu.org; Thu, 08 Sep 2011 03:10:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R1YkU-0004bb-MR for emacs-orgmode@gnu.org; Thu, 08 Sep 2011 03:10:11 -0400 Received: from lo.gmane.org ([80.91.229.12]:42392) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1YkU-0004bM-AR for emacs-orgmode@gnu.org; Thu, 08 Sep 2011 03:10:10 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1R1YkR-0002VE-Qp for emacs-orgmode@gnu.org; Thu, 08 Sep 2011 09:10:08 +0200 Received: from cpmon.mq.edu.au ([137.111.13.200]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 08 Sep 2011 09:10:07 +0200 Received: from arik.mitschang by cpmon.mq.edu.au with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 08 Sep 2011 09:10:07 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Hi Eric, Thanks for the response. Yes, I'm aware of that, but it seems unnecessary when I have already used the alignments in the table (and of course if you want HTML to be the same alignment as latex then you would have to do both). I have a patch that fixes this issue and behaves the same when alignment is not specified (or is specified via the attr_latex). This patch is actually against org version 7.7. Not totally sure the best delivery method, but it is short so I include here. Let me know what you think Thanks, -Arik ========================================== diff -U3 /usr/local/share/emacs/site-lisp/org-latex.el /Users/arikm/devel/org-latex-table-export-align-fix.el --- /usr/local/share/emacs/site-lisp/org-latex.el 2011-07-28 20:35:40.000000000 +1000 +++ /Users/arikm/devel/org-latex-table-export-align-fix.el 2011-09-08 16:31:32.000000000 +1000 @@ -1867,9 +1867,11 @@ (org-table-last-alignment (copy-sequence org-table-last-alignment)) (org-table-last-column-widths (copy-sequence org-table-last-column-widths)) + (forced-aligns (org-find-text-property-in-string + 'org-forced-aligns raw-table)) fnum fields line lines olines gr colgropen line-fmt align - caption width shortn label attr floatp placement - longtblp tblenv tabular-env) + alignments caption width shortn label attr floatp + placement longtblp tblenv tabular-env) (if org-export-latex-tables-verbatim (let* ((tbl (concat "\\begin{verbatim}\n" raw-table "\\end{verbatim}\n"))) @@ -1944,12 +1946,21 @@ (when (and (not org-export-latex-tables-column-borders) (string-match "^\\(|\\)?\\(.+\\)|$" line-fmt)) (setq line-fmt (match-string 2 line-fmt))) + ;; incorporate forced alignment defaulting to "right" alignment + (dotimes (i (length fields)) + (let ((forced forced-aligns) + (a "r")) + (while forced + (when (= (car (car forced)) (- (length fields) i)) + (setq a (cdr (car forced)))) + (setq forced (cdr forced))) + (push a alignments))) ;; format alignment (unless align (setq align (apply 'format (cons line-fmt - (mapcar (lambda (x) (if x "r" "l")) - org-table-last-alignment))))) + (mapcar (lambda (x) x) + alignments))))) ;; prepare the table to send to orgtbl-to-latex (setq lines (mapcar =============================================