2

I am creating a longtabu with a caption. As you can see in below example the text is indented to far to the left. I attached a minimal example. Could somebody please explain what I am doing wrong?

\documentclass[11pt,a4paper]{book}
\usepackage[a4paper,showframe]{geometry}

\RequirePackage{luatex85}
\usepackage[table]{xcolor}      % xcolor: colors

\usepackage{tabu}
\usepackage{longtable}

%% Table captions above tables
\usepackage[
singlelinecheck=false
]{caption}

\begin{document}

\tabulinesep = ^2mm_2mm         
\begin{longtabu} to \textwidth { X[1] X[1]} % {<input1>} cell/cell size;
\caption{123123} \label{123} \vspace{-1em} \\
\rowfont{\leavevmode\color{white}\bfseries} % Set font color for the first row
\rowcolor{blue}                     % Set row color for the first row
1 & 2 \\
\endfirsthead
\caption[]{123123 - continued} \vspace{-1em} \\
\rowfont{\leavevmode\color{white}\bfseries} % Set font color for the first row
\rowcolor{blue}                     % Set row color for the first row
1 & 2 \\
\endhead
\everyrow{\tabucline[.4mm  blue]{}} % Set line between rows
3 & 4
\end{longtabu}
\vspace{0.5em}      % Vertical space at table end

\end{document} 

Wrong aligment

2

If you just want your caption left-aligned (not reaching into the margin), you should avoid using \vspace. Below there's a tidied-up version of your code.

longtabu

\RequirePackage{luatex85}
\documentclass[11pt]{book}
\usepackage[a4paper,showframe]{geometry}

\usepackage[table]{xcolor}      % xcolor: colors
\usepackage{tabu}
\usepackage{longtable}

%% Table captions above tables
\usepackage[singlelinecheck=false]{caption}

\begin{document}

\tabulinesep = ^2mm_2mm         
\begin{longtabu} to \textwidth { X[1] X[1]} % {<input1>} cell/cell size;
\caption{123123}\label{123}\\[-1em]
\rowfont{\leavevmode\color{white}\bfseries} % Set font color for the first row
\rowcolor{blue}                     % Set row color for the first row
1 & 2 \\
\endfirsthead
\caption[]{123123 - continued} \vspace{-1em} \\
\rowfont{\leavevmode\color{white}\bfseries} % Set font color for the first row
\rowcolor{blue}                     % Set row color for the first row
1 & 2 \\
\endhead
\everyrow{\tabucline[.4mm  blue]{}} % Set line between rows
3 & 4
\end{longtabu}
\vspace{0.5em}      % Vertical space at table end

\end{document} 

Update: If you need a centered caption, use \captionsetup{justification=centering} after the \usepackage.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.