[Tex/LaTex] tabularx and array

boldtabularx

I need two things for my tables:

  1. text has to be able to wrap.
  2. the first row has to be bold

For 1, I need the package tabularx.
For 2, I need the package array and quite a lot of commands (see Make first row of table all bold)

However if I transpose the above commands into a tabularx (rather than tabular) things won't work (apparently).

Any ideas?

Best Answer

From your original description it wasn't clear that you need any packages, but I give an example using tabulary (tabularx's younger brother) where the column widths are chosen automatically.

enter image description here

\documentclass{article}

\usepackage{tabulary}

\begin{document}

\begin{tabular}{|p{2cm}|p{3cm}|p{2cm}|}
\bfseries\centering some bold words here&
\bfseries\centering and yet more bold&
\bfseries\centering heading for third column\tabularnewline
\hline
normal weight words go here normal weight words go here
normal weight words go here normal weight words go here
&
different words go here different words go here 
different words go here different words go here 
different words go here different words go here 
&
and this is the third column and this is the third column 
and this is the third column and this is the third column 
and this is the third column and this is the third column 
\end{tabular}

\bigskip        

\noindent\begin{tabulary}{\textwidth}{|J|J|J|}
\bfseries\centering some bold words here&
\bfseries\centering and yet more bold&
\bfseries\centering heading for third column\tabularnewline
\hline
normal weight words go here normal weight words go here
normal weight words go here normal weight words go here
&
different words go here different words go here 
different words go here different words go here 
different words go here different words go here 
&
and this is the third column and this is the third column 
and this is the third column and this is the third column 
and this is the third column and this is the third column 
\end{tabulary}

\end{document}