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?

L.J.R.
  • 10,932

4 Answers4

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}
lockstep
  • 250,273
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

F. Pantigny
  • 40,250
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

L.J.R.
  • 10,932