尝试应用于表\rowcolor{gray}
中的某一行tabularx
(该行的值是从该表中计算出来的)spreadtab
会导致著名的错误
TeX 容量超出,抱歉 [参数堆栈大小=10000]。
这可能与某些列大小有关吗?我搞不懂。请在下面找到 MWE,并记下 documentclass scrlttr2
。非常感谢。
\documentclass[fontsize=10pt]{scrlttr2}
\usepackage[margin=4cm]{geometry}
\usepackage{booktabs}
\usepackage{tabularx,colortbl}
\usepackage{siunitx} % align by decimal point
\sisetup{detect-weight=true, detect-family=true}
\sisetup{locale = DE}
\usepackage{microtype}
\usepackage{eurosym}
\usepackage{spreadtab} % for table calculation
\usepackage{microtype}
\usepackage{tabularx}
\usepackage[scaled]{helvet}
\renewcommand\familydefault{\sfdefault}
\usepackage[ngerman]{babel}
\usepackage{xspace} % for fantom space
\begin{document}
\begin{letter}{}
Hi
\newcommand\Rate{50}
\medskip\par\noindent
\begin{spreadtab}{{tabularx}{\textwidth}{rlcS[table-format=5.2,round-integer-to-decimal,round-mode = places]}}%<{\euro}
\toprule
%A & B & C & D
@ & @\textbf{Item} & @\textbf{Amount} & @\textbf{Total (\euro)} \\ \midrule
@1 & @some relatively long text for no reason & 3 & c2*\Rate \\
@2 & @Bar & 3 & c3*\Rate \\
@3 & @Baz & 1 & c4*\Rate \\ \midrule
& \hspace{0pt plus 1filll} @Total: & sum(c2:c4) & \\
& \hspace{0pt plus 1filll} @Rate: & @\Rate\xspace\euro & \\ \midrule
& \hspace{0pt plus 1filll} @Sum netto: & & sum(d2:d4) \\
& \hspace{0pt plus 1filll} @Tax 19\%: & & 0.19*[0,-1] \\
%\rowcolor{gray} % <-------------------
& \hspace{0pt plus 1filll} @Total: & & :={[0,-1]+[0,-2]}\xspace\euro \\
\bottomrule
\end{spreadtab}
\medskip\par
\closing{Bye}
\end{letter}
\end{document}
较小的例子
\documentclass{article}
\usepackage{colortbl}
\usepackage{spreadtab}
\begin{document}
\begin{spreadtab}{{tabular*}{\textwidth}{rlcc}}
@1 & @text for no reason & @z & @h \\
\rowcolor{red}
a&b&c&d
\end{spreadtab}
\end{document}
答案1
您可以尝试新的 LaTeX3 包tabularray
:
siunitx
版本 3的解决方案
\documentclass[fontsize=10pt]{scrlttr2}
\usepackage[margin=4cm]{geometry}
\usepackage{microtype}
\usepackage{eurosym}
\usepackage[scaled]{helvet}
\renewcommand\familydefault{\sfdefault}
\usepackage{xspace} % for fantom space
\usepackage{spreadtab} % for table calculation
\usepackage{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{siunitx}
\sisetup{detect-weight=true, detect-family=true}
\sisetup{locale = DE}
\begin{document}
\begin{letter}{}
Hi
\newcommand\Rate{50}
\medskip\par\noindent
\begin{spreadtab}{{tblr}{
width = \linewidth,
colspec={rlcX[l,si={table-format=5.2,round-integer-to-decimal,round-mode = places,table-number-alignment=left}]},
hline{1,10} = {0.08em}, % toprule and bottomrule
hline{2,5,7} = {0.05em}, % midrule
cell{5-9}{2} = {r}, % right alignment
row{1} = {font=\rmfamily\bfseries}, % row font
row{9} = {gray8}, % row color
}}
@ & @Item & @Amount & @{{{Total (\euro)}}} \\
@1 & @some relatively long text for no reason & 3 & c2*\Rate \\
@2 & @Bar & 3 & c3*\Rate \\
@3 & @Baz & 1 & c4*\Rate \\
& @Total: & sum(c2:c4) & \\
& @Rate: & @\Rate\xspace\euro & \\
& @Sum netto: & & sum(d2:d4) \\
& @Tax 19\%: & & 0.19*[0,-1] \\
& @Total: & & :={[0,-1]+[0,-2]}\xspace\euro \\
\end{spreadtab}
\medskip\par
\closing{Bye}
\end{letter}
\end{document}
siunitx
版本 2的解决方案
\documentclass[fontsize=10pt]{scrlttr2}
\usepackage[margin=4cm]{geometry}
%\usepackage{microtype}
\usepackage{eurosym}
\usepackage[scaled]{helvet}
\renewcommand\familydefault{\sfdefault}
\usepackage{xspace} % for fantom space
\usepackage{spreadtab} % for table calculation
\usepackage{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{siunitx}
\sisetup{detect-weight=true, detect-family=true}
\sisetup{locale = DE}
\begin{document}
\begin{letter}{}
Hi
\newcommand\Rate{50}
\medskip\par\noindent
\begin{spreadtab}{{tblr}{
width = \linewidth,
colspec={rlcQ[r,si={table-format=5.2,round-integer-to-decimal,round-mode = places,table-number-alignment=left}]@{}X},
hline{1,10} = {0.08em}, % toprule and bottomrule
hline{2,5,7} = {0.05em}, % midrule
cell{5-9}{2} = {r}, % right alignment
row{1} = {font=\rmfamily\bfseries}, % row font
row{9} = {gray8}, % row color
}}
@ & @Item & @Amount & @{{{Total}}} & @\,(\euro) \\
@1 & @some relatively long text for no reason & 3 & c2*\Rate \\
@2 & @Bar & 3 & c3*\Rate \\
@3 & @Baz & 1 & c4*\Rate \\
& @Total: & sum(c2:c4) & @{{{}}} \\
& @Rate: & @\Rate\xspace\euro & @{{{}}} \\
& @Sum netto: & & sum(d2:d4) \\
& @Tax 19\%: & & 0.19*[0,-1] \\
& @Total: & & :={[0,-1]+[0,-2]} & @\xspace\euro \\
\end{spreadtab}
\medskip\par
\closing{Bye}
\end{letter}
\end{document}