0

I am using the following code to format my tables for my thesis (template based on this question here: Wrap text in table column header AND fit table width to pagewidth

\usepackage[utf8]{inputenc}
\usepackage{fourier}
\usepackage{array}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{makecell}

\newcolumntype{Z}{ >{\centering\arraybackslash}X }

\renewcommand\theadfont{\bfseries}
%\renewcommand\theadalign{cc}
\usepackage[autolanguage, np]{numprint}

\begin{document}

\begin{table}[!h]
\setlength\tabcolsep{4pt}
\begin{tabularx}{\textwidth}{*{4}{Z}}
\toprule
\multicolumn{4}{c}{xxx xx xxxx}   \\
\midrule
\thead{miRNA}  & \thead{logFC \\ (ABCDEF vs \\ ABCFED) } & \thead{PValue} & \thead{False \\Discovery\\ Rate} \\%
\midrule
abcd efg hijka  & $-1.854$                                                & \np{9.52E-11}        & \np{8.41E-10}                         \\
abcd efg hijka  & $-1.815$                                                & \np{3.38E-09}        & \np{2.42E-08}                         \\
 \bottomrule
\end{tabularx}
\end{table}
a lot of text here to show text width a lot of text here to show text width a lot of text here to show text width a lot of text here to show text width a lot of text here to show text width a lot of text here to show text width a lot of text here to show text width

\end{document} 

enter image description here I was wondering how can I left align only the data in the first column of this table? Is there an easy way to maybe change the \newcolumntype{Z}{ >{\centering\arraybackslash}X } command to only leftalign data in the first column of the table and not the header? The other columns and headers should remain centered.

1
  • Welcome to TeX.SX! Declare the first column as l and input the header with \multicolumn{1}{c}{Header}
    – egreg
    Jan 4, 2018 at 20:41

1 Answer 1

1

This code should do it:

\begin{table}[!h]
\setlength\tabcolsep{4pt}
\begin{tabularx}{\textwidth}{X*{3}{Z}}
\toprule
\multicolumn{4}{c}{xxx xx xxxx}   \\
\cmidrule(lr){1-4}
\thead{miRNA}  & \thead{logFC \\ (ABCDEF vs \\ ABCFED) } & \thead{PValue} & \thead{False \\Discovery\\ Rate} \\%
\midrule
abcd efg hijka  & $-1.854$                                                & \np{9.52E-11}        & \np{8.41E-10}                         \\
abcd efg hijka  & $-1.815$                                                & \np{3.38E-09}        & \np{2.42E-08}                         \\
 \bottomrule
\end{tabularx}
\end{table}

since an Xcolumn, by default, is left-aligned, but \thead is centred (vertically and horizontally).

Additionally, I think \cmidrule(lr){1-4} between the first two rows will look nicer than \midrule.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .