Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
2  
You don't need tabularx to have columns with line wrapping a standard latex tabular p column will allow that. Why can't you just start each cell in the first row with \bfseries. –  David Carlisle Oct 5 '12 at 16:38
    
To the best of my knowledge, the problem with tabular p columns is that you have to choose a size, I want LaTeX to conveniently allocate it and this happens well with tabularx. Of course I can bfseries every entry of the first row, but if I am here is because I don't want to. –  Ale Oct 5 '12 at 19:28

2 Answers 2

You can also use the tabu package and its \rowfont command to easily modify the font and the alignment of each cell in one row:

\documentclass{article}
\usepackage{tabu}
\usepackage{booktabs}

\begin{document}

\noindent\begin{tabu} to \textwidth {@{}XXX<{\strut}@{}}
\toprule
\rowfont[c]{\bfseries} 
some bold words here & and yet more bold & heading for third column \\
\midrule
normal weight words go here normal weight words go here
normal weight words go here normal weight words go here
&
different words go here in the second column
different words go here in the second column
different words go here in the second 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 and this is the third column \\ 
\bottomrule
\end{tabu}

\end{document}

enter image description here

share|improve this 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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.