Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
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. –  Paulo Cereda Aug 10 '11 at 12:53

1 Answer 1

up vote 8 down vote accepted
\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}
share|improve this answer
    
Fantastic! It works like a charm and saves me a lot of typing! Thanks, Herbert! –  Paulo Cereda Aug 10 '11 at 13:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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