28

I want to create a table and to make all cells of a column emphasized. Is there a simple way to do it, or do I have to emphasize every single cell?

36

>{..} defines what to do before the cell

\documentclass{article}
\usepackage{array}% for extended column definitions    
\begin{document}

\begin{tabular}{c >{\em}c c}
foo & bar & baz
\end{tabular}

\end{document}
  • 2
    For this to work you need to \usepackage{array}. Otherwise you might get an "Error: Illegal character in array arg." – benroth Jul 19 '16 at 14:48
  • 2
    the reason why I used this package ... ;-) – user2478 Jul 19 '16 at 17:53
12

Just worth adding to @Herbert's answer, that you can also make an entire column bold with >{\bfseries}, used in exactly the same way as he uses >{\em}. The meaning of bfseries is discussed in detail here.

As stated in the comments here, you can use \normalfont{} to unbold the column header.

\begin{table}
    \begin{tabular}{>{\bfseries}l l}
        \toprule
        \normalfont{foo} & bar \\
        \midrule
        foo & baz \\
        bar & qux \\
        \bottomrule
    \end{tabular}
\end{table}

enter image description here

  • Similarly, \itshape is preferred in LaTeX over the legacy \em from TeX. (just like how \bf is deprecated in favor of \bfseries) – TedPavlic Sep 21 '17 at 19:27
1

A very elementary addon but I was unable to find this elsewhere online and it may save someone a few minutes of head-scratching: you can add multiple styles to each line with a space:

\begin{tabular}{|c |>{\huge \bfseries}c |}
\hline
\multicolumn{2}{|c|}{Using multiple styles on a column}\\
\hline
normal & bold and huge\\
\hline
0 & 0\\
\hline
1 & 1\\
\hline
\end{tabular}

enter image description here

  • 1
    Welcome to TeX.SX! Thanks for helping and answering. Useful to read: [How do I write a good answer?].(tex.stackexchange.com/help/how-to-answer) – Bobyandbob Nov 11 '17 at 23:13
  • 1
    How is this differing from the accepted answer? – Johannes_B Nov 12 '17 at 6:47
  • @Johannes_B Only the \huge as far as I can see, should we mark it as not an answer (comment)? – CarLaTeX Nov 12 '17 at 8:17
  • The idea of this answer is to show how to add 2 styles to a column, a concept for which I did not find another immediate answer. If this does not meet the standards of an answer feel free to delete it I was just trying to be helpful – Uzebeckatrente Nov 12 '17 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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