emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Arik Mitschang <arik.mitschang@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Bug: org-table latex export does not honour alignment [7.5]
Date: Thu, 8 Sep 2011 07:02:52 +0000 (UTC)	[thread overview]
Message-ID: <loom.20110908T085415-105@post.gmane.org> (raw)
In-Reply-To: 874o0o7q2u.fsf@ucl.ac.uk

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	other threads:[~2011-09-08  7:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-07  5:01 Bug: org-table latex export does not honour alignment [7.5] Arik Mitschang
2011-09-07  7:46 ` Eric S Fraga
2011-09-08  7:02   ` Arik Mitschang [this message]
2011-09-08  9:02     ` Eric S Fraga

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=loom.20110908T085415-105@post.gmane.org \
    --to=arik.mitschang@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).