禁忌改变垂直间距

禁忌改变垂直间距

我在使用 tabu 时遇到了一个实际问题:我的一个表格需要更改表格中间的垂直间距,例如前 6 行间距为 A,接下来的 4 行间距为 B。我想使用 \tabulinesep,但它会为整个表格设置一致的间距。我宁愿在开始时设置 \tabulinesep=2mm(像往常一样),然后在几行之后更改为 \tabulinesep=1mm,并将其保留在表格的其余部分。现在我采用“肮脏”的方式,但只是使用固定的 \tabulinesep=2mm,然后在我想要较短间距的每一行末尾添加 [-1mm]。但这不是很优雅,而且,当我的表格是彩色的时,您可以在放大 pdf 时看到由移位引起的重叠,所以看起来不太好。有什么建议吗?

我的代码:

\documentclass[DIN, 10pt, pagenumber=footmiddle,
    fromalign=right,  % Align sender to the right
    fromphone=false,
    fromemail=true,
    fromfax=false,
    fromlogo=false,
    fromrule=false]{scrlttr2}

\usepackage[english, ngerman]{babel} %load german as main and english as secondary
\usepackage[utf8]{inputenc} %typing in german characters like umlaut
\usepackage[scaled]{helvet} %the font for this document
\renewcommand*\familydefault{\sfdefault} %% Only if the base font of the document is to be sans serif
\usepackage[T1]{fontenc}    %standard font encoding
\usepackage{textcomp}       %for additional text fonts
\usepackage{tabularx}       %more table options, like fill-to-margin
\usepackage[table]{xcolor}  %colors in table enviroment
\usepackage{longtable}      %...for table something
\usepackage{array}          %...for table something
\usepackage{tabu}           %...for teble something
\usepackage{marvosym}       % Allows the use of symbols
\usepackage{fontawesome}    % nicer font for e.g. Email icon
\usepackage{booktabs}       %for rules in table for instance
\usepackage[nodayofweek,level]{datetime} %for better handling of Rechnungsdatum, Zahlungsdatum
\usepackage{graphicx}       %for pictures
\usepackage[scale=0.85]{geometry} %helps with setting of margins etc
\setlength{\parindent}{0cm} %no indentation in paragraphs

\usepackage{hyperref}       %always load at the end

%---------------------------------------------------------------------
%- color setting for the document ------------------------------------
%---------------------------------------------------------------------
\colorlet{headcolor}{gray!90!white}
\colorlet{tablecolor1}{gray!20!white}
\colorlet{tablecolor2}{gray!40!white}
\colorlet{footnotecolor}{gray!80!white}
%---------------------------------------------------------------
%=====================================================================
%=====================================================================

\begin{document}
\begin{letter}
This is how my table looks with consistent 1.7mm of line seperation by \begin{verbatim}\tabulinesep=1.7mm\end{verbatim} as you can see, the last square with subtotal,discount, VAT and total is also separated with 1.7mm but that's too wide, I would like to have smaller separation here, but retain the 1.7mm for the upper part of the table:
{\small
\tabulinesep=1.7mm
\begin{longtabu} to
\textwidth{X[0.5,c,m]X[2.5,L,m]X[3.5,L,m]X[1.4,c,m]X[0.6,c,m]X[1.5,r,m]}
    \taburowcolors 1{footnotecolor .. footnotecolor}
    \rowfont[c]{\bfseries}%
    \vbox to 0em{\kern -1.1em No.\vss} & 
    \vbox to 0em{\kern -1.1em Item \vss} & 
    \vbox to 0em{\kern -1.1em Description \vss} &
    Unit price (netto) & 
    \vbox to 0em{\kern -1.1em Qty. \vss} & 
    Line total (netto)\tabularnewline
    \taburowcolors 1{tablecolor1 .. tablecolor2}
    1 & stuff 1 &
    stuff 1 description &  400\,EUR$^*$ & 1 & 400\,EUR\\
    2 & stuff 2 &
    stuff 2 description & 300\,EUR$^*$ & 1 & 300\,EUR\\
    3 & stuff 3 &
    stuff 3 description & 1000\,EUR$^*$ & 1 & 1000\,EUR\\
    4 & stuff 4 &
    stuff 4 description & 600\,EUR$^*$ & 1 & 600\,EUR\\
    5 & stuff 5 &
    stuff 5 description & 1000\,EUR$^*$ & 1 & 1000\,EUR\\
    \taburowcolors 1{footnotecolor .. footnotecolor}
   & && \multicolumn{2}{r}{Subtotal}  & 3300\,EUR\\
   & && \multicolumn{2}{r}{Discount 40\%}  & $-$ 1320\,EUR\\
   & && \multicolumn{2}{r}{VAT.$^{**}$} & 0\,EUR\\
   & && \multicolumn{2}{r}{\bfseries Total}  &  \textbf{1980\,EUR}\\
\end{longtabu}
}
This is how I need it to look like - less separation in the bottom 4 lines. Now I do it the "dirty" way, by adding \begin{verbatim}[-1.7mm]\end{verbatim} at the end of the bottom rows but that just doesn't look good, especially if you zoom in on the document, you can see the overlap of the grey area from the shift:
{\small
\tabulinesep=1.7mm
\begin{longtabu} to
\textwidth{X[0.5,c,m]X[2.5,L,m]X[3.5,L,m]X[1.4,c,m]X[0.6,c,m]X[1.5,r,m]}
    \taburowcolors 1{footnotecolor .. footnotecolor}
    \rowfont[c]{\bfseries}%
    \vbox to 0em{\kern -1.1em No.\vss} & 
    \vbox to 0em{\kern -1.1em Item \vss} & 
    \vbox to 0em{\kern -1.1em Description \vss} &
    Unit price (netto) & 
    \vbox to 0em{\kern -1.1em Qty. \vss} & 
    Line total (netto)\tabularnewline
    \taburowcolors 1{tablecolor1 .. tablecolor2}
    1 & stuff 1 &
    stuff 1 description &  400\,EUR$^*$ & 1 & 400\,EUR\\
    2 & stuff 2 &
    stuff 2 description & 300\,EUR$^*$ & 1 & 300\,EUR\\
    3 & stuff 3 &
    stuff 3 description & 1000\,EUR$^*$ & 1 & 1000\,EUR\\
    4 & stuff 4 &
    stuff 4 description & 600\,EUR$^*$ & 1 & 600\,EUR\\
    5 & stuff 5 &
    stuff 5 description & 1000\,EUR$^*$ & 1 & 1000\,EUR\\
    \taburowcolors 1{footnotecolor .. footnotecolor}
   & && \multicolumn{2}{r}{Subtotal}  & 3300\,EUR\\[-1.7mm]
   & && \multicolumn{2}{r}{Discount 40\%}  & $-$ 1320\,EUR\\[-1.7mm]
   & && \multicolumn{2}{r}{VAT.$^{**}$} & 0\,EUR\\[-1.7mm]
   & && \multicolumn{2}{r}{\bfseries Total}  &  \textbf{1980\,EUR}\\
\end{longtabu}
How do I achieve a homogeneous 1.7mm consistent line separation for the whole table, but with the exclusion of the bottom 4 rows??
}
\end{letter}
\end{document}

相关内容