將表格中的某些列水平置中至頁面

將表格中的某些列水平置中至頁面

我想將此表的第二列和第三列水平居中於頁面,以便“結構合金”和包層“會伸出到左側: 在此輸入影像描述

\documentclass{article}
\usepackage{booktabs, multirow, threeparttable}
\usepackage{siunitx}

\begin{document}
\begin{table}[htpb] \footnotesize
    \centering
    \begin{threeparttable}
        \caption{Material properties of cladding alloys compared to structural alloys at \SI{705}{\celsius}}
        \label{tab:properties}
        \begin{tabular}{rlc}
             \cmidrule[0.08em]{2-3}
            & Material & CTE (\SI{e-3}{\per\celsius}) \\ 
            \cmidrule[0.05em]{2-3}
            \multirow{2}{*}{Structural alloys \bigg\{} & 316H & 18.8 \\
            & 800H & 17.2 \\ 
            \cmidrule[0.05em]{2-3}
            \multirow{3}{*}{Claddings \Bigg\{} & Ni-201 & 15.8  \\ 
            & Hastelloy N & 14.3  \\ 
            & Haynes 242 & 13  \\ 
            \cmidrule[0.08em]{2-3}
        \end{tabular}
    \end{threeparttable}
\end{table}
\end{document}

答案1

無論如何,桌子看起來都會不平衡。

你可以不用\multirow;來做到這一點。按照公認的慣例,空白儲存格表示重複值。

\documentclass{article}
\usepackage{booktabs, multirow, threeparttable}
\usepackage{siunitx}

\begin{document}

\begin{table}[htpb]
\centering
\begin{threeparttable}

\caption{Material properties of cladding alloys compared 
  to structural alloys at \SI{705}{\celsius}}
\label{tab:properties}

\begin{tabular}{@{}llS[table-format=2.1]@{}}
\toprule
Type & Material & {CTE (\SI{e-3}{\per\celsius})} \\
\midrule
Structural alloy & 316H        & 18.8 \\
                 & 800H        & 17.2 \\
\midrule
Cladding         & Ni-201      & 15.8 \\
                 & Hastelloy N & 14.3 \\
                 & Haynes 242  & 13   \\
\bottomrule
\end{tabular}

\end{threeparttable}

\end{table}

\end{document}

在此輸入影像描述

另一種選擇看起來不那麼有吸引力:

\documentclass{article}
\usepackage{booktabs, multirow, threeparttable}
\usepackage{siunitx}

\begin{document}
\begin{table}[htpb]
    \centering
    \begin{threeparttable}
        \caption{Material properties of cladding alloys compared to structural alloys at \SI{705}{\celsius}}
        \label{tab:properties}
        \begin{tabular}{@{}r@{}lc}
             \cmidrule[0.08em]{2-3}
            & Material & CTE (\SI{e-3}{\per\celsius}) \\ 
            \cmidrule[0.05em]{2-3}
            \multirow{2}{*}{\llap{Structural alloys \bigg\{\ }} & 316H & 18.8 \\
            & 800H & 17.2 \\ 
            \cmidrule[0.05em]{2-3}
            \multirow{3}{*}{\llap{Claddings \Bigg\{\ }} & Ni-201 & 15.8  \\ 
            & Hastelloy N & 14.3  \\ 
            & Haynes 242 & 13  \\ 
            \cmidrule[0.08em]{2-3}
        \end{tabular}
    \end{threeparttable}
\end{table}
\end{document}

在此輸入影像描述

答案2

編輯: 在下面的OP評論之後,他似乎希望將列標題中帶有“材料”的列放置在文字寬度的中間。這可以透過將桌子移到左側來實現。這可以透過多種方式完成......在threeparttable我想到最簡單的想法後,使用隱形規則。因此,我從答案的第一個版本中更正了我的 MWE:

在此輸入影像描述

\documentclass{article}
\usepackage{booktabs, multirow, threeparttable}
\usepackage{siunitx}
\newlength\tabshift% added

%-------------------------------------------- to show page layout
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
\begin{table}[htpb] 
    %\footnotesize
    \centering
    \begin{threeparttable}
        \caption{Material properties of cladding alloys compared to structural alloys at \SI{705}{\celsius}}
        \label{tab:properties}
        \begin{tabular}{rlS}
             \cmidrule[0.08em]{2-3}
            & Material & {CTE (\SI{e-3}{\per\celsius})} \\
            \cmidrule[0.05em]{2-3}
            \multirow{2}{*}{Structural alloys \bigg\{} & 316H & 18.8 \\
            & 800H & 17.2 \\
            \cmidrule[0.05em]{2-3}
            \multirow{3}{*}{Claddings \Bigg\{} & Ni-201 & 15.8  \\
            & Hastelloy N & 14.3  \\
            & Haynes 242 & 13  \\
            \cmidrule[0.08em]{2-3}
        \end{tabular}
    \end{threeparttable}%
        \rule{0.5\tabshift}{0pt}% added
\end{table}
\end{document}

S我使用 package 將最後一個表格列更改為列類型siunitx。您可以對S列進行詳細規範,例如S[table-format=2.1](建議這樣做)。在您的特定情況下,兩種情況的結果是相同的。

注意事項(1):請在將來始終提供小而完整的文件(MWE:最小(非)工作範例),就像我上面所做的那樣。幫助那些願意幫助你的人。寫缺失的序言並不有趣...

筆記2):今後請更準確地表達您的問題:)。關於您下面的評論,您收到的兩個答案都是基於錯誤的假設。順便說一句,桌子的原始位置(在向左移動之前)似乎很好...

0.5您可以透過更改因素來微調表格位置,\rule{0.5\tabshift}{0pt}以根據您的喜好將表格放置在頁面上的最佳位置。

附錄: 在頁面上形成更好的表格視覺居中我將重新設計您的表格,如下所示:

\documentclass{article}
\usepackage{booktabs, makecell, multirow, threeparttable}
\usepackage{siunitx}

%---------------------------------------------------------------%
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
\begin{table}[htpb]
    \centering
    \begin{threeparttable}
        \caption{Material properties of cladding alloys compared to structural alloys at \SI{705}{\celsius}}
        \label{tab:properties}
        \begin{tabular}{rlS}
             \cmidrule[0.08em]{2-3}
            & Material & {CTE (\SI{e-3}{\per\celsius})} \\
            \cmidrule[0.05em]{2-3}
            \multirow{2}{*}{\makecell{Structural\\ alloys} \bigg\{} & 316H & 18.8 \\
            & 800H & 17.2 \\
            \cmidrule[0.05em]{2-3}
            \multirow{3}{*}{Claddings \Bigg\{} & Ni-201 & 15.8  \\
            & Hastelloy N & 14.3  \\
            & Haynes 242 & 13  \\
            \cmidrule[0.08em]{2-3}
        \end{tabular}
    \end{threeparttable}
\end{table}
\end{document}

在此輸入影像描述

答案3

我想將該表的第二列和第三列水平居中

c這可以透過使用所需的列來實現\begin{tabular}{rcc}

相關內容