我们能否将表格中的标题设为“中心”,将内容设为“左侧”?

我们能否将表格中的标题设为“中心”,将内容设为“左侧”?

我们能否为表格内容制作centre标题和侧面?left

对于Testing 1 species, Class AA),是centre和好的。对于18, 17, 15, 18 and 18,17, 18 and 18,17,我们可以移至左侧吗?

table-number-alignment=center为所有人使用。

我的 MWE:

\documentclass[12pt,oneside]{book}

\usepackage[showframe]{geometry}
\usepackage{amsmath}
\usepackage{ragged2e}
\usepackage{makecell, multirow, tabularx}
\renewcommand\theadfont{\small\bfseries} % for bold in table using \small
\renewcommand\theadgape{}
\usepackage[svgnames, table]{xcolor}
\usepackage{hhline, boldline}
\usepackage{seqsplit, caption} %for table spacing to second row
\usepackage{booktabs, ragged2e} % Use booktabs rules and get rid of vertical rules, ragged2e to ragged text
\usepackage{siunitx} %for table spacing to second row
\usepackage{threeparttable} %to add footnote below table
\usepackage{tabulary}
\usepackage{graphicx}

\usepackage[font=small,labelfont={bf,sf}, textfont={sf}, justification=centering]{caption}

\begin{document}


\begin{table}[h!]
\centering
\sisetup{table-format=6.0, table-number-alignment=center, table-column-width=6.0cm}
 \begin{tabular}{lcc}
     \toprule
      & \multicolumn{2}{c}{\thead{Sample Number}}\\ 
     \cmidrule{2-3}
     & \thead{Testing1 species \\(Class AA)}
     & \thead{Testing2 species \\ (Class BB)} \\
     \midrule
    High Wavenlength & {18, 17, 15, 18} & {19, 18, 1, 11} \\
    Medium Wavenlength & {18, 17, 18} & {19, 18, 11} \\
    Low Wavenlength & {18, 17} & {19, 18} \\
     \bottomrule
    \end{tabular}
\end{table}


\end{document}

答案1

对于第 2 列和第 3 列,使用l( left) 类型的列,而不是c( center) 类型的列。标题将保持居中,因为的默认对齐方式\thead是水平居中。

在此处输入图片描述

\documentclass[12pt,oneside]{book}

\usepackage[showframe]{geometry}
\usepackage{amsmath}
\usepackage{ragged2e}
\usepackage{makecell, multirow, tabularx}
\renewcommand\theadfont{\small\bfseries} % for bold in table using \small
\renewcommand\theadgape{}
\usepackage[svgnames, table]{xcolor}
\usepackage{hhline, boldline}
\usepackage{seqsplit, caption} %for table spacing to second row
\usepackage{booktabs, ragged2e} % Use booktabs rules and get rid of vertical rules, ragged2e to ragged text
\usepackage{siunitx} %for table spacing to second row
\usepackage{threeparttable} %to add footnote below table
\usepackage{tabulary}
\usepackage{graphicx}

\usepackage[font=small,labelfont={bf,sf}, textfont={sf}, justification=centering]{caption}

\begin{document}


\begin{table}[h!]
\centering
 \begin{tabular}{lll}
     \toprule
      & \multicolumn{2}{c}{\thead{Sample Number}}\\ 
     \cmidrule{2-3}
     & \thead{Testing1 species \\(Class AA)}
     & \thead{Testing2 species \\ (Class BB)} \\
     \midrule
    High Wavenlength & 18, 17, 15, 18 & 19, 18, 1, 11 \\
    Medium Wavenlength & 18, 17, 18 & 19, 18, 11 \\
    Low Wavenlength & 18, 17 & 19, 18 \\
     \bottomrule
    \end{tabular}
\end{table}


\end{document}

相关内容