仅在 longtable 的第一行出现不必要的缩进

仅在 longtable 的第一行出现不必要的缩进

我的工作中有很多长表,我发现只有第一列的第一行是缩进的。其余行没有这种情况。我发现,对于另一种较小的表格(如表格),我的问题不会发生。

我正在寻找如何修复它,我找到了这篇文章,但解决方案对我没有用。 longtable 的左对齐 - 不需要的最小缩进

我用蓝色标出了错误。我希望第一行与第二行完全相等。 问题

有谁知道如何修复它吗?

首先十分感谢。

\documentclass[a4paper]{article}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{lipsum}  
\usepackage{booktabs,threeparttablex}
\usepackage{etoolbox}
\appto\TPTnoteSettings{\footnotesize}
\usepackage{caption}
\usepackage[labelfont=bf,labelsep=period]{caption} 
\usepackage{array}
\usepackage[lmargin=2.5cm, rmargin=2.5cm, top=2cm, bottom=2cm]{geometry} 

\begin{document}

\lipsum[2-6]

\begin{ThreePartTable}
\renewcommand\TPTminimum{\textwidth}
\setlength\LTleft{0pt}
\begin{TableNotes}[flushleft] 
    \footnotesize 
    \item[*] Footnote1
\end{TableNotes}

\begin{longtable}{| m{1.7cm} | m{2.1cm}| m{1.4cm}| m{2cm}| m{4.4cm}| m{1.7cm}|}
\caption{\textit{\textbf{It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout}}} \\
\hline
\textbf{Foo} & \textbf{Foo} & \textbf{Foo} & \textbf{Foo} & \textbf{Foo (Foo)} & \textbf{Foo\tnote{*}} \\ 
\hline
\endfirsthead
\multicolumn{6}{l}{\tablename\ \thetable:
\textit{It is a long established fact that a reader }(Cont\ldots)}\\
\hline
\textbf{Foo} & \textbf{Foo} & \textbf{Foo} & \textbf{Foo} & \textbf{Foo (Foo} & \textbf{Foo} \\ 
\hline
\endhead
\multicolumn{6}{l}{}\\
\endfoot
\noalign {\rule [-1.4ex]{6.7cm}{0.4pt}}
\insertTableNotes
\endlastfoot
\label{tab:CasosDosVarHom}
\multirow{4}{*}{10-343} & Foo & 2 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 1 & Foo & Fooooo (0.001) & F \\ 
                        & Foo & 6 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 4 & Foo & Foooo (0.001) & F \\ 
\hline
\multirow{4}{*}{10-343} & Foo & 2 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 1 & Foo & Fooooo (0.001) & F \\ 
                        & Foo & 6 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 4 & Foo & Foooo (0.001) & F \\ 
\hline
\multirow{4}{*}{10-343} & Foo & 2 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 1 & Foo & Fooooo (0.001) & F \\ 
                        & Foo & 6 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 4 & Foo & Foooo (0.001) & F \\ 
\hline
\multirow{4}{*}{10-343} & Foo & 2 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 1 & Foo & Fooooo (0.001) & F \\ 
                        & Foo & 6 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 4 & Foo & Foooo (0.001) & F \\ 
\hline
\multirow{4}{*}{10-343} & Foo & 2 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 1 & Foo & Fooooo (0.001) & F \\ 
                        & Foo & 6 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 4 & Foo & Foooo (0.001) & F \\ 
\hline
\multirow{4}{*}{10-343} & Foo & 2 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 1 & Foo & Fooooo (0.001) & F \\ 
                        & Foo & 6 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 4 & Foo & Foooo (0.001) & F \\ 
\hline
\multirow{4}{*}{10-343} & Foo & 2 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 1 & Foo & Fooooo (0.001) & F \\ 
                        & Foo & 6 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 4 & Foo & Foooo (0.001) & F \\ 
\hline
\end{longtable}
\end{ThreePartTable}

\end{document}

答案1

问题在于\label{tab:CasosDosVarHom}。您必须%在 的参数后面\label(输入行的末尾)添加 。否则,它会产生一个杂散空格。

行尾的百分号 (%) 有什么用?(为什么我的宏会产生额外的空间?)

\documentclass[a4paper]{article}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{lipsum}  
\usepackage{booktabs,threeparttablex}
\usepackage{etoolbox}
\appto\TPTnoteSettings{\footnotesize}
\usepackage{caption}
\usepackage[labelfont=bf,labelsep=period]{caption} 
\usepackage{array}
\usepackage[lmargin=2.5cm, rmargin=2.5cm, top=2cm, bottom=2cm]{geometry} 

\begin{document}

\lipsum[2-6]

\begin{ThreePartTable}
\renewcommand\TPTminimum{\textwidth}
\setlength\LTleft{0pt}
\begin{TableNotes}[flushleft] 
    \footnotesize 
    \item[*] Footnote1
\end{TableNotes}

\begin{longtable}{| m{1.7cm} | m{2.1cm}| m{1.4cm}| m{2cm}| m{4.4cm}| m{1.7cm}|}
\caption{\textit{\textbf{It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout}}} \\
\hline
\textbf{Foo} & \textbf{Foo} & \textbf{Foo} & \textbf{Foo} & \textbf{Foo (Foo)} & \textbf{Foo\tnote{*}} \\ 
\hline
\endfirsthead
\multicolumn{6}{l}{\tablename\ \thetable:
\textit{It is a long established fact that a reader }(Cont\ldots)}\\
\hline
\textbf{Foo} & \textbf{Foo} & \textbf{Foo} & \textbf{Foo} & \textbf{Foo (Foo} & \textbf{Foo} \\ 
\hline
\endhead
\multicolumn{6}{l}{}\\
\endfoot
\noalign {\rule [-1.4ex]{6.7cm}{0.4pt}}
\insertTableNotes
\endlastfoot
\label{tab:CasosDosVarHom}% <--ADD PERCENT HERE!!
\multirow{4}{*}{10-343} & Foo & 2 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 1 & Foo & Fooooo (0.001) & F \\ 
                        & Foo & 6 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 4 & Foo & Foooo (0.001) & F \\ 
\hline
\multirow{4}{*}{10-343} & Foo & 2 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 1 & Foo & Fooooo (0.001) & F \\ 
                        & Foo & 6 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 4 & Foo & Foooo (0.001) & F \\ 
\hline
\multirow{4}{*}{10-343} & Foo & 2 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 1 & Foo & Fooooo (0.001) & F \\ 
                        & Foo & 6 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 4 & Foo & Foooo (0.001) & F \\ 
\hline
\multirow{4}{*}{10-343} & Foo & 2 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 1 & Foo & Fooooo (0.001) & F \\ 
                        & Foo & 6 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 4 & Foo & Foooo (0.001) & F \\ 
\hline
\multirow{4}{*}{10-343} & Foo & 2 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 1 & Foo & Fooooo (0.001) & F \\ 
                        & Foo & 6 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 4 & Foo & Foooo (0.001) & F \\ 
\hline
\multirow{4}{*}{10-343} & Foo & 2 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 1 & Foo & Fooooo (0.001) & F \\ 
                        & Foo & 6 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 4 & Foo & Foooo (0.001) & F \\ 
\hline
\multirow{4}{*}{10-343} & Foo & 2 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 1 & Foo & Fooooo (0.001) & F \\ 
                        & Foo & 6 & Foo & Foooo (0.001) & F \\ 
                        & Foo & 4 & Foo & Foooo (0.001) & F \\ 
\hline
\end{longtable}
\end{ThreePartTable}

\end{document}

在此处输入图片描述

答案2

我会重新组织你的表格序言。\label标题后立即进行割草解决了你的问题:

\documentclass[a4paper]{article}
\usepackage[hmargin=2.5cm, vmargin=2cm]{geometry}
\usepackage{array, booktabs,
            longtable, multirow,
            threeparttablex}
\usepackage{etoolbox}
\appto\TPTnoteSettings{\footnotesize}
\usepackage{caption}
\usepackage[labelfont=bf,labelsep=period,
            textfont={it,bf}]{caption}
\usepackage{lipsum}

\begin{document}

\lipsum[2-6]

    \begin{ThreePartTable}
\renewcommand\TPTminimum{\textwidth}
\setlength\LTleft{0pt}
\begin{TableNotes}[flushleft]
    \footnotesize
    \item[*] Footnote1
\end{TableNotes}

\begin{longtable}{| m{1.7cm} | m{2.1cm}| m{1.4cm}| m{2cm}| m{4.4cm}| m{1.7cm}|}
\caption{It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout}
\label{tab:CasosDosVarHom}  \\  % <---
    \hline
\textbf{Foo}    & \textbf{Foo}  & \textbf{Foo}      
                & \textbf{Foo}  & \textbf{Foo (Foo)}    & \textbf{Foo\tnote{*}} \\
    \hline
\endfirsthead
\caption[]{It is a long established fact that a reader \dots (Cont.)}           \\
    \hline
\textbf{Foo}    & \textbf{Foo}  & \textbf{Foo}
                & \textbf{Foo}  & \textbf{Foo (Foo)}    & \textbf{Foo}          \\
    \hline
\endhead
    \hline
    \multicolumn{6}{r}{\footnotesize\textit{Continue on the next page}}         \\
\endfoot
    \hline
\insertTableNotes
\endlastfoot
\multirow{4}{*}{10-343} & Foo & 2 & Foo & Foooo (0.001)  & F \\*
                        & Foo & 1 & Foo & Fooooo (0.001) & F \\*
                        & Foo & 6 & Foo & Foooo (0.001)  & F \\*
                        & Foo & 4 & Foo & Foooo (0.001)  & F \\
\hline
\multirow{4}{*}{10-343} & Foo & 2 & Foo & Foooo (0.001)  & F \\*
                        & Foo & 1 & Foo & Fooooo (0.001) & F \\*
                        & Foo & 6 & Foo & Foooo (0.001)  & F \\*
                        & Foo & 4 & Foo & Foooo (0.001)  & F \\
\hline
\multirow{4}{*}{10-343} & Foo & 2 & Foo & Foooo (0.001)  & F \\*
                        & Foo & 1 & Foo & Fooooo (0.001) & F \\*
                        & Foo & 6 & Foo & Foooo (0.001)  & F \\*
                        & Foo & 4 & Foo & Foooo (0.001)  & F \\
\hline
\multirow{4}{*}{10-343} & Foo & 2 & Foo & Foooo (0.001)  & F \\*
                        & Foo & 1 & Foo & Fooooo (0.001) & F \\*
                        & Foo & 6 & Foo & Foooo (0.001)  & F \\*
                        & Foo & 4 & Foo & Foooo (0.001)  & F \\
\hline
\multirow{4}{*}{10-343} & Foo & 2 & Foo & Foooo (0.001)  & F \\*
                        & Foo & 1 & Foo & Fooooo (0.001) & F \\*
                        & Foo & 6 & Foo & Foooo (0.001)  & F \\*
                        & Foo & 4 & Foo & Foooo (0.001)  & F \\
\hline
\multirow{4}{*}{10-343} & Foo & 2 & Foo & Foooo (0.001)  & F \\*
                        & Foo & 1 & Foo & Fooooo (0.001) & F \\*
                        & Foo & 6 & Foo & Foooo (0.001)  & F \\*
                        & Foo & 4 & Foo & Foooo (0.001)  & F \\
\hline
\multirow{4}{*}{10-343} & Foo & 2 & Foo & Foooo (0.001)  & F \\*
                        & Foo & 1 & Foo & Fooooo (0.001) & F \\*
                        & Foo & 6 & Foo & Foooo (0.001)  & F \\*
                        & Foo & 4 & Foo & Foooo (0.001)  & F \\
\hline
\end{longtable}
    \end{ThreePartTable}
\end{document}

代码中的其他小改动使表格更加一致(在表格的每个部分的末尾添加行,表格在下一页继续的信息,仅在multirow单元格开始处启用表格分隔符)。

在此处输入图片描述

在此处输入图片描述

相关内容