# Centered columns with fixed width using tabularx

How do I center the last seven columns in the attached text without dropping the fixed table width or the fixed column width?

\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}

• Can you make this into a complete compilable example? Nov 23 '14 at 16:39
• what is s ? and do you just want c (which centres) Nov 23 '14 at 16:42
• \newcolumntype{s}{>{\hsize=1.5cm}X} (which you did not even show in the original version of the question) will entirely break tabularx. You can not use an X column to get a fixed width, the whole point of X is to get variable width. Nov 23 '14 at 16:45
• Okay. Thanks. What should I then use to get a fixed column width while perserving the fixed table width in tabularx? Nov 23 '14 at 16:48
• @Marcus see answer but I wouldn't use tabularx, the first column looks like it should just be l and you can use a normal tabular (or tabular*) Nov 23 '14 at 16:50

You need p columns for fixed width, not X also there is not room for that many columns of 1.5cm so I changed it to 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}

• Can you do this with just tabularx shoul I find more explanation in tabluarx docs? Especially the meaning of this: >{\centering\arraybackslash? Feb 26 '19 at 10:39
• @snoram I'm not sure what you mean by "just tabularx" the above only uses tabularx, the > syntax should be described in any latex tutorial, it comes from the array package there are multiple examples in the array and tabularx doc and this site (it just inserts the centering code into each cell in that column). Feb 26 '19 at 11:14
• Sorry, I meant is what does this solution depend on apart from tabularx. I assume that, for example, I need to load the array package? Feb 26 '19 at 11:21
• @snoram for > yes or without array just put \centering in each cell directly Feb 26 '19 at 12:50