Longtabu 标题问题

Longtabu 标题问题

我正在创建一个带有标题的长标签。如您在下面的示例中所见,文本缩进得太靠左了。我附上了一个最小示例。有人能解释一下我做错了什么吗?

\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} 

错误对齐

答案1

如果您只是希望标题左对齐(不延伸到边缘),则应避免使用\vspace。下面是代码的整理版本。

隆塔布

\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} 

更新:如果需要居中标题,请\captionsetup{justification=centering}在 后使用\usepackage

相关内容