长表、标题和注释需要调整位置 - 调整宽度不起作用

长表、标题和注释需要调整位置 - 调整宽度不起作用

我有一个问题,我想提交一篇文章,但是我需要使用期刊提供的模板,但模板有多个限制,例如左侧有巨大的偏移量。现在我想要一个跨多页的表格(所以我不能使用表格环境),但我无法以正确的方式调整它。标题和表格注释应该从左侧开始,没有偏移量。表格本身应该居中。目前表格注释也不在表格的公共环境中。我希望有人有解决方案!

表 1 显示了它应该是什么样子。表 2 显示了它目前的样子。

这是我的示例代码:

\documentclass[10pt,letterpaper]{article}
\usepackage[top=0.85in,left=2.75in,footskip=0.75in]{geometry}
\usepackage{changepage}
% Text layout
\raggedright
\setlength{\parindent}{0.5cm}
\textwidth 5.25in 
\textheight 8.75in

% Captions will be left justified
\usepackage[aboveskip=1pt,labelfont=bf,labelsep=period,justification=raggedright,singlelinecheck=off]{caption}

% Header and Footer
\usepackage{fancyhdr}
\pagestyle{myheadings}
\pagestyle{fancy}
\fancyhf{}
\setlength{\headheight}{27.023pt}
\rfoot{\thepage/\pageref{LastPage}}
\renewcommand{\footrule}{\hrule height 2pt \vspace{2mm}}
\fancyheadoffset[L]{2.25in}
\fancyfootoffset[L]{2.25in}

% ltablex package
\usepackage{ltablex}

\begin{document}

This is just a dummy text to show the general text layout.
This is just a dummy text to show the general text layout.
This is just a dummy text to show the general text layout.
This is just a dummy text to show the general text layout. \\

\begin{table}[!ht]
    \begin{adjustwidth}{-2.25in}{0in}
        \centering
        \caption{
            {\bf Table caption... This is how it should look like.}}
        \begin{tabular}{|l|l|l|l|l|l|l|l|}
            \hline
            \multicolumn{4}{|l|}{\bf Heading 1} & \multicolumn{4}{|l|}{\bf Heading 2}\\
            \hline
            $cell1 row1$ & cell2 row 1 & cell3 row 1 & cell4 row 1 & cell5 row 1 & cell6 row 1 & cell7 row 1 & cell8 row 1\\ \hline
            $cell1 row2$ & cell2 row 2 & cell3 row 2 & cell4 row 2 & cell5 row 2 & cell6 row 2 & cell7 row 2 & cell8 row 2\\ \hline
            $cell1 row3$ & cell2 row 3 & cell3 row 3 & cell4 row 3 & cell5 row 3 & cell6 row 3 & cell7 row 3 & cell8 row 3\\ \hline
        \end{tabular}
            \begin{flushleft} Table notes...
            \end{flushleft}
        \label{table1}
    \end{adjustwidth}
\end{table}

\begin{longtable}{|l|l|l|l|l|l|l|}%{@{\extracolsep{\fill}}|l+l|l|l|l|l|l|@{}}
    \caption{
    \bf{Table caption... This is how it looks like.}} \\
    \hline
    & \multicolumn{3}{l}{Top Heading 1} \vline & \multicolumn{3}{l}{Top Heading 2} \vline \\
Heading 1                 & Heading 2   & Heading 3   & Heading 4   & Heading 5 & Heading 6 & Heading 7 \\ 
    \hline
    \endfirsthead
    \multicolumn{7}{l}
{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
    \hline
    & \multicolumn{3}{l}{Top Heading 1} \vline & \multicolumn{3}{l}{Top Heading 2} \vline \\
Heading 1                 & Heading 2   & Heading 3   & Heading 4   & Heading 5 & Heading 6 & Heading 7 \\ 
    \hline
    \endhead
    \hline \multicolumn{7}{r}{\textit{Continued on next page}} \\
    \endfoot
    \hline
    \endlastfoot
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6        \\
    Text                   & 1         & 2     & 3          & 4       & 5       & 6             \label{table2}
\end{longtable}
Table notes...


\end{document}

先感谢您!

答案1

您可以使用负数 来移动边距中的长表\LTleft。标题caption也可以使用包和负边距来移动:

\usepackage{ltablex} 
\usepackage{caption}
\captionsetup[longtable]{margin=-2.25in}
\setlength{\LTleft}{-2.25in}

在此处输入图片描述

答案2

编辑: 在澄清了您下面评论中的问题后,现在很清楚了,您还希望有宽度longtable,但不会突出到右边距。为此,提供了一种解决方案乌尔里克回答如下,所以我在这里添加了一些可能需要的更改(长表与环境中的表具有相同的宽度adjustwidth):

看看您的 mwe 中的以下更改是否可以接受:

\documentclass{article}
\usepackage[letterpaper,
            top=0.85in,left=2.75in,footskip=0.75in]{geometry}
\usepackage{changepage}
% Text layout
\raggedright
\setlength{\parindent}{0.5cm}
%\textwidth 5.25in
%\textheight 8.75in

% Captions will be left justified
\usepackage[aboveskip=1pt,labelfont=bf,labelsep=period,
            justification=raggedright,singlelinecheck=off]{caption}

% Header and Footer
\usepackage{fancyhdr}
\pagestyle{myheadings}
\pagestyle{fancy}
\fancyhf{}
\setlength{\headheight}{27.023pt}
\rfoot{\thepage/\pageref{LastPage}}
\renewcommand{\footrule}{\hrule height 2pt \vspace{2mm}}
\fancyheadoffset[L]{2.25in}
\fancyfootoffset[L]{2.25in}

% ltablex package
\usepackage{makecell, % for two line column headers, macro  \thead{...\\...}
            ltablex}
\renewcommand\theadfont{\normalsize}
\renewcommand\theadgape{}

\begin{document}

This is just a dummy text to show the general text layout.
This is just a dummy text to show the general text layout.
This is just a dummy text to show the general text layout.
This is just a dummy text to show the general text layout. \\

\begin{table}[!ht]
    \begin{adjustwidth}{-2.25in}{0in}
        \centering
        \caption{Table caption... This is how it should look like.}
        \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
                                    |l|l|l|l|l|l|l|l|}
            \hline
            \multicolumn{4}{|l|}{\textbf{Heading 1}} & \multicolumn{4}{l|}{\textbf{Heading 2}}\\
            \hline
            $cell1 row1$ & cell2 row 1 & cell3 row 1 & cell4 row 1 & cell5 row 1 & cell6 row 1 & cell7 row 1 & cell8 row 1\\ \hline
            $cell1 row2$ & cell2 row 2 & cell3 row 2 & cell4 row 2 & cell5 row 2 & cell6 row 2 & cell7 row 2 & cell8 row 2\\ \hline
            $cell1 row3$ & cell2 row 3 & cell3 row 3 & cell4 row 3 & cell5 row 3 & cell6 row 3 & cell7 row 3 & cell8 row 3\\ \hline
        \end{tabular*}

        \raggedright
        Table notes...
        \label{table1}
    \end{adjustwidth}
\end{table}

{\setlength{\LTleft}{-2.25in}
 \setlength{\LTright}{0in}
 \setlength{\LTcapwidth}{\dimexpr\linewidth+4.5in\relax}
    \begin{longtable}{@{\extracolsep{\fill}}
                      |l|l|l|l|l|l|l|}

    \caption{Table caption... This is how it looks like.}
    \label{tab:my long table}\\
    \hline
    & \multicolumn{3}{l|}{Top Heading 1}
        & \multicolumn{3}{l|}{Top Heading 2}        \\
Heading 1 & Heading 2 & Heading 3 & Heading 4 & Heading 5 & Heading 6 & Heading 7 \\
    \hline
    \endfirsthead
    \caption{ -- \textit{Continued from previous page}} \\
    \hline
    & \multicolumn{3}{l|}{Top Heading 1} & \multicolumn{3}{l|}{Top Heading 2}        \\
Heading 1 & Heading 2 & Heading 3 & Heading 4 & Heading 5 & Heading 6 & Heading 7   \\

    \hline
    \endhead
    \hline \multicolumn{7}{r}{\textit{Continued on next page}} \\
    \endfoot
    \hline
    \endlastfoot
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6
\end{longtable}
}
Table notes...

\end{document}

得出的结果(第一页的顶部):

在此处输入图片描述

(第二页顶部):

在此处输入图片描述

  • 关于表格注释,看看是否threparttable(或threparttablex)可以改进写表格注释的技巧。
  • booktabs通过使用包中的规则并省略垂直规则,您将获得更专业的表格外观:

在此处输入图片描述

上述 mwe 的变化包括:

...
\usepackage{booktabs,
            ltablex}

\begin{document}

This is just a dummy text to show the general text layout.
This is just a dummy text to show the general text layout.
This is just a dummy text to show the general text layout.
This is just a dummy text to show the general text layout. \\

\begin{table}[!ht]
    \begin{adjustwidth}{-2.25in}{0in}
        \centering
        \caption{Table caption... This is how it should look like.}
        \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
                                     lll lll ll}
            \toprule
            \multicolumn{4}{l}{\textbf{Heading 1}} & \multicolumn{4}{l}{\textbf{Heading 2}}\\
            \midrule
            $cell1 row1$ & cell2 row 1 & cell3 row 1 & cell4 row 1 & cell5 row 1 & cell6 row 1 & cell7 row 1 & cell8 row 1\\ 
            $cell1 row2$ & cell2 row 2 & cell3 row 2 & cell4 row 2 & cell5 row 2 & cell6 row 2 & cell7 row 2 & cell8 row 2\\ 
            $cell1 row3$ & cell2 row 3 & cell3 row 3 & cell4 row 3 & cell5 row 3 & cell6 row 3 & cell7 row 3 & cell8 row 3\\ 
            \bottomrule
        \end{tabular*}

        \raggedright
        Table notes...
        \label{table1}
    \end{adjustwidth}
\end{table}

{\setlength{\LTleft}{-2.25in}
 \setlength{\LTright}{0in}
 \setlength{\LTcapwidth}{\dimexpr\linewidth+4.5in\relax}
    \begin{longtable}{@{\extracolsep{\fill}}
                      lll lll l
                      }
    \caption{Table caption... This is how it looks like.}
    \label{tab:my long table}\\
    \hline
    & \multicolumn{3}{l}{Top Heading 1}
        & \multicolumn{3}{l}{Top Heading 2}        \\
    \cmidrule(lr){2-4}\cmidrule(lr){5-7}
Heading 1 & Heading 2 & Heading 3 & Heading 4 & Heading 5 & Heading 6 & Heading 7 \\
    \toprule
    \endfirsthead
    \caption{ -- \textit{Continued from previous page}} \\
    \midrule
    & \multicolumn{3}{l}{Top Heading 1} & \multicolumn{3}{l|}{Top Heading 2}        \\
    \cmidrule(lr){1-4}\cmidrule(lr){5-7}
Heading 1 & Heading 2 & Heading 3 & Heading 4 & Heading 5 & Heading 6 & Heading 7   \\
    \midrule
    \endhead
    \midrule[\heavyrulewidth]
    \multicolumn{7}{r}{\textit{Continued on next page}} \\
    \endfoot
    \bottomrule
    \endlastfoot
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    \addlinespace
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    \addlinespace
    Text        & 1     & 2     & 3     & 4     & 5     & 6\\
    ...

相关内容