表格位于页面中央 + 表格标题位于中央

表格位于页面中央 + 表格标题位于中央

我制作了下表:

在此处输入图片描述

我想让它完美,因为在我看来,表格的标题/说明没有完全居中。此外,我想让这个表格位于页面的中心。令人惊讶的是,如果我在第 6 页复制这个表格,我确实得到了居中的表格,但对于附录的第一页,它不起作用。

以下是代码:

\documentclass{article}
\usepackage[utf8]{inputenc}

\begin{document}

\newpage
\appendix
\setcounter{table}{0}
\renewcommand{\tablename}{TABLE}
\renewcommand{\figurename}{Appendix Figure}
\renewcommand{\thetable}{A\arabic{table}}
\setcounter{figure}{0}
\renewcommand{\thefigure}{A\arabic{figure}}

\section{Additional Tables and Figures} \label{appendixA}


\begin{table}[h]
\centering
\caption{OCCUPATIONS AND RELATIVE TASK INTENSITY}
  \addtolength{\tabcolsep}{-5pt}
\label{tableA1}
\begin{tabular}{lccc}
\toprule
\toprule
Occupation &
  \begin{tabular}[c]{@{}c@{}}Communication\\ intensity\\ index\end{tabular} &
  \begin{tabular}[c]{@{}c@{}}Manual\\ intensity\\ index\end{tabular} &
  \begin{tabular}[c]{@{}c@{}}C/M\\ percentile\end{tabular} \\ \hline
                                                & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} \\
Four occupations with highest C/M values &
  \multicolumn{1}{l}{} &
  \multicolumn{1}{l}{} &
  \multicolumn{1}{l}{} \\
\hspace{3mm}Financial managers                              & 0.830                & 0.210                & 0.999                \\
\hspace{3mm}Managers of properties and real estate          & 0.740                & 0.210                & 0.997                \\
\hspace{3mm}Editors and reporters                           & 0.870                & 0.200                & 0.997                \\
\hspace{3mm}Operations and systems researchers and analysts & 0.640                & 0.200                & 0.990                \\
                                                &                      &                      &                      \\
Five occupations with average C/M values        &                      &                      &                      \\
\hspace{3mm}Cashiers                                        & 0.380                & 0.730                & 0.562                \\
\hspace{3mm}Cooks, variously defined                        & 0.320                & 0.670                & 0.530                \\
\hspace{3mm}Hairdressers and cosmetologists                 & 0.300                & 0.620                & 0.498                \\
\hspace{3mm}Repairers of industrial electrical equipment    & 0.360                & 0.770                & 0.490                \\
\hspace{3mm}Kitchen workers                                 & 0.280                & 0.620                & 0.489                \\
                                                &                      &                      &                      \\
Four occupations with lowest C/M values         &                      &                      &                      \\
\hspace{3mm}Vehicle washers and equipment cleaners          & 0.040                & 0.720                & 0.021                \\
\hspace{3mm}Furniture and wood finishers                    & 0.010                & 0.720                & 0.021                \\
\hspace{3mm}Roofers and slaters                             & 0.010                & 0.640                & 0.020                \\
\hspace{3mm}Drywall installers                              & 0.000                & 0.720                & 0.006                \\ \hline
\end{tabular}
\end{table}

\end{document}

答案1

由于您只有几个子标题,我认为减少重复的最简单方法是插入一个额外的列,将其固定宽度设置为缩进的大小,例如3mm,并用于\multicolumn合并不应该缩进的单元格。

几点。
我将环境更改为tabularx带有Xcolumn-type 的环境;它会调整其列宽,以便列填充表格中的剩余空间。 \addlinespace[<optional v-sep>]是添加额外空间的更好方法,因为您使用了booktabs。目前,在这一行中

\renewcommand{\tabularxcolumn}[1]{>{\hangindent=2em}m{#1}}

X被重新定义为与数字进行中间垂直对齐。这可以更改为p{#1}(顶部对齐)或b{#1}(底部对齐)。由于缩进,我还添加了\hangiafter区分第一行和任何后续行(如果单元格太窄而无法容纳其内容)。

在此处输入图片描述

\documentclass{article}
\usepackage{booktabs}
\usepackage{tabularx}   % Added for the X column type
\usepackage{ragged2e}   % Added for \Centering
\usepackage{caption}
    \captionsetup[table]{position=top,skip=3pt}


\begin{document}
\newpage
\appendix
\setcounter{table}{0}
\renewcommand{\tablename}{TABLE}
\renewcommand{\figurename}{Appendix Figure}
\renewcommand{\thetable}{A\arabic{table}}
\setcounter{figure}{0}
\renewcommand{\thefigure}{A\arabic{figure}}

\section{Additional Tables and Figures}\label{appendixA}

%%% Added
\NewExpandableDocumentCommand\mc{O{3} m}{\multicolumn{#1}{@{}l@{}}{#2}}      % For unindented columns
\renewcommand{\tabularxcolumn}[1]{>{\hangindent=2em}m{#1}}                   % Redefines X
\newcolumntype{C}[1]{>{\Centering}p{#1}}

\begin{table}[h]
  % \addtolength{\tabcolsep}{-5pt}
  \setlength\tabcolsep{3pt}
  \centering
  \caption{OCCUPATIONS AND RELATIVE TASK INTENSITY}
  \label{tab:tableA1}
  \begin{tabularx}{\linewidth}{@{} p{3mm} @{} X C{2.5cm}C{1.5cm}C{1.5cm} @{}}
    \toprule
    \toprule
    \mc[2]{Occupation}
      & \begin{tabular}[c]{@{}c@{}}Communication\\ intensity\\ index\end{tabular}
      & \begin{tabular}[c]{@{}c@{}}Manual\\ intensity\\ index\end{tabular}
      & \begin{tabular}[c]{@{}c@{}}C/M\\ percentile\end{tabular} \\
    \midrule
    \addlinespace[\normalbaselineskip]
    \mc{Four occupations with highest C/M values} && \\
    & Financial managers                              & 0.830 & 0.210 & 0.999 \\
    & Managers of properties and real estate          & 0.740 & 0.210 & 0.997 \\
    & Editors and reporters                           & 0.870 & 0.200 & 0.997 \\
    & Operations and systems researchers and analysts & 0.640 & 0.200 & 0.990 \\
    \addlinespace[\normalbaselineskip]
    \mc{Five occupations with average C/M values} && \\
    & Cashiers                                        & 0.380 & 0.730 & 0.562 \\
    & Cooks, variously defined                        & 0.320 & 0.670 & 0.530 \\
    & Hairdressers and cosmetologists                 & 0.300 & 0.620 & 0.498 \\
    & Repairers of industrial electrical equipment    & 0.360 & 0.770 & 0.490 \\
    & Kitchen workers                                 & 0.280 & 0.620 & 0.489 \\
    \addlinespace[\normalbaselineskip]
    \mc{Four occupations with lowest C/M values}  && \\
    & Vehicle washers and equipment cleaners          & 0.040 & 0.720 & 0.021 \\
    & Furniture and wood finishers                    & 0.010 & 0.720 & 0.021 \\
    & Roofers and slaters                             & 0.010 & 0.640 & 0.020 \\
    & Drywall installers                              & 0.000 & 0.720 & 0.006 \\
    \bottomrule
  \end{tabularx}
\end{table}

\end{document}

答案2

  • 抱歉,我还是不清楚你想要什么。
  • 所以,这个答案是基于猜测
  • 看看以下建议是否能达到预期的效果
\documentclass{article}
%--------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{booktabs, makecell, tabularx}
\usepackage[skip=0.33\baselineskip]{caption}

\begin{document}
\newpage
\appendix
    \setcounter{table}{0}
    \renewcommand{\tablename}{TABLE}
    \renewcommand{\figurename}{Appendix Figure}
    \renewcommand{\thetable}{A\arabic{table}}
    \setcounter{figure}{0}
    \renewcommand{\thefigure}{A\arabic{figure}}

\section{Additional Tables and Figures} 
\label{appendixA}
\vfil
    \begin{table}[ht] 
\caption{OCCUPATIONS AND RELATIVE TASK INTENSITY} 
\label{tableA1} 
    \renewcommand\tabularxcolumn[1]{m{#1}}
\begin{tabularx}{\linewidth}{@{} Xccc @{}} 
    \toprule
Occupation 
    & \makecell{Communication\\ intensity index} 
        & \makecell{Manual\\ intensity index} 
            & \makecell{C/M\\ percentile}                       \\ 
    \midrule
\multicolumn{4}{@{}>{\bfseries}l}{Four occupations with highest C/M values}    \\ 
Financial managers  
    & 0.830 & 0.210 & 0.999                                     \\ 
Managers of properties and real estate          
    & 0.740 & 0.210 & 0.997                                     \\ 
Editors and reporters                           
    & 0.870 & 0.200 & 0.997                                     \\ 
Operations and systems researchers and analysts 
    & 0.640 & 0.200 & 0.990                                     \\ 
\multicolumn{4}{@{}>{\bfseries}l}{Five occupations with average C/M values}                                           \\
    \addlinespace
Cashiers                                        
    & 0.380 & 0.730 & 0.562                                     \\
Cooks, variously defined                        
    & 0.320 & 0.670 & 0.530                                     \\ 
Hairdressers and cosmetologists                 
    & 0.300 & 0.620 & 0.498                                     \\ 
Repairers of industrial electrical equipment    
    & 0.360 & 0.770 & 0.490                                     \\ 
Kitchen workers                                 
    & 0.280 & 0.620 & 0.489                                     \\ 
    \addlinespace
\multicolumn{4}{@{}>{\bfseries}l}{Four occupations with lowest C/M values}\\
Vehicle washers and equipment cleaners          
    & 0.040 & 0.720 & 0.021                                     \\
Furniture and wood finishers                    
    & 0.010 & 0.720 & 0.021                                     \\
Roofers and slaters                             
    & 0.010 & 0.640 & 0.020                                     \\
Drywall installers                              
    & 0.000 & 0.720 & 0.006                                     \\
    \bottomrule
\end{tabularx} 
    \end{table}
\end{document}

在此处输入图片描述

相关内容