emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Bug: org-table latex export does not honour alignment [7.5]


From: Arik Mitschang
Subject: Re: [O] Bug: org-table latex export does not honour alignment [7.5]
Date: Thu, 8 Sep 2011 07:02:52 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.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

=============================================






reply via email to

[Prev in Thread] Current Thread [Next in Thread]