[Tex/LaTex] tabu and space between columns

columnsspacingtabu

I have aproblem with column widths in tabu environment. I set dimensions of tables and columns. First columns should have the same width = 5cm, First and second table should have the same width = 19cm. But there is a significant shift = purple rectangle on an image. How can I fix it? I need to define total width of table and widths of columns. But i have no idea how:) So please help me

\documentclass[article, 12pt, oneside]{memoir}
\setstocksize{297mm}{210mm}
\settrimmedsize{297mm}{210mm}{*}
\settrims{0mm}{0mm}
\setlrmarginsandblock{10mm}{*}{1}
\setulmarginsandblock{20mm}{*}{1}
\checkandfixthelayout
\usepackage{polyglossia}
\usepackage{microtype}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{TeX Gyre Schola}
\usepackage{tabu}
\begin{document}
\begin{center}
    \begin{tabu} to 19cm {|X[5cm,p,l]|X[11cm,p,l]X[3cm,p,r]|}
        \multicolumn{3}{l}{ \textit{ \textls[100]{bla bla} } } \\
        \toprule
        bla bla                     & bla bla           & bla \\
        bla bla                     & bla bla           & bla \\
        bla bla                     & bla bla           & bla \\
        bla bla                     & bla bla           & bla \\
        bla bla                     & bla bla           & bla \\

    \end{tabu}
    \begin{tabu} to 19cm {|X[5cm,p,l]|X[14cm,p,l]|}
        \addlinespace[1cm]
        \multicolumn{2}{l}{ \textit{ \textls[100]{bla bla} } } \\
        \toprule
        bla bla & bla bla bla bla bla bla bla bla \\
        bla bla & bla bla bla bla bla bla bla bla \\
        bla bla & bla bla bla bla bla bla bla bla \\
    \end{tabu}
\end{center}
\end{document}

enter image description here

Best Answer

First of all, I've adjusted your code not to have bad boxes. If you omit the tabu length then it uses \linewidth.

If you use all columns of type X then the space is divided into the columns depending on the first parameter you give to the column.

So, specifying X[5] is not the same as specifying p{5cm}.

Moreover, the right way to specify an X column is (commas can be omitted):

X[<coef>,<align>,<type>]

where <coef> scales the widths of the X columns, if there are more than one X column and takes into consideration the length \tabcolsep, <align> is the horizontal alignment (either r, c, l or j (default)) and <type> is the vertical alignment (either p (default), m or b).

Specifying

X[5cm,p,l]

is wrong for a few reasons: you are specifying a width coefficient of 5 (5), a centered column (c) and a column type m. Then you are redefining things adding p which overwrites m and r which overwrites c. The right definition in this case would have been:

X[5,l,p]

where p can be omitted since it's the default.

If you want the result you're expecting, it is better to use fixed width columns and only the last one calculated (X).

This means that this is the right code to use:

\documentclass[article, 12pt, oneside]{memoir}
\setstocksize{297mm}{210mm}
\settrimmedsize{297mm}{210mm}{*}
\settrims{0mm}{0mm}
\setlrmarginsandblock{10mm}{*}{1}
\setulmarginsandblock{20mm}{*}{1}
\checkandfixthelayout
\usepackage{polyglossia}
\usepackage{microtype}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{TeX Gyre Schola}
\usepackage{tabu}
\begin{document}
\begin{center}
    \begin{tabu} {|p{5cm}|p{11cm}X[r]|}
        \multicolumn{3}{l}{ \textit{ \textls[100]{bla bla} } } \\
        \toprule
        bla bla                     & bla bla           & bla \\
        bla bla                     & bla bla           & bla \\
        bla bla                     & bla bla           & bla \\
        bla bla                     & bla bla           & bla \\
        bla bla                     & bla bla           & bla \\

    \end{tabu}
    \begin{tabu} {|p{5cm}|X[l]|}
        \addlinespace[1cm]
        \multicolumn{2}{l}{ \textit{ \textls[100]{bla bla} } } \\
        \toprule
        bla bla & bla bla bla bla bla bla bla bla \\
        bla bla & bla bla bla bla bla bla bla bla \\
        bla bla & bla bla bla bla bla bla bla bla \\
    \end{tabu}
\end{center}
\end{document} 

enter image description here

Related Question