0

I'd like to embed org-mode tables in my latex files and have org mode take care of formatting floating point numbers. Based on A.6.2 of the org-mode manual (http://orgmode.org/org.pdf) I expected this to work, in particular to produce 1.0 & 2.0 \\:

\documentclass{article}
\usepackage{comment}
\begin{document}
\begin{comment}
  #+ORGTBL: SEND table-name orgtbl-to-latex :splice t :fmt (1 "%.3s" 2 "%.2f")
 | 1.000 | 2.000 |
\end{comment}
\begin{tabular}{lrr}
  % BEGIN RECEIVE ORGTBL table-name
  % END RECEIVE ORGTBL table-name
\end{tabular}
\end{document}

However, it doesn't. Instead i get an error: Format specifier doesn't match argument type

Any ideas? Is %s the only supported format or am I missing somthing? (Why?)

1
  • I can work around it by producing additional formatted colums and skip the original, but that seems messy.
    – kidmose
    Commented Dec 20, 2016 at 15:00

2 Answers 2

0

One approach would be to calculate additional columns and skip the originals:

#+ORGTBL: SEND correlation-detection-outcomes orgtbl-to-latex :splice t :skipcols (1 2)
| 1 |  2 | 
#+TBLFM: $3=$1;%.2f::$4=$2;%.2f

note the added #+TBLFM: $3=$1;%.2f::$4=$2;%.2f, which that has to be executed (?) by putting the point on it an pressing C-c C-c before doing the same on the table.

This do however seem bloaty and unecessarily hackish.

0

Exploiting the possibility for :fmt to be a function it can be done as follows:

\documentclass{article}
\usepackage{comment}
\begin{document}
\begin{comment}
  #+ORGTBL: SEND table-name orgtbl-to-latex :splice t :fmt (lambda (str) (format "%.2f" (string-to-number str)))
 | 1.000 | 2.000 |
\end{comment}
\begin{tabular}{lrr}
  % BEGIN RECEIVE ORGTBL table-name
  % END RECEIVE ORGTBL table-name
\end{tabular}
\end{document}

Note: :fmt can also be a list with pr. column functions such as (1 fcn1 2 fcn2 ...), where fcn1 is applied to column 1 and so on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.