使用 tabularx 固定宽度的居中列

使用 tabularx 固定宽度的居中列

如何使附加文本的最后七列居中而不丢失固定表格宽度或固定列宽度?

\documentclass[a4paper,12pt,oneside]{article}
\usepackage{amsmath,amssymb,bm,mathtools,amsthm}
\usepackage{graphicx}
\usepackage{float}
\usepackage{wrapfig,booktabs}
\usepackage{array}
\usepackage{multirow,dcolumn,booktabs}
\usepackage{threeparttable, tabulary, tabularx, placeins,tocloft,tocbibind}

\newcolumntype{s}{>{\hsize=1.5cm}X}

\begin{document}
\begin{threeparttable}\footnotesize
\centering
\begin{tabularx}{\textwidth}{Xsss|ssss}
\toprule
$\alpha$                &  & $ 1 $ & $ 2 $ & $ 3 $ & $ 4 $ & $ 5 $ & $ 6 $  \\
\bottomrule
\end{tabularx}
\end{threeparttable}

\end{document}

答案1

您需要p固定宽度的列,而且X也没有空间容纳那么多列,1.5cm所以我将其更改为 1.1

\documentclass[a4paper,12pt,oneside]{article}
\usepackage{amsmath,amssymb,bm,mathtools,amsthm}
\usepackage{graphicx}
\usepackage{float}
\usepackage{wrapfig,booktabs}
\usepackage{array}
\usepackage{multirow,dcolumn,booktabs}
\usepackage{threeparttable, tabulary, tabularx, placeins,tocloft,tocbibind}

\newcolumntype{s}{>{\centering\arraybackslash}p{1.1cm}}



\begin{document}
\begin{threeparttable}\footnotesize
\centering
\begin{tabularx}{\textwidth}{Xsss|ssss}
\toprule
$\alpha$                &  & $ 1 $ & $ 2 $ & $ 3 $ & $ 4 $ & $ 5 $ & $ 6 $  \\
\bottomrule
\end{tabularx}
\end{threeparttable}

\end{document}

相关内容