emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Austin Frank <austin.frank@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: [babel]  apply #+TABLEFM lines during export?
Date: Mon, 12 Jul 2010 22:59:42 -0500	[thread overview]
Message-ID: <m0y6dg1175.fsf@gmail.com> (raw)
In-Reply-To: 87hbk5mh9j.fsf@gmail.com


[-- Attachment #1.1: Type: text/plain, Size: 2172 bytes --]

On Sun, Jul 11 2010, Eric Schulte wrote:

> Under the current setup, I don't know of a way to ensure that the
> formula will be re-run.  This may be a good place for future
> (post-feature-freeze) functionality.  There has also been discussion
> of adding a header argument for "post-processing" code blocks which
> could accept the output of the evaluated code block as input -- this
> might be related.

Yes, eager to see where this goes.

> As a work-around, I would suggest the following emacs-lisp code block.
> Export of this code block will trigger the evaluation of the R code
> block, and it will then trim the output of said block resulting in the
> desired table precision.
>
> #+begin_src emacs-lisp :var tab=anova-example :colnames yes :cache yes
>   (mapcar
>    (lambda (row)
>      (mapcar
>       (lambda (cell) (if (numberp cell) (format "%.4f" cell) cell))
>       row))
>    tab)
> #+end_src


I tried to customize your approach to apply to the whole buffer.  This
code seems to do a nice job of changing the appearance of the tables
within the buffer, but the extra precision is still maintained on
export.

--8<---------------cut here---------------start------------->8---
#+source:  format-table-floats
#+BEGIN_SRC emacs-lisp :results silent :exports none
(add-hook 'org-export-preprocess-final-hook
          (lambda ()
            (while (re-search-forward
                    "|?[ ]+\\(-?[0-9]+\\.[0-9]+\\)\\(e-\\)?[ ]+|"
                    nil t)
              (progn
                (replace-match (concat
                                (format "%.4f"
                                        (string-to-number (match-string 1)))
                                " |"))
                (org-table-align)))))
#+END_SRC
--8<---------------cut here---------------end--------------->8---

Can anyone suggest another approach that would change the precision of
floats in all tables in the buffer before export?  Perhaps there's a
different hook I should be using for LaTeX export?

Thanks!
/au

-- 
Austin Frank
http://aufrank.net
GPG Public Key (D7398C2F): http://aufrank.net/personal.asc

[-- Attachment #1.2: Type: application/pgp-signature, Size: 194 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

  reply	other threads:[~2010-07-13  4:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-10 14:13 [babel] apply #+TABLEFM lines during export? Austin Frank
2010-07-11 22:26 ` Eric Schulte
2010-07-13  3:59   ` Austin Frank [this message]
2010-07-13  5:06     ` Eric Schulte
2010-07-13 22:56       ` Austin Frank

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=m0y6dg1175.fsf@gmail.com \
    --to=austin.frank@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).