2

I'm trying to use Pandoc for the semi-automatic generation of billing statements from YAML text inputs:

  • For doing sum calculations I use the spreadtab package.
  • For getting automatic page breaks if the statement is long, the longtable package is wrapped inside spreadtab.

Most elementary things work now as needed, but I want to polish the appearance of long numbers by inserting a thousand separator. However, I'm now lost with this last issue: inserting a "thousands separator" into the display of long numbers:

MWE example -- resulting table displays numbers without "thousands separator".

Here is a minimally working example LaTeX code which Pandoc generated from my own custom LaTeX template:

%\listfiles
\documentclass[12pt]{article}
\usepackage[]{geometry}
    \geometry{a4paper, paperwidth=595pt, paperheight=842pt, left=25.0mm, right=18mm, top=45.5mm, bottom=32mm}
\usepackage[boldmath, np, oldcolumntypes, sepfour, warning, autolanguage, addplus,]{numprint}
\usepackage[table]{xcolor}

\usepackage{polyglossia}
    \setmainlanguage{german}

\usepackage[document]{ragged2e}

\usepackage{fontspec}
\usepackage{xunicode}

%--------------------------------
% I'm really using WeidemannStd-Medium
%--------------------------------
%\setmainfont[SmallCapsFeatures={LetterSpace=5,Letters=SmallCaps}]{WeidemannStd-Medium}
%    \setsansfont{WeidemannStd-Medium}
%--------------------------------

%--------------------------------
% However, for the MWE I'm switching to Vollkorn, because not everybody has Weidemann fonts...
%--------------------------------
\setmainfont[Numbers={Lining,Monospaced}]{Vollkorn-Regular}
%--------------------------------

\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}

%--------------------------------
% TABLE CUSTOMIZATION
%--------------------------------
\usepackage{enumitem}                       % Anpassen von Listen
    \setlist{nolistsep}                     % Kein whitespace zwischen Listen-Items
    \setlist[itemize]{leftmargin=0.6cm}     % Reduziere linken Einzug bei Listen
\usepackage{spreadtab}
    \setlength{\tabcolsep}{6pt}             % Größeren gutter zwischen Spalten

%--------------------------------
% To be decided!
%--------------------------------
\usepackage{longtable}
%\usepackage{supertabular}
%\usepackage{tabularx}
%\usepackage{booktabs}
%\usepackage{ltablex}
%\usepackage{tabu}
%--------------------------------

\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \TeXXeTstate=1
  \newcommand{\RL}[1]{\beginR #1\endR}
  \newcommand{\LR}[1]{\beginL #1\endL}
  \newenvironment{RTL}{\beginR}{\endR}
  \newenvironment{LTR}{\beginL}{\endL}
\fi

\begin{document}

\makeatletter
  \newcommand\myFootnotesize{\@setfontsize\tinyv{9pt}{11.5}}
\makeatother

\newcounter{pos}
\setcounter{pos}{0}
\STautoround*{2}
\STsetdecimalsep{,}

\npfourdigitsep
\npstylegerman
\npthousandsep{\.}

\rowcolors{1}{gray!30}{gray!20}
%--------------------------------
% HIER WIRD'S INTERESSANT!
%--------------------------------
\begin{spreadtab}
{{longtable}[t t t]{rp{120.0mm}r}}
@ \textbf{Pos.}               & @ \textbf{Beschreibung}                  &  @ \textbf{Preise in EUR}  \\
@ \refstepcounter{pos}\thepos & @ Die erste erbrachte Leistungs-Position &  14450                     \\
@ \refstepcounter{pos}\thepos & @ Weitere Position, mit einer Liste von Einzelheiten
                                                  \newline
                                                      \begin{itemize}
                                                         \myFootnotesize \item
                                                         Nähere Erläuterungen zur erbrachten\ldots{}
                                                         \myFootnotesize \item
                                                         \ldots{}Leistung, wie evtl. erforderlich
                                                         \myFootnotesize \item
                                                         Sieht gut aus
                                                      \end{itemize}      & -734                       \\
@                             & @ \multicolumn{1}{r}{Summe, netto:}      &  :={sum(c1:[0,-1])}        \\
@                             & @ \multicolumn{1}{r}{MWSt. 19\%:}        &  19/100*[0,-1]             \\
@                             & @ \multicolumn{1}{r}{\textbf{Gesamt:} }  &  \textbf{:={[0,-1]+[0,-2]}}\\
\end{spreadtab}

\end{document}

I'm using xelatex to compile the LaTeX code to PDF.

As you can see, the numprint packages is loaded in line 5 with the sepfour option, so I can possibly get the thousands separator to work. I played with the available options there, but I did not find any which would get it to work.

I would assume that the \npthousandsep{\.} command (line 73 of the MWE) should do what I want, but it doesn't.

So I must clearly be missing something obvious...

My main question for now is the first one below. However, I'm interested in getting answers for the second and third ones too:

  1. How can I get a "thousands separator" (either a dot, or a narrow space) inserted into all long numbers?
  2. Is there a way to automatically append the Euro sign to all displayed numbers in column 3?
  3. I could not get the code to work with other table packages (other than longtable), as they are listed in lines 44-49:
    • Which one of the other table packages can also automatically insert line breaks if required?
    • What do I need to change in the table code to use that other package?

Update: I can hardly believe that no-one tried to answer my question(s) more than 12 months after submitting it. Maybe this update draws new attention to it?

1 Answer 1

2

don't know if it matters anymore, but I believe numprint can do what you want with the commands:

\renewcommand\STprintnum[1]{\numprint{#1}}
\npthousandsep{,}

I also had to redefine the decimal separator. An example is shown below (sorry not a long table). table with thousands , seperator

\documentclass{article}

\usepackage{spreadtab}
\usepackage{numprint}
\usepackage{booktabs} % for more table lines

\begin{document}

\begin{table}[!ht]
    \centering
    \renewcommand\STprintnum[1]{\numprint{#1}}
    \nprounddigits{2}
    \npthousandsep{,}
    \npdecimalsign{.}

    \begin{spreadtab}{{tabular}{lrrrrrrr}}
        \toprule
          & @Time step  & @\shortstack{Simulation\\ Time [sec] } &@ \shortstack{Data File \\Size [KB] }  &@ \shortstack{Real time \\Speed up}& @\shortstack{ PSDS\\Speed up} & @\shortstack{Reduction \\ of file size}  & @ \shortstack{Steady State $f$ \\ error [Hz]}\\
        \midrule        
        @PSDS       &@4.167 ms      &  56.12    & 35070     & \STcopy{v}{90/C2}     & 1                     & 1                     & 0\\
        @LTD        &@  2 sec       & 13.88     &   300     &                       & \STcopy{v}{56.12/c3}  & \STcopy{v}{!d!2/d3}   &@ NA \\ 
        @LTD        &@  1 sec       & 26.28     &   496     &                       &                       &                       &@ 9.50E-4\\
        @LTD        &@  0.5 sec     & 52.27     &   888     &                       &                       &                       &@ 9.71E-4\\ 
        @LTD        &@  0.25 sec    & 102.43    &   1672    &                       &                       &                       &@ 9.78E-4\\
        \bottomrule
    \end{spreadtab}
\end{table} 

\end{document}
1
  • Thanks for the answer, even if it is almost three years later. I cannot verify it right now, but I'll upvote it for now, just for the effort. Once I verified it (can take a while till I get round), I'll also accept it. Thanks again! May 22, 2019 at 20:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .