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}
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 specifyingp{5cm}
.Moreover, the right way to specify an
X
column is (commas can be omitted):where
<coef>
scales the widths of theX
columns, if there are more than oneX
column and takes into consideration the length\tabcolsep
,<align>
is the horizontal alignment (eitherr
,c
,l
orj
(default)) and<type>
is the vertical alignment (eitherp
(default),m
orb
).Specifying
is wrong for a few reasons: you are specifying a width coefficient of 5 (
5
), a centered column (c
) and a column typem
. Then you are redefining things addingp
which overwritesm
andr
which overwritesc
. The right definition in this case would have been: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: