How could I adjust the text of a column in a table?
Something like this? Note that I've also (a) replaced the multitude of \textcolor
statements with a single \color
statement and (b) switched the column types of the final 8 columns from c
to r
.
I had to make quite a few guesses about the document class, the main document font size, and the width and height of the textblock in use in your document. If these guesses are wildly wrong, do please let me know.
\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage[a4paper,margin=2.5cm]{geometry}
\usepackage[table]{xcolor}
\usepackage{rotating,ragged2e,array}
\newcommand{\mybox}[1]{\parbox[b]{4.5cm}{\RaggedRight\bfseries #1}}
\newcommand\vertbox[1]{\rotatebox[origin=lb]{90}{~\mybox{#1}}}
\begin{document}
\begin{sidewaystable}
\setlength\extrarowheight{2pt} % for a more open "look"
\small
\centering
\color[rgb]{ .329, .51, .208} % we need just 1 \color statement
\begin{tabular}{ lll *{12}{r} }
\bfseries Nombres &
\bfseries Ap.\ Paterno &
\bfseries Ap.\ Materno
& \vertbox{Organización, estructura y actividad celular}
& \vertbox{Procesos y funciones vitales}
& \vertbox{Biología humana y salud}
& \vertbox{Herencia y evolución}
& \vertbox{Organismo y ambiente}
& \vertbox{Ondas}
& \vertbox{Mecánica}
& \vertbox{Energía}
& \vertbox{Macrocosmos y microcosmos}
& \vertbox{Estructura Atómica}
& \vertbox{Química Orgánica}
& \vertbox{Reacciones Químicas y Estequiometría} \\
\hline
\rowcolor[rgb]{ .886, .937, .855}
Vicente Joaquin & Chamorro & Carrizo &
57\% & 0\% & 100\% & 0\% & 57\% & 20\% & 33\% & 0\% & 100\% & 64\% & 60\% & 30\% \\
Vicente & Donoso & Vergara &
43\% & 0\% & 0\% & 0\% & 43\% & 60\% & 0\% & 25\% & 0\% & 9\% & 20\% & 39\% \\
\rowcolor[rgb]{ .886, .937, .855}
Diego & Herrera & Mureno &
57\% & 0\% & 100\% & 0\% & 57\% & 40\% & 33\% & 25\% & 33\% & 36\% & 50\% & 35\% \\
Nicolás & Urmeneta & Gompertz &
29\% & 0\% & 0\% & 0\% & 14\% & 0\% & 67\% & 0\% & 67\% & 27\% & 20\% & 43\% \\
\rowcolor[rgb]{ .886, .937, .855}
Joaquín & Vera & Sepúlveda &
100\% & 100\% & 100\% & 100\% & 43\% & 40\% & 17\% & 25\% & 0\% & 9\% & 30\% & 30\% \\
\hline
\end{tabular}
\end{sidewaystable}
\end{document}
- With use of the
makecell
package (for rotating cells in column headers) - Exploit
\rowcolors
fromxcolor
package add~%
to column definitions (`r<{\%} - The width of your table is greater than text width. To fit in text area you have two possibilities:
- further reduce font size (to
\scriptsize
) or - rotate tale as suggest @Mico in his nice answer
- further reduce font size (to
\documentclass[12pt]{article}
\usepackage[a4paper,margin=2.5cm,showframe]{geometry}
\usepackage[spanish]{babel}
\usepackage[table]{xcolor}
\usepackage{rotating}
\usepackage{makecell} % <--- new
\renewcommand{\theadfont}{\footnotesize\bfseries} % <--- new
\renewcommand{\theadgape}{} % <--- new
\newcommand\mcrh[1]{\multicolumn{1}{l}{\rothead{#1}}} % <--- new
\begin{document}
\begin{sidewaystable}
\setlength\extrarowheight{2pt} % for a more open "look"
\small
\centering
\settowidth\rotheadsize{\theadfont Organización, estructura} % <--- new
\color[rgb]{ .329, .51, .208} % we need just 1 \color statement
\definecolor{rowgreen}{rgb}{.886, .937, .855} % <--- new
\rowcolors{1}{white}{rowgreen} % <--- new
\begin{tabular}{lll *{12}{ r<{\%} } } % <--- changed
\mcrh{Nombres}
& \mcrh{Ap. Paterno}
& \mcrh{Ap. Materno}
& \mcrh{Organización, estructura y actividad celular}
& \mcrh{Procesos y funciones vitales}
& \mcrh{Biología humana y salud}
& \mcrh{Herencia y evolución}
& \mcrh{Organismo y ambiente}
& \mcrh{Ondas}
& \mcrh{Mecánica}
& \mcrh{Energía}
& \mcrh{Macrocosmos y microcosmos}
& \mcrh{Estructura Atómica}
& \mcrh{Química Orgánica}
& \mcrh{Reacciones Químicas y Estequiometría} \\
\hline
Vicente Joaquin & Chamorro & Carrizo
& 57 & 0 & 100 & 0 & 57 & 20 & 33 & 0 & 100 & 64 & 60 & 30 \\
Vicente & Donoso & Vergara
& 43 & 0 & 0 & 0 & 43 & 60 & 0 & 25 & 0 & 9 & 20 & 39 \\
Diego & Herrera & Mureno
& 57 & 0 & 100 & 0 & 57 & 40 & 33 & 25 & 33 & 36 & 50 & 35 \\
Nicolás & Urmeneta & Gompertz
& 29 & 0 & 0 & 0 & 14 & 0 & 67 & 0 & 67 & 27 & 20 & 43 \\
Joaquín & Vera & Sepúlveda
& 100 & 100 & 100 & 100 & 43 & 40 & 17 & 25 & 0 & 9 & 30 & 30 \\
\hline
\end{tabular}
\end{sidewaystable}
\end{document}