17

I would like to italicize all of the names in the second column of a table, but presently the only way I have found to do this is to use \textit{} in each cell, i.e.:

\documentclass{article}

\begin{document}

\begin{table}
\begin{tabular}{lll}
PFT & Scientific Name & Common Name\\
PFT1 &  & \\
 & \textit{Elymus repens} & quackgrass\\
 & \textit{Koeleria macrantha} & prairie Junegrass\\
 & \textit{Elymus canadensis} & Canada wildrye\\
%....
\end{tabular}
\label{tab:foo}
\caption{test caption}
\end{table}

\end{document}

Is there an easier / more elegant way to do this?

4 Answers 4

14

Use the array package to specify \itshape for the second column, and use the \multicolumn command to cancel the effect for the header.

\documentclass{article}

\usepackage{array}

\begin{document}

\begin{tabular}{l>{\itshape}ll}
PFT & \multicolumn{1}{l}{Scientific Name} & Common Name\\
PFT1 &  & \\
 & Elymus repens & quackgrass\\
 & Koeleria macrantha & prairie Junegrass\\
 & Elymus canadensis & Canada wildrye\\
\end{tabular}

\end{document}
3
  • 4
    Instead of \multicolumn, you can also use \upshape or \textup{...}, although \multicolumn is more general. Nov 30, 2010 at 1:14
  • 6
    \normalfont also works.
    – Caramdir
    Nov 30, 2010 at 1:16
  • 2
    @Antal: My idea was not to counter \itshape, but to cancel whatever formatting may have been set for the column. @Caramdir: I didn't think of \normalfont.
    – lockstep
    Nov 30, 2010 at 6:38
1

Instead \multicolumn{1}{l}{Scientific Name} (as lockstep suggested) you can use \normaltext{Scientific Name} as follows:

\documentclass{article}

\usepackage{array}

\begin{document}

\begin{tabular}{l>{\itshape}ll}
PFT & \normaltext{Scientific Name} & Common Name\\
PFT1 &  & \\
 & Elymus repens & quackgrass\\
 & Koeleria macrantha & prairie Junegrass\\
 & Elymus canadensis & Canada wildrye\\
\end{tabular}

\end{document}
1

In {NiceTabular} of nicematrix, you have a built-in counter for the rows, called iRow (it's a LaTeX counter, not a TeX counter). So, it's easy to create a column specifier which will apply only after the first row.

\documentclass{article}
\usepackage{ifthen}
\usepackage{nicematrix}

\begin{document}

\newcolumntype{B}[1]{>{\ifthenelse{\value{iRow}>1}{#1}{}}}

\begin{NiceTabular}{lB{\itshape}ll}
PFT  & Scientific Name    & Common Name       \\
PFT1 &                    &                   \\
     & Elymus repens      & quackgrass        \\
     & Koeleria macrantha & prairie Junegrass \\
     & Elymus canadensis  & Canada wildrye    \\
\end{NiceTabular}

\end{document}

Output of the above code

1

An easy solution with tblr environment of tabularray package:

\documentclass{article}

\usepackage{tabularray}

\begin{document}

\begin{table}
\centering
\begin{tblr}{
  colspec = {lll},
  cell{2-Z}{2} = {font=\itshape}, % Z stands for the last
  hlines,
}
PFT  & Scientific Name    & Common Name       \\
PFT1 &                    &                   \\
     & Elymus repens      & quackgrass        \\
     & Koeleria macrantha & prairie Junegrass \\
     & Elymus canadensis  & Canada wildrye    \\
\end{tblr}
\label{tab:foo}
\caption{test caption}
\end{table}

\end{document}

enter image description here

You must log in to answer this question.

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