emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* radiotables in LaTeX-document: export numbers from orgtbl with commas as decimal separators instead of periods; with MWE and lisp-code
@ 2012-04-18 11:00 AW
  2012-04-21  9:22 ` AW
  2012-04-21 22:38 ` radiotables in LaTeX-document: export numbers from orgtbl with commas as decimal separators instead of periods; with MWE and lisp-code => SOLVED AW
  0 siblings, 2 replies; 4+ messages in thread
From: AW @ 2012-04-18 11:00 UTC (permalink / raw)
  To: Emacs-orgmode

Dear all,

I'd like to use radiotables inside a LaTeX-document. Here is a minimal working 
example:

-----------------------------------------------------------
\documentclass[pagesize, ngerman, fontsize=12pt]{scrartcl}
\usepackage[T1]{fontenc}\usepackage[utf8]{inputenc}
\usepackage{babel, comment, array, booktabs}


\title{Sicherheitsbestellung}
\subtitle{gag}
\begin{document}
\maketitle

\begin{tabular}{p{0.25\linewidth}p{0.5\linewidth}}%\toprule
  Bezeichnung & Betrag \\
% BEGIN RECEIVE ORGTBL Kaufpreis
Kaufpreis & 100000.00 \\
Darlehen & -5000.00 \\
Summe & 95000.00 \\
% END RECEIVE ORGTBL Kaufpreis
\bottomrule
\end{tabular}
\begin{comment}
#+ORGTBL: SEND Kaufpreis orgtbl-to-latex :splice t :skip 0
| Kaufpreis | 100000.00 |
| Darlehen  |  -5000.00 |
| Summe     |  95000.00 |
#+TBLFM: @3$2=@1$2+@2$2;%.2f

\end{comment}
\end{document}
-----------------------------------------------------------

I would like to have the LaTeX table with commas as decimal separators instead 
of periods, e.g.: 

»Kaufpreis & 100000,00\\« or even better 
»Kaufpreis & 100\,000,00\\«. 

To avoid misunderstandigs: The change of all periods to commas should take 
place when the org-table is »transfered« to the LaTeX table, not earlier!

I found a suggestion by Carsten Dominik here: 
http://permalink.gmane.org/gmane.emacs.orgmode/42000

-----------------------------------------------------------
(add-hook 'org-export-preprocess-hook
	  'org-use-comma-in-exported-tables)

(defun org-use-comma-in-exported-tables ()
  (goto-char (point-min))
  (while (re-search-forward "\\([0-9]\\)\\.\\([0-9]\\)" nil t)
    (org-if-unprotected
     (when (save-match-data (org-at-table-p))
       (replace-match "\\1,\\2" t nil)))))
-----------------------------------------------------------

I put that into my .emacs, restarted Emacs, but no result.
I'm using Emacs 23.3 and Org-mode version 7.8.02. Please bear in mind that I'm 
may have made strange mistake, because I do neither have experience with 
radiotables nor understand lisp.

Any help would be appreciated, thanks in advance.

Kind regards,

Alexander

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: radiotables in LaTeX-document: export numbers from orgtbl with commas as decimal separators instead of periods; with MWE and lisp-code
  2012-04-18 11:00 radiotables in LaTeX-document: export numbers from orgtbl with commas as decimal separators instead of periods; with MWE and lisp-code AW
@ 2012-04-21  9:22 ` AW
  2012-04-21 23:09   ` William Henney
  2012-04-21 22:38 ` radiotables in LaTeX-document: export numbers from orgtbl with commas as decimal separators instead of periods; with MWE and lisp-code => SOLVED AW
  1 sibling, 1 reply; 4+ messages in thread
From: AW @ 2012-04-21  9:22 UTC (permalink / raw)
  To: emacs-orgmode

On wednesday, 18. April 2012, 13:00:25 wrote AW:
> Dear all,

Sorry for this attempt to insist on something else than buriel in the digital 
mass grave of gnu.org for my question. 

Maybe someone could have a look at it, it would be very usefull to me and 
probably to others: A comma is the decimal separator for amounts in money in 
continental europe. Without replacement of periods with commas _while 
exporting to LaTeX_ you can not use radiotables for any kind of accounting.

If my question lacks sense or has other shortcomings, please tell me. Thank 
you very much.

Regards,

Alexander

> 
> I'd like to use radiotables inside a LaTeX-document. Here is a minimal
> working example:
> 
> -----------------------------------------------------------
> \documentclass[pagesize, ngerman, fontsize=12pt]{scrartcl}
> \usepackage[T1]{fontenc}\usepackage[utf8]{inputenc}
> \usepackage{babel, comment, array, booktabs}
> 
> 
> \title{Sicherheitsbestellung}
> \subtitle{gag}
> \begin{document}
> \maketitle
> 
> \begin{tabular}{p{0.25\linewidth}p{0.5\linewidth}}%\toprule
>   Bezeichnung & Betrag \\
> % BEGIN RECEIVE ORGTBL Kaufpreis
> Kaufpreis & 100000.00 \\
> Darlehen & -5000.00 \\
> Summe & 95000.00 \\
> % END RECEIVE ORGTBL Kaufpreis
> \bottomrule
> \end{tabular}
> \begin{comment}
> #+ORGTBL: SEND Kaufpreis orgtbl-to-latex :splice t :skip 0
> 
> | Kaufpreis | 100000.00 |
> | Darlehen  |  -5000.00 |
> | Summe     |  95000.00 |
> 
> #+TBLFM: @3$2=@1$2+@2$2;%.2f
> 
> \end{comment}
> \end{document}
> -----------------------------------------------------------
> 
> I would like to have the LaTeX table with commas as decimal separators
> instead of periods, e.g.:
> 
> »Kaufpreis & 100000,00\\« or even better
> »Kaufpreis & 100\,000,00\\«.
> 
> To avoid misunderstandigs: The change of all periods to commas should take
> place when the org-table is »transfered« to the LaTeX table, not earlier!
> 
> I found a suggestion by Carsten Dominik here:
> http://permalink.gmane.org/gmane.emacs.orgmode/42000
> 
> -----------------------------------------------------------
> (add-hook 'org-export-preprocess-hook
> 	  'org-use-comma-in-exported-tables)
> 
> (defun org-use-comma-in-exported-tables ()
>   (goto-char (point-min))
>   (while (re-search-forward "\\([0-9]\\)\\.\\([0-9]\\)" nil t)
>     (org-if-unprotected
>      (when (save-match-data (org-at-table-p))
>        (replace-match "\\1,\\2" t nil)))))
> -----------------------------------------------------------
> 
> I put that into my .emacs, restarted Emacs, but no result.
> I'm using Emacs 23.3 and Org-mode version 7.8.02. Please bear in mind that
> I'm may have made strange mistake, because I do neither have experience
> with radiotables nor understand lisp.
> 
> Any help would be appreciated, thanks in advance.
> 
> Kind regards,
> 
> Alexander

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: radiotables in LaTeX-document: export numbers from orgtbl with commas as decimal separators instead of periods; with MWE and lisp-code => SOLVED
  2012-04-18 11:00 radiotables in LaTeX-document: export numbers from orgtbl with commas as decimal separators instead of periods; with MWE and lisp-code AW
  2012-04-21  9:22 ` AW
@ 2012-04-21 22:38 ` AW
  1 sibling, 0 replies; 4+ messages in thread
From: AW @ 2012-04-21 22:38 UTC (permalink / raw)
  To: emacs-orgmode

There is an easy solution on the LaTeX side: we simply have to use the package 
»numprint« and to wrap every number of the second column with 
»\numprint{number}«, then it will be printed in a suitable way.

We get this by adding to the #+ORGTBL - line this code: 

:fmt (2 "\\numprint{%s} EUR")

So the whole line looks like this:

#+ORGTBL: SEND anteile orgtbl-to-latex :splice t :skip 1 :fmt (2 
"\\numprint{%s} EUR")

Sorry for the noise.

Regards,

Alexander

> Dear all,
> 
> I'd like to use radiotables inside a LaTeX-document. Here is a minimal
> working example:
> 
> -----------------------------------------------------------
> \documentclass[pagesize, ngerman, fontsize=12pt]{scrartcl}
> \usepackage[T1]{fontenc}\usepackage[utf8]{inputenc}
> \usepackage{babel, comment, array, booktabs}
> 
> 
> \title{Sicherheitsbestellung}
> \subtitle{gag}
> \begin{document}
> \maketitle
> 
> \begin{tabular}{p{0.25\linewidth}p{0.5\linewidth}}%\toprule
>   Bezeichnung & Betrag \\
> % BEGIN RECEIVE ORGTBL Kaufpreis
> Kaufpreis & 100000.00 \\
> Darlehen & -5000.00 \\
> Summe & 95000.00 \\
> % END RECEIVE ORGTBL Kaufpreis
> \bottomrule
> \end{tabular}
> \begin{comment}
> #+ORGTBL: SEND Kaufpreis orgtbl-to-latex :splice t :skip 0
> 
> | Kaufpreis | 100000.00 |
> | Darlehen  |  -5000.00 |
> | Summe     |  95000.00 |
> 
> #+TBLFM: @3$2=@1$2+@2$2;%.2f
> 
> \end{comment}
> \end{document}
> -----------------------------------------------------------
> 
> I would like to have the LaTeX table with commas as decimal separators
> instead of periods, e.g.:
> 
> »Kaufpreis & 100000,00\\« or even better
> »Kaufpreis & 100\,000,00\\«.
> 
> To avoid misunderstandigs: The change of all periods to commas should take
> place when the org-table is »transfered« to the LaTeX table, not earlier!
> 
> I found a suggestion by Carsten Dominik here:
> http://permalink.gmane.org/gmane.emacs.orgmode/42000
> 
> -----------------------------------------------------------
> (add-hook 'org-export-preprocess-hook
> 	  'org-use-comma-in-exported-tables)
> 
> (defun org-use-comma-in-exported-tables ()
>   (goto-char (point-min))
>   (while (re-search-forward "\\([0-9]\\)\\.\\([0-9]\\)" nil t)
>     (org-if-unprotected
>      (when (save-match-data (org-at-table-p))
>        (replace-match "\\1,\\2" t nil)))))
> -----------------------------------------------------------
> 
> I put that into my .emacs, restarted Emacs, but no result.
> I'm using Emacs 23.3 and Org-mode version 7.8.02. Please bear in mind that
> I'm may have made strange mistake, because I do neither have experience
> with radiotables nor understand lisp.
> 
> Any help would be appreciated, thanks in advance.
> 
> Kind regards,
> 
> Alexander

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: radiotables in LaTeX-document: export numbers from orgtbl with commas as decimal separators instead of periods; with MWE and lisp-code
  2012-04-21  9:22 ` AW
@ 2012-04-21 23:09   ` William Henney
  0 siblings, 0 replies; 4+ messages in thread
From: William Henney @ 2012-04-21 23:09 UTC (permalink / raw)
  To: AW; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 3901 bytes --]

Hi Alexander  

On Saturday, 21 April 2012 at 04:22, AW wrote:  
> On wednesday, 18. April 2012, 13:00:25 wrote AW:
> >  
> Sorry for this attempt to insist on something else than buriel in the digital  
> mass grave of gnu.org (http://gnu.org) for my question.  
>  
> Maybe someone could have a look at it, it would be very usefull to me and  
> probably to others: A comma is the decimal separator for amounts in money in  
> continental europe. Without replacement of periods with commas _while  
> exporting to LaTeX_ you can not use radiotables for any kind of accounting.
>  
> If my question lacks sense or has other shortcomings, please tell me. Thank  
> you very much.
>  
I have no idea how to solve this on the orgtable side, but there are several ways to solve it with LaTeX.  That is, your .tex file would still have, for example, "100000.00" but this would be automagically translated to "100\,000,00" when you compile it.  

One way is to use the numprint package, which defines a new table column type "n" for typesetting numbers nicely.  It is fully localizable to your language.

I attach a slightly modified version of your example to illustrate how it works.  

I think that pgftables can probably also do this.  

Hope this helps

Will


--

Dr William Henney, Centro de Radioastronomía y Astrofísica,
Universidad Nacional Autónoma de México, Campus Morelia


  
>  
> Regards,
>  
> Alexander
>  
> >  
> > I'd like to use radiotables inside a LaTeX-document. Here is a minimal
> > working example:
> >  
> > -----------------------------------------------------------
> > \documentclass[pagesize, ngerman, fontsize=12pt]{scrartcl}
> > \usepackage[T1]{fontenc}\usepackage[utf8]{inputenc}
> > \usepackage{babel, comment, array, booktabs}
> >  
> >  
> > \title{Sicherheitsbestellung}
> > \subtitle{gag}
> > \begin{document}
> > \maketitle
> >  
> > \begin{tabular}{p{0.25\linewidth}p{0.5\linewidth}}%\toprule
> > Bezeichnung & Betrag \\
> > % BEGIN RECEIVE ORGTBL Kaufpreis
> > Kaufpreis & 100000.00 \\
> > Darlehen & -5000.00 \\
> > Summe & 95000.00 \\
> > % END RECEIVE ORGTBL Kaufpreis
> > \bottomrule
> > \end{tabular}
> > \begin{comment}
> > #+ORGTBL: SEND Kaufpreis orgtbl-to-latex :splice t :skip 0
> >  
> > | Kaufpreis | 100000.00 |
> > | Darlehen | -5000.00 |
> > | Summe | 95000.00 |
> >  
> > #+TBLFM: @3$2=@1$2+@2$2;%.2f
> >  
> > \end{comment}
> > \end{document}
> > -----------------------------------------------------------
> >  
> > I would like to have the LaTeX table with commas as decimal separators
> > instead of periods, e.g.:
> >  
> > »Kaufpreis & 100000,00\\« or even better
> > »Kaufpreis & 100\,000,00\\«.
> >  
> > To avoid misunderstandigs: The change of all periods to commas should take
> > place when the org-table is »transfered« to the LaTeX table, not earlier!
> >  
> > I found a suggestion by Carsten Dominik here:
> > http://permalink.gmane.org/gmane.emacs.orgmode/42000
> >  
> > -----------------------------------------------------------
> > (add-hook 'org-export-preprocess-hook
> > 'org-use-comma-in-exported-tables)
> >  
> > (defun org-use-comma-in-exported-tables ()
> > (goto-char (point-min))
> > (while (re-search-forward "\\([0-9]\\)\\.\\([0-9]\\)" nil t)
> > (org-if-unprotected
> > (when (save-match-data (org-at-table-p))
> > (replace-match "\\1,\\2" t nil)))))
> > -----------------------------------------------------------
> >  
> > I put that into my .emacs, restarted Emacs, but no result.
> > I'm using Emacs 23.3 and Org-mode version 7.8.02. Please bear in mind that
> > I'm may have made strange mistake, because I do neither have experience
> > with radiotables nor understand lisp.
> >  
> > Any help would be appreciated, thanks in advance.
> >  
> > Kind regards,
> >  
> > Alexander  


[-- Attachment #2: tabgerman.tex --]
[-- Type: application/octet-stream, Size: 997 bytes --]

\documentclass[pagesize, ngerman, fontsize=12pt]{scrartcl}
\usepackage[T1]{fontenc}\usepackage[utf8]{inputenc}
\usepackage{babel, comment, array, booktabs}

%% WJH 21 Apr 2012: numprint defines the "n" column type
%% WJH: The autolanguage option will take the language from the document
\usepackage[autolanguage]{numprint}

\title{Sicherheitsbestellung}
\subtitle{gag}
\begin{document}
\maketitle

% WJH: n{6}{2} means 6 digits before and 2 digits after the decimal separator
\begin{tabular}{p{0.25\linewidth}n{6}{2}}%\toprule
Bezeichnung & {Betrag} \\ % WJH: normal text in a "n" column must be in braces to avoid being in math mode
% BEGIN RECEIVE ORGTBL Kaufpreis
Kaufpreis & 100000.00 \\
Darlehen & -5000.00 \\
Summe & 95000.00 \\
% END RECEIVE ORGTBL Kaufpreis
\bottomrule
\end{tabular}
\begin{comment}
#+ORGTBL: SEND Kaufpreis orgtbl-to-latex :splice t :skip 0
| Kaufpreis | 100000.00 |
| Darlehen | -5000.00 |
| Summe | 95000.00 |
#+TBLFM: @3$2=@1$2+@2$2;%.2f

\end{comment}
\end{document}

[-- Attachment #3: tabgerman.pdf --]
[-- Type: application/pdf, Size: 68531 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-04-21 23:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-18 11:00 radiotables in LaTeX-document: export numbers from orgtbl with commas as decimal separators instead of periods; with MWE and lisp-code AW
2012-04-21  9:22 ` AW
2012-04-21 23:09   ` William Henney
2012-04-21 22:38 ` radiotables in LaTeX-document: export numbers from orgtbl with commas as decimal separators instead of periods; with MWE and lisp-code => SOLVED AW

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).