A veces es necesario resaltar alguna fila en una tabla usando Latex, para hacer eso es un poco tedioso, pero los resultados son únicos.
Para usar colores y sombreado de filas en tablas en latex es necesario importar los siguientes paquetes:
\usepackage{color}
\usepackage{graphicx}
\usepackage{epsfig}
\usepackage{multirow}
\usepackage{multirow}
\usepackage{colortbl}
\usepackage[table]{xcolor}
\usepackage[table]{xcolor}
Antes de comenzar a usar un color, es necesario declararlo primero, antes de la etiqueta \begin{document}
\definecolor{lightgray}{gray}{0.9}
Para generar la siguiente tabla:
El código para generar dicha tabla es:
\begin{table}[!htb]
\rowcolors{1}{}{lightgray}
\centering
\begin{tabular}{p{5cm}p{5cm}}
\hline
\rowcolor[gray]{.1} \color{white}Column 1 & \color{white}Column 2\\
\hline
-&-\\
-&-\\
\cellcolor{lightgray}&Single-row\\
\cellcolor{lightgray}&Single-row\\
\multirow{-3}{*}{\cellcolor{lightgray}Multi-row (3)}&Single-row\\
-&-\\
-&-\\
\hline
\end{tabular}
\caption{Multirow table with all cells in the same color.}\label{tab:multi row}
\end{table}
\rowcolors{1}{}{lightgray}
\centering
\begin{tabular}{p{5cm}p{5cm}}
\hline
\rowcolor[gray]{.1} \color{white}Column 1 & \color{white}Column 2\\
\hline
-&-\\
-&-\\
\cellcolor{lightgray}&Single-row\\
\cellcolor{lightgray}&Single-row\\
\multirow{-3}{*}{\cellcolor{lightgray}Multi-row (3)}&Single-row\\
-&-\\
-&-\\
\hline
\end{tabular}
\caption{Multirow table with all cells in the same color.}\label{tab:multi row}
\end{table}
Para generar las siguientes tablas:
El código es:
\begin{table}[!htb]
\centering
\begin{tabular}{|l|l|l|}
\hline
\rowcolor[gray]{.1} \multicolumn{3}{|c|}{\color{white}Team sheet} \\
\hline
Goalkeeper & GK & Paul Robinson \\ \hline
\multirow{4}{*}{Defenders} & LB & Lucus Radebe \\
& DC & Michael Duberry \\
& DC & Dominic Matteo \\
& RB & Didier Domi \\ \hline
\multirow{3}{*}{Midfielders} & MC & David Batty \\
& MC & Eirik Bakke \\
& MC & Jody Morris \\ \hline
Forward & FW & Jamie McMaster \\ \hline
\multirow{2}{*}{Strikers} & ST & Alan Smith \\
& ST & Mark Viduka \\
\hline
\end{tabular}
\caption{Multirow table with all cells in the same color.}\label{tab:}
\end{table}
\begin{table}[!htb]
\rowcolors{2}{blue!15}{white}
\centering
\begin{tabular}{|c | c|}
\rowcolor{blue!50} % Heading with different color to highlight it
Heading1 & Heading2 \\ \hline
Row 1 column 1 & Row 1 column 2 \\
Row 2 column 1 & Row 2 column 2 \\
Row 3 column 1 & Row 3 column 2 \\
Row 4 column 1 & Row 4 column 2 \\
Row 5 column 1 & Row 5 column 2 \\ \hline
\end{tabular}
\caption{Multirow table with all cells in the hola mundo desde ayers same color.}\label{tab:multi}
\end{table}
\centering
\begin{tabular}{|l|l|l|}
\hline
\rowcolor[gray]{.1} \multicolumn{3}{|c|}{\color{white}Team sheet} \\
\hline
Goalkeeper & GK & Paul Robinson \\ \hline
\multirow{4}{*}{Defenders} & LB & Lucus Radebe \\
& DC & Michael Duberry \\
& DC & Dominic Matteo \\
& RB & Didier Domi \\ \hline
\multirow{3}{*}{Midfielders} & MC & David Batty \\
& MC & Eirik Bakke \\
& MC & Jody Morris \\ \hline
Forward & FW & Jamie McMaster \\ \hline
\multirow{2}{*}{Strikers} & ST & Alan Smith \\
& ST & Mark Viduka \\
\hline
\end{tabular}
\caption{Multirow table with all cells in the same color.}\label{tab:}
\end{table}
\begin{table}[!htb]
\rowcolors{2}{blue!15}{white}
\centering
\begin{tabular}{|c | c|}
\rowcolor{blue!50} % Heading with different color to highlight it
Heading1 & Heading2 \\ \hline
Row 1 column 1 & Row 1 column 2 \\
Row 2 column 1 & Row 2 column 2 \\
Row 3 column 1 & Row 3 column 2 \\
Row 4 column 1 & Row 4 column 2 \\
Row 5 column 1 & Row 5 column 2 \\ \hline
\end{tabular}
\caption{Multirow table with all cells in the hola mundo desde ayers same color.}\label{tab:multi}
\end{table}
Gracias por el aporte
ResponderBorrarGracias por el aporte
ResponderBorrarde nada
Borrar