12

I am using fp to add a few values in LaTeX. How can I replace the . in \erg with a comma (In Germany the comma is used as decimal mark).

\documentclass{minimal}
\usepackage{fp}

\begin{document}

\FPset\erg{0} 
\FPadd\erg{\erg}{23.20} 
\FPadd\erg{\erg}{38.46}
\FPadd\erg{\erg}{22.36}
\FPadd\erg{\erg}{22.00}
\FPadd\erg{\erg}{15.00}
\FPclip\erg\erg

The sum is  \erg\

\end{document}
1
  • What about \usepackage[locale=DE]{siunitx} and then use the num macro? Nov 2, 2013 at 20:24

2 Answers 2

12

I'd use siunitx for the printing and the LaTeX3 FPU for the sums:

\documentclass{article}
\usepackage{siunitx}
\sisetup{locale = DE}

\ExplSyntaxOn
\newcommand*{\fpeval}[1]{\fp_eval:n {#1}}
\newcommand*{\addto}[2]{\fp_set:Nn #1 { #1 + (#2) }}
\ExplSyntaxOff
\begin{document}

\newcommand*{\erg}{0} 
\addto{\erg}{23.20}
\addto{\erg}{38.46}
\addto{\erg}{22.36}
\addto{\erg}{22.00}
\addto{\erg}{15.00}

The sum is  \num{\fpeval{\erg}}

\end{document}
0
5
\documentclass[preview,border=12pt,varwidth]{standalone}% change this line back to your own document class
\usepackage[nomessages]{fp}

\usepackage{siunitx}
\sisetup{output-decimal-marker={,}}

\begin{document}

\FPset\erg{0} 
\FPadd\erg{\erg}{23.20} 
\FPadd\erg{\erg}{38.46}
\FPadd\erg{\erg}{22.36}
\FPadd\erg{\erg}{22.00}
\FPadd\erg{\erg}{15.00}
\FPclip\erg\erg

The sum is  \num{\erg}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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