How do I get a table where the header in column 2 is wrapped, while keeping the width of the table = textwidth? As you can see from the attached figure, I have a long title for the 2nd column, which makes the column very wide, resulting in wrapping of the text (actual entries, not the title) in the first column. I guess in a more general sense, I want to prioritize wrapping of column titles over wrapping of actual column entries. (I am not stuck on using tabularx; I am happy to try any other package if it works.)
\documentclass[12pt]{report}
\usepackage{tabularx}
\begin{document}
\begin{table}[h]
\begin{tabularx}{\textwidth}{XXXX}
\hline
\multicolumn{4}{c}{xxx xx xxxx} \\ \hline
\textbf{miRNA} & \multicolumn{1}{l}{\textbf{logFC (ABCDEF vs ABCFED)}} & \textbf{PValue} & \textbf{False Discovery Rate} \\ \hline
abcd efg hijka & -1.854 & 9.52E-11 & 8.41E-10 \\
abcd efg hijka & -1.815 & 3.38E-09 & 2.42E-08 \\ \hline
\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}
\multicolumn{1}
for the header in the second column.[h]
on its own (latex normamly issues a warning and changes it to[ht]
but better to use[htp]
to give latex a chance not to take the float to the end of the document