10

Friends, I have to create some sort of a balance sheet, so my first sketch is using a tabular environment. I also have to follow some styling rules.

One of the styles rules I need to obey is the presence of the currency symbol in every single monetary description. I defined \brl (to be expanded as R$) to make my life easier. Besides that, all currency symbols need to be vertically aligned.

Most of the work is wonderfully made by the siunitx package. Consider the following code:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{siunitx}

\newcommand{\brl}{R\$}

\sisetup{output-decimal-marker={,},group-separator ={.},group-minimum-digits=4}

\begin{document}

\begin{table*}[h]
\centering
\begin{tabular}{p{.35\textwidth}S}
Item 1\dotfill\brl & 10.00\\
Item 2\dotfill\brl & 100.00\\
Item 3\dotfill\brl & 1000.00\\
Item 4\dotfill\brl & 10000.00
\end{tabular}
\end{table*}

\end{document}

That's the workaround I came up. The output is as follows:

Output

I also need to use \dotfill. The dots are part of the styling rules as well.

TBH, I'm not proud of my solution. =P I'm sure there are better approaches than mine. I suspect siunitx can easily solve this issue of currency symbol alignment, but I'm stuck.

Any ideas on how to improve my code?

UPDATE: Sorry if I didn't make myself clear. I was thinking about a currency symbol configuration in the number column itself, something like \money{1000.00} instead of putting the \brl symbol in the previous column.

2
  • I'm not sure what you're asking. What would a "better" solution achieve that this solution doesn't?
    – Seamus
    Aug 10 '11 at 12:46
  • @Seamus: Sorry, I probably didn't make myself clear. I was thinking about a currency symbol configuration in the number column itself. My solution works, but I'd like to avoid \dotfill\brl. Aug 10 '11 at 12:53
9
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{siunitx}

\newcommand{\brl}{R\$}

\sisetup{output-decimal-marker={,},group-separator ={.},group-minimum-digits=4}

\begin{document}

\begin{table*}[h]
\centering
\begin{tabular}{p{.35\textwidth}<{\dotfill\brl}S}
Item 1 & 10.00\\
Item 2 & 100.00\\
Item 3 & 1000.00\\
Item 4 & 10000.00
\end{tabular}
\end{table*}

\end{document}
1
  • Fantastic! It works like a charm and saves me a lot of typing! Thanks, Herbert! Aug 10 '11 at 13:07

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.