Graphics, Figures & TablesHow to highlight multiple rows in the table?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
gcheer3
Posts: 41
Joined: Wed Jun 25, 2008 4:39 pm

How to highlight multiple rows in the table?

Post by gcheer3 »

Code: Select all

\documentclass{article}
\usepackage{amsmath,amsthm,amssymb}

\begin{document}

\begin{tabular}{|l|l|l|} \hline
 \raisebox{0ex}{Immediate} & RR & Round Robin \\
& EF & Earliest First \\
& LL & Lightest Loaded \\ 

 \raisebox{0ex} {Batch} & MM & 0.546 \\
& MX & 0.7839 \\
& DL & $\sqrt{2}$ \\
& RC & $\frac{1}{2}$\\ 

 \raisebox{0ex}{Evolutionary} & PN & This paper \\
& ZO & Genetic Algorithm\\
& TA & Tabu search~\\
& SA & Simlulated Annealing \\ \hline
\end{tabular}
\end{document}

Hello,
I want to highlight multiple rows together (I want to make the font bold for the four rows in the middle of the table). I tried

Code: Select all

\textbf{\raisebox{0ex} {Batch} & MM & 0.546 \\
& MX & 0.7839 \\
& DL & $\sqrt{2}$ \\
& RC & $\frac{1}{2}$\}
It doesn't do the work. Thank you for any help.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

How to highlight multiple rows in the table?

Post by localghost »

The TeX FAQ come with a solution [1]. It requires only the array package.

Code: Select all

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{array}

\newcolumntype{$}{>{\global\let\currentrowstyle\relax}}
\newcolumntype{^}{>{\currentrowstyle}}
\newcommand{\rowstyle}[1]{%
  \gdef\currentrowstyle{#1}%
  #1\ignorespaces
}

\begin{document}
  \begin{tabular}{|$l|^l|^l|} \hline
    Immediate    & RR & Round Robin \\
                 & EF & Earliest First \\
                 & LL & Lightest Loaded \\
    \rowstyle{\bfseries}
    Batch        & MM & 0.546 \\
    \rowstyle{\bfseries}
                 & MX & 0.7839 \\
    \rowstyle{\bfseries}
                 & DL & $\boldsymbol{\sqrt{2}}$ \\
    \rowstyle{\bfseries}
                 & RC & $\boldsymbol{\frac{1}{2}}$\\
    Evolutionary & PN & This paper \\
                 & ZO & Genetic Algorithm\\
                 & TA & Tabu search~\\
                 & SA & Simlulated Annealing \\ \hline
  \end{tabular}
\end{document}
The \rowstyle command only affects the successing table row thus must be inserted for every row to be pointed out. The mathematical expressions have to be handled separately.

[1] TeX Frequently Asked Questions - How to change a whole row of a table


Thorsten
Post Reply