0

I came across a practical problem while using tabu: one of my tables requires to change the vertical spacing mid table, for example the first 6 rows with spacing A and next 4 rows with a shorter spacing B. I would like to use \tabulinesep, but it sets the spacing consistently for the whole table. I would rather want to set e.g. \tabulinesep=2mm an the beginning (like usual), but then change to \tabulinesep=1mm after some rows and keep it for the rest of the table. Right now I do it the "dirty" way, but just using that fixed \tabulinesep=2mm and then adding [-1mm] at the end of every row that I want the shorter spacing at. But that's not very elegant and also, when my table is colored, you can see the overlap caused by the shift when zooming in in the pdf, so it doesn't look very good. Any suggestions?

My code:

\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}
  • 2
    Check the readme and the issue list here github.com/tabu-issues-for-future-maintainer/tabu and then decide if you still want to use tabu. – Ulrike Fischer Jul 12 at 22:56
  • Please make your MWE (Minimal Working Example) really minimal. Remove all what is not related to the your table. Instead of longtabu try to use xltabular (if your table is longer than one page) or tabularx if it is shorter. – Zarko Jul 13 at 17:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.