如何设置部分 toprule 并制作均匀子列

如何设置部分 toprule 并制作均匀子列

首先,我的 LaTeX 代码,

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[letterpaper, top=0.25in, bottom=0.25in, left=0.25in, right=0.25in]{geometry}
\usepackage{multirow,array,varwidth,spreadtab,caption}
\usepackage{booktabs}
\usepackage{siunitx,booktabs,caption}
\usepackage{multirow,array,varwidth,spreadtab,}
\usepackage{siunitx,booktabs,caption}
\usepackage{ragged2e}
\newcolumntype{L}[1]{>{\RaggedRight\hspace{0pt}}p{#1}}
\newcolumntype{R}[1]{>{\RaggedLeft\hspace{0pt}}p{#1}}
%%% change contents font %%%
\usepackage[scaled]{helvet}
\renewcommand\familydefault{\sfdefault} 
\usepackage[T1]{fontenc}
%%% %%% %%% %%% %%% %%% %%%%
\begin{document}
\begin{table}
\large                              
\captionsetup{labelformat=empty,font=large}
\centering \caption{REVENUE INTERESTS}
\begin{tabular}{
  *{5}{S[table-format=1.4]}
 }
  \toprule
& {Expense}  & {Oil/}       & {Plant}    &       \\
& {Interest} & {Condensate} & {Products} & {Gas} \\
\cmidrule(lr){2-2} \cmidrule(lr){3-3} \cmidrule(lr){4-4} \cmidrule(lr){5-5}
\bf{INITIAL} & 1.2345 & 1.2345 & 1.2345 & 1.2345 \\
\bf{FINAL}   & 1.2345 & 1.2345 & 1.2345 & 1.2345 \\
\bf{REMARKS} & \multicolumn{4}{c}{\bf{ALL AMOUNTS ARE EXPRESSED IN THOUSANDS OF DOLLARS.}}\\
  \multicolumn{5}{l}{%
  \scriptsize
  %
}
\end{tabular}
\end{table}
\end{document}

导出表如下所示, 我目前处于

我想要将表格编辑成

1. 部分顶部规则线,使标题居中,缩短顶部规则。2. 均匀分布子列3. 减少标题与表格本身的垂直距离。

看起来应该像下面的图片一样, 希望以此结束

多谢。

答案1

您可以定义一个本地命令,将所有标题设置为\makebox相同的宽度;尝试不同的宽度,直到您满意为止。

在代码中,我只留下了排版表格所需的包。请注意,您不需要\caption,因为“收入兴趣”是表格的标题。

\documentclass{article}
\usepackage[T1]{fontenc}

%%% change contents font %%%
\usepackage[scaled]{helvet}
\renewcommand\familydefault{\sfdefault} 
%%% %%% %%% %%% %%% %%% %%%%

\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}
\begin{table}
\newcommand{\fl}[1]{\makebox[.15\textwidth]{#1}}
\centering
\begin{tabular}{
  l
  *{4}{S[table-format=1.4]}
 }
& \multicolumn{4}{c}{\textbf{REVENUE INTERESTS}}\\
\cmidrule[\heavyrulewidth]{2-5}
& {\fl{Expense}}  & {\fl{Oil/}}       & {\fl{Plant}}    &       \\
& {\fl{Interest}} & {\fl{Condensate}} & {\fl{Products}} & {\fl{Gas}} \\
\cmidrule(lr){2-2} \cmidrule(lr){3-3} \cmidrule(lr){4-4} \cmidrule(lr){5-5}
\textbf{INITIAL} & 1.2345 & 1.2345 & 1.2345 & 1.2345 \\
\textbf{FINAL}   & 1.2345 & 1.2345 & 1.2345 & 1.2345 \\
\textbf{REMARKS} & 
  \multicolumn{4}{c}{\textbf{ALL AMOUNTS ARE EXPRESSED IN THOUSANDS OF DOLLARS.}}\\
\bottomrule
\end{tabular}
\end{table}
\end{document}

在此处输入图片描述

\cmidrule使用以下选项,你可以得到正确的对齐方式table-alignment=right

\documentclass{article}
\usepackage[letterpaper, top=0.25in, bottom=0.25in, left=0.25in, right=0.25in]{geometry}
\usepackage[T1]{fontenc}

%%% change contents font %%%
\usepackage[scaled]{helvet}
\renewcommand\familydefault{\sfdefault} 
%%% %%% %%% %%% %%% %%% %%%%

\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}
\begin{table}
\newcommand{\fl}[1]{\makebox[.12\textwidth]{#1}}
\centering
\begin{tabular}{
  l
  *{4}{S[table-format=1.4,table-alignment=right]}
 }
& \multicolumn{4}{c}{\textbf{REVENUE INTERESTS}}\\
\cmidrule[\heavyrulewidth]{2-5}
& {\fl{Expense}}  & {\fl{Oil/}}       & {\fl{Plant}}    &       \\
& {\fl{Interest}} & {\fl{Condensate}} & {\fl{Products}} & {\fl{Gas}} \\
\cmidrule(lr){2-2} \cmidrule(lr){3-3} \cmidrule(lr){4-4} \cmidrule(lr){5-5}
\textbf{INITIAL} & 1.2345 & 1.2345 & 1.2345 & 1.2345 \\
\textbf{FINAL}   & 1.2345 & 1.2345 & 1.2345 & 1.2345 \\
\textbf{REMARKS} & 
  \multicolumn{4}{c}{\textbf{ALL AMOUNTS ARE EXPRESSED IN THOUSANDS OF DOLLARS.}}\\
\bottomrule
\end{tabular}
\end{table}
\end{document}

在此处输入图片描述

答案2

尝试:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[letterpaper, top=0.25in, bottom=0.25in, left=0.25in, right=0.25in]{geometry}
\usepackage{multirow,array,varwidth,spreadtab,caption}
\usepackage{booktabs}
\usepackage{siunitx,booktabs,caption}
\usepackage{multirow,array,varwidth,spreadtab,}
\usepackage{ragged2e}
\newcolumntype{L}[1]{>{\RaggedRight\hspace{0pt}}p{#1}}
\newcolumntype{R}[1]{>{\RaggedLeft\hspace{0pt}}p{#1}}
%%% change contents font %%%
\usepackage[scaled]{helvet}
\renewcommand\familydefault{\sfdefault}
\usepackage[T1]{fontenc}

\usepackage[active,floats,tightpage]{preview}% just for showing only table
    \setlength\PreviewBorder{1em}
%%% %%% %%% %%% %%% %%% %%%%
    \begin{document}
\begin{table}
\large
\centering 
\begin{tabular}{>{\bfseries}l}
\\
\\
\\[0.8em] % determined experimentally 
INITIAL         \\
FINAL           \\
REMARKS         \\%
    \end{tabular}
    \begin{tabular}{*{4}{S[table-format=1.4]}}
\multicolumn{4}{c}{\textbf{REVENUE INTERESTS.}} \\
    \toprule
{Expense}   &   {Oil/}      & {Plant}    &       \\
{Interest}  & {Condensate}  & {Products} & {Gas} \\
    \cmidrule(lr){1-1} \cmidrule(lr){2-2} \cmidrule(lr){3-3} \cmidrule(lr){4-4}
1.2345      & 1.2345        & 1.2345    & 1.2345 \\
1.2345      & 1.2345        & 1.2345    & 1.2345 \\
\multicolumn{4}{c}{\textbf{ALL AMOUNTS ARE EXPRESSED IN THOUSANDS OF DOLLARS.}}
    \end{tabular}
\end{table}
    \end{document}

在序言中我删除了重复的包。由于 Caption 没有被列举出来,我把它放在了第二个表格环境的第一行。

在此处输入图片描述

编辑: 您可以获得相等的列宽,以便在第二个表格环境中合并第一行和第二行(最后一行更宽,因为最后一行的文本太宽)。

    \begin{document}
\begin{table}
\large
\centering 
\begin{tabular}{>{\bfseries}l}
\\
\\[0.75em] 
INITIAL         \\
FINAL           \\
\midrule
REMARKS         \\%
    \end{tabular}%
    \begin{tabular}{*{4}{S[table-format=1.4]}}
\multicolumn{4}{c}{\textbf{REVENUE INTERESTS.}} \\
    \toprule
{Expense Interest}   
            &   {Oil/Condensate}      
                            & {Plant Products}    & {Gas} \\
    \cmidrule(lr){1-1} \cmidrule(lr){2-2} \cmidrule(lr){3-3} \cmidrule(lr){4-4}
1.2345      & 1.2345        & 1.2345    & 1.2345 \\
1.2345      & 1.2345        & 1.2345    & 1.2345 \\
    \midrule
\multicolumn{4}{c}{\textbf{ALL AMOUNTS ARE EXPRESSED IN THOUSANDS OF DOLLARS.}}
    \end{tabular}
\end{table}
    \end{document}

我只添加了表格内容......

在此处输入图片描述

相关内容