3

I am developing a simple cash book on latex using spreadtab. How would I ensure that the Cost column always gives the value to 2 decimal places (it represents money). I would like the British format please of xx.xx (not xx,xx).

If possible, is there an equivalent of accounting format that could be used on excel, i.e a £ symbol to the left and the cost value on the right?

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=1cm,landscape]{geometry}
\usepackage{spreadtab}
\title{Spreadsheet}
\author{}
\date{}
\begin{document}
\begin{spreadtab}{{tabular}{c|c|c|c|c|c}}
     @Date & @Date v.2 & @ Cost & @Fund & @Bank Acc & @Analysis \\
     \hline
     @01/01/2019 & 20190101 & 2.30   & @General & @HSBC &@Office Expenses   \\ 
     @02/01/2019 & 20190102 & 102.00 & @General & @HSBC &@ Rent\\
     @02/01/2019 & 20190102 & 32.00 & @General & @HSBC &@ Hospitality\\
     \hline
     & & sum(c2:c4) && \\
\end{spreadtab}
\end{document}

enter image description here

3

With the help of siunitx you can achieve the following:

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=1cm,landscape]{geometry}
\usepackage{spreadtab}

\usepackage{siunitx}
\title{Spreadsheet}
\author{}
\date{}
\begin{document}
\begin{spreadtab}{{tabular}{c|c|S[table-format=3.2, round-integer-to-decimal, round-mode = places, round-precision = 2]|c|c|c}}
     @Date & @Date v.2 & @ Cost & @Fund & @Bank Acc & @Analysis \\
     \hline
     @01/01/2019 & 20190101 & 2.30   & @General & @HSBC &@Office Expenses   \\ 
     @02/01/2019 & 20190102 & 102.00 & @General & @HSBC &@ Rent\\
     @02/01/2019 & 20190102 & 32.00 & @General & @HSBC &@ Hospitality\\
     \hline
     & & sum(c2:c4) && \\
\end{spreadtab}

\bigskip

\begin{spreadtab}{{tabular}{c|c|S[table-format=3.2, round-integer-to-decimal, round-mode = places, round-precision = 2]|c|c|c}}
     @Date & @Date v.2 & {@ Cost in \pounds} & @Fund & @Bank Acc & @Analysis \\
     \hline
     @01/01/2019 & 20190101 & 2.30   & @General & @HSBC &@Office Expenses   \\ 
     @02/01/2019 & 20190102 & 102.00 & @General & @HSBC &@ Rent\\
     @02/01/2019 & 20190102 & 32.00 & @General & @HSBC &@ Hospitality\\
     \hline
     & & sum(c2:c4) && \\
\end{spreadtab}

\bigskip

\begin{spreadtab}{{tabular}{c|c|>{\pounds}S[table-format=3.2, round-integer-to-decimal, round-mode = places, round-precision = 2, table-space-text-pre=\pounds]|c|c|c}}
     @Date & @Date v.2 & \multicolumn{1}{c|}{@ Cost} & @Fund & @Bank Acc & @Analysis \\
     \hline
     @01/01/2019 & 20190101 & 2.30   & @General & @HSBC &@Office Expenses   \\ 
     @02/01/2019 & 20190102 & 102.00 & @General & @HSBC &@ Rent\\
     @02/01/2019 & 20190102 & 32.00 & @General & @HSBC &@ Hospitality\\
     \hline
     & & sum(c2:c4) && \\
\end{spreadtab}


\end{document}
2

Since the author of spreadtab seems to preferably use numprint, here is a solution wih the N column type. For the number of decimal digits, you have the command \STautoround*{2}. For the £ currency unit, I suggest using it in the column head once and for all.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=1cm,landscape]{geometry}
\usepackage{makecell, numprint}
\usepackage{spreadtab}
\usepackage{numprint}
 \npdecimalsign{.}
\title{Spreadsheet}
\author{}
\date{}
\begin{document}

\setlength{\extrarowheight}{2pt}
\STautoround*{2}
\begin{spreadtab}{{tabular}{c|c|N{3}{2}|c|c|c}}
     @Date & @Date v.2 &\multicolumn{1}{c|}{\makecell{@ Cost\\ (£)}}& @Fund & @Bank Acc & @Analysis \\
     \hline
     @01/01/2019 & 20190101 & 2.301 & @General & @HSBC &@Office Expenses \\
     @02/01/2019 & 20190102 & 102.997 & @General & @HSBC &@ Rent\\
     @02/01/2019 & 20190102 & 31.998 & @General & @HSBC &@ Hospitality\\
     \hline
     & & sum(c2:c4) && \\
\end{spreadtab}

\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.