3

I am attempting to use Latex to present financial statements. The majority of the work involves the tabular environment with numbers presented in columns which I have set as ragged right. My problem is aligning numbers so that negative numbers which are in parentheses align with the positive ones above and below. there are no decimal points by which I can align the numbers. I have tried adding hspace to the positive numbers, but this doesn't do the trick; neither does the \quad, \qquad. Unable to find any help from google etc. Here is, what I hope is an mwe.

\documentclass[12pt]{report}
\usepackage[top=.8in,bottom=.89in,left=1.25in,right=1.5in]{geometry}
\usepackage[UKenglish]{babel}
\usepackage{amsmath,amssymb,mathtools}
\usepackage{array,booktabs}
\usepackage{parskip}
\usepackage{siunitx}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\begin{document}
\begin{tabular}{p{3.5in}p{1in}R{1in}} %
Turnover &  & 24,500\\ 
Direct Costs &  & (12,250)\\ 
Gross Profit &  & 12,500\\ 
\end{tabular} 
\end{document}

Am I trying to do the impossible or missing something glaringly obvious? Any help would be greatly appreciated.

4

Since you’re already loading siunitx, use it.

Code

\documentclass[varwidth]{standalone}
\usepackage{siunitx}
\begin{document}\noindent
\begin{tabular}{lS[table-format=5.0, table-space-text-pre={(},table-space-text-post={)}]}
    Turnover     &    24500    \\
    Direct Costs & {(}12250{)} \\
    Gross Profit &    12500
\end{tabular}
\end{document}

Output

enter image description here

3

You could use dcolumn for decimal numbers to align at the , (or . if you will)`.

The new column type can be defined by D{,}{,}{4}. The 2 , set the, to input and output separator and the 4 stands for the decimal points to which it will align.

(I slightly altered your code.)

Code

\documentclass[12pt]{report}
\usepackage[top=.8in,bottom=.89in,left=1.25in,right=1.5in]{geometry}

\usepackage{dcolumn}
\newcolumntype{d}{D{,}{,}{4}}

\begin{document}
\begin{tabular*}{.95\linewidth}{@{\extracolsep{\fill}}ld@{}}
Turnover     &  24,500 \\ 
Direct Costs & (12,250)\\ 
Gross Profit &  12,500 \\ 
\end{tabular*} 
\end{document}
2

A simple trick is to print invisible parentheses for the positive numbers via \hphantom:

\documentclass[12pt]{report}
\usepackage[top=.8in,bottom=.89in,left=1.25in,right=1.5in]{geometry}
\usepackage[UKenglish]{babel}
\usepackage{amsmath,amssymb,mathtools}
\usepackage{array,booktabs}
\usepackage{parskip}
\usepackage{siunitx}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\begin{document}
\begin{tabular}{p{3.5in}p{1in}R{1in}} %
Turnover &  & 24,500\hphantom{)}\\
Direct Costs &  & (12,250)\\
Gross Profit &  & 12,500\hphantom{)}\\
\end{tabular}
\end{document}

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.