emacs-orgmode
[Top][All Lists]
Advanced

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

Re: Allow Currency Symbols and Grouping Commas in Table Numbers


From: Daniel E. Doherty
Subject: Re: Allow Currency Symbols and Grouping Commas in Table Numbers
Date: Tue, 31 May 2022 09:19:24 -0500
User-agent: mu4e 1.6.2; emacs 29.0.50

Ihor,

Again, thanks for your thoughts.  All, however, ruin the look of the
tables.  Could you, perhaps, point me to where in the vast org code,
strings are converted to numbers in preparation for sending to calc?

I could then play with overriding the function and come up with a
work-around.

Regards,

On Fri, May 27 2022, Ihor Radchenko wrote:

> "Daniel E. Doherty" <ded@ddoherty.net> writes:
>
>> | Description  | Amount     |
>> |--------------+------------|
>> | Mortage      | 125,000.26 |
>> | Credit Cards | 6,325.00   |
>> | Auto Loan    | 14,853.00  |
>> |--------------+------------|
>> | Total        | 1323.26    |
>> #+TBLFM: @5$2=vsum(@I..@II)
>>
>> Note that the total is wrong.
>
> Well. This is also a caveat from calc, unfortunately.
>
> 7.7.2 Grouping Digits
>    Please note that grouped numbers will not generally be parsed
> correctly if re-read in textual form, say by the use of ‘C-x * y’ and
> ‘C-x * g’.  (*Note Kill and Yank::, for details on these commands.)  One
> exception is the ‘\,’ separator, which doesn’t interfere with parsing
> because it is ignored by TeX language mode.
>
> So, you can instead do
>
> | Description  | Amount      |
> |--------------+-------------|
> | Mortage      | 125\,000.26 |
> | Credit Cards | 6\,325.00   |
> | Auto Loan    | 14\,853.00  |
> |--------------+-------------|
> | Total        | 146178.26   |
>
> #+TBLFM: @5$2=vsum(@I..@II)
>
> Or with
>
> #+begin_SRC emacs-lisp
> (setq org-calc-default-modes
>       '( calc-internal-prec 12
>        calc-float-format  (float 8)
>        calc-angle-mode    deg
>        calc-prefer-frac   nil
>        calc-symbolic-mode nil
>        calc-language latex ;; <--- this is new compared to default, enable 
> latex symbols
>        calc-group-digits t ;; <--- group digits in the results
>        calc-group-char "\\,"
>        calc-date-format (YYYY "-" MM "-" DD " " Www (" " hh ":" mm))
>        calc-display-working-message t))
> #+end_SRC
>
>
> | Description  | Amount      |
> |--------------+-------------|
> | Mortage      | 125\,000.26 |
> | Credit Cards | 6\,325.00   |
> | Auto Loan    | 14\,853.00  |
> |--------------+-------------|
> | Total        | 146\,178.26 |
>
> #+TBLFM: @5$2=vsum(@I..@II)
>
>> | Description  | Amount                     |
>> |--------------+----------------------------|
>> | Mortage      | \dollar 125000.26          |
>> | Credit Cards | 6325.00                    |
>> | Auto Loan    | 14853.00                   |
>> |--------------+----------------------------|
>> | Total        | 125000.26 \dollar + 21178. |
>> #+TBLFM: @5$2=vsum(@I..@II)
>>
>> Total is still wrong.
>
> You need
>
> | Description  | Amount                     |
> |--------------+----------------------------|
> | Mortage      | \dollar 125000.26          |
> | Credit Cards | \dollar 6325.00            |
> | Auto Loan    | \dollar 14853.00           |
> |--------------+----------------------------|
> | Total        | 146178.26 \dollar          |
>
> #+TBLFM: @5$2=vsum(@I..@II)
>
> Best,
> Ihor


--
====================================================
Daniel E. Doherty
Law Offices of Daniel E. Doherty
7300 W. 110th Street, Suite 930
Overland Park, KS 66210
913.338.7182 (Phone)
913.338.7164 (FAX)
ded@ddoherty.net



reply via email to

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