4

first of all I want to thank you for the help that you given to me.

In the table that I made, I would like to adjust the width of the vertical text (shown in the pic.) so that It looks shorter. (Idk how to say in English, I hope you understand).enter image description here

 \begin{table}[ht!]
    \small 
   \centering
     \begin{tabular}{lllcccccccccccc}
     \textcolor[rgb]{ .329,  .51,  .208}{\textbf{Nombres}} & \textcolor[rgb]{ .329,  .51,  .208}{\textbf{Ap. Paterno}} & \textcolor[rgb]{ .329,  .51,  .208}{\textbf{Ap. Materno}} & \rotatebox[origin=lb]{90}{\textcolor[rgb]{ .329,  .51,  .208}{\textbf{Organización, estructura y actividad celular}}} & \rotatebox[origin=lb]{90}{\textcolor[rgb]{ .329,  .51,  .208}{\textbf{Procesos y funciones vitales}}} & \rotatebox[origin=lb]{90}{\textcolor[rgb]{ .329,  .51,  .208}{\textbf{Biología humana y salud}}} & \rotatebox[origin=lb]{90}{\textcolor[rgb]{ .329,  .51,  .208}{\textbf{Herencia y evolución}}} & \rotatebox[origin=lb]{90}{\textcolor[rgb]{ .329,  .51,  .208}{\textbf{Organismo y ambiente}}} & \rotatebox[origin=lb]{90}{\textcolor[rgb]{ .329,  .51,  .208}{\textbf{Ondas}}} & \rotatebox[origin=lb]{90}{\textcolor[rgb]{ .329,  .51,  .208}{\textbf{Mecánica}}} & \rotatebox[origin=lb]{90}{\textcolor[rgb]{ .329,  .51,  .208}{\textbf{Energía}}} & \rotatebox[origin=lb]{90}{\textcolor[rgb]{ .329,  .51,  .208}{\textbf{Macrocosmos y microcosmos}}} & \rotatebox[origin=lb]{90}{\textcolor[rgb]{ .329,  .51,  .208}{\textbf{Estructura Atómica}}} & \rotatebox[origin=lb]{90}{\textcolor[rgb]{ .329,  .51,  .208}{\textbf{Química Orgánica}}} & \rotatebox[origin=lb]{90}{\textcolor[rgb]{ .329,  .51,  .208}{\textbf{Reacciones Químicas y Estequiometría}}} \\
         \hline
     \rowcolor[rgb]{ .886,  .937,  .855} \textcolor[rgb]{ .329,  .51,  .208}{Vicente Joaquin } & \textcolor[rgb]{ .329,  .51,  .208}{Chamorro} & \textcolor[rgb]{ .329,  .51,  .208}{Carrizo} & \textcolor[rgb]{ .329,  .51,  .208}{57\%} & \textcolor[rgb]{ .329,  .51,  .208}{0\%} & \textcolor[rgb]{ .329,  .51,  .208}{100\%} & \textcolor[rgb]{ .329,  .51,  .208}{0\%} & \textcolor[rgb]{ .329,  .51,  .208}{57\%} & \textcolor[rgb]{ .329,  .51,  .208}{20\%} & \textcolor[rgb]{ .329,  .51,  .208}{33\%} & \textcolor[rgb]{ .329,  .51,  .208}{0\%} & \textcolor[rgb]{ .329,  .51,  .208}{100\%} & \textcolor[rgb]{ .329,  .51,  .208}{64\%} & \textcolor[rgb]{ .329,  .51,  .208}{60\%} & \textcolor[rgb]{ .329,  .51,  .208}{30\%} \\
     \textcolor[rgb]{ .329,  .51,  .208}{Vicente} & \textcolor[rgb]{ .329,  .51,  .208}{Donoso} & \textcolor[rgb]{ .329,  .51,  .208}{Vergara} & \textcolor[rgb]{ .329,  .51,  .208}{43\%} & \textcolor[rgb]{ .329,  .51,  .208}{0\%} & \textcolor[rgb]{ .329,  .51,  .208}{0\%} & \textcolor[rgb]{ .329,  .51,  .208}{0\%} & \textcolor[rgb]{ .329,  .51,  .208}{43\%} & \textcolor[rgb]{ .329,  .51,  .208}{60\%} & \textcolor[rgb]{ .329,  .51,  .208}{0\%} & \textcolor[rgb]{ .329,  .51,  .208}{25\%} & \textcolor[rgb]{ .329,  .51,  .208}{0\%} & \textcolor[rgb]{ .329,  .51,  .208}{9\%} & \textcolor[rgb]{ .329,  .51,  .208}{20\%} & \textcolor[rgb]{ .329,  .51,  .208}{39\%} \\
     \rowcolor[rgb]{ .886,  .937,  .855} \textcolor[rgb]{ .329,  .51,  .208}{Diego} & \textcolor[rgb]{ .329,  .51,  .208}{Herrera} & \textcolor[rgb]{ .329,  .51,  .208}{Mureno} & \textcolor[rgb]{ .329,  .51,  .208}{57\%} & \textcolor[rgb]{ .329,  .51,  .208}{0\%} & \textcolor[rgb]{ .329,  .51,  .208}{100\%} & \textcolor[rgb]{ .329,  .51,  .208}{0\%} & \textcolor[rgb]{ .329,  .51,  .208}{57\%} & \textcolor[rgb]{ .329,  .51,  .208}{40\%} & \textcolor[rgb]{ .329,  .51,  .208}{33\%} & \textcolor[rgb]{ .329,  .51,  .208}{25\%} & \textcolor[rgb]{ .329,  .51,  .208}{33\%} & \textcolor[rgb]{ .329,  .51,  .208}{36\%} & \textcolor[rgb]{ .329,  .51,  .208}{50\%} & \textcolor[rgb]{ .329,  .51,  .208}{35\%} \\
     \textcolor[rgb]{ .329,  .51,  .208}{Nicolás} & \textcolor[rgb]{ .329,  .51,  .208}{Urmeneta} & \textcolor[rgb]{ .329,  .51,  .208}{Gompertz} & \textcolor[rgb]{ .329,  .51,  .208}{29\%} & \textcolor[rgb]{ .329,  .51,  .208}{0\%} & \textcolor[rgb]{ .329,  .51,  .208}{0\%} & \textcolor[rgb]{ .329,  .51,  .208}{0\%} & \textcolor[rgb]{ .329,  .51,  .208}{14\%} & \textcolor[rgb]{ .329,  .51,  .208}{0\%} & \textcolor[rgb]{ .329,  .51,  .208}{67\%} & \textcolor[rgb]{ .329,  .51,  .208}{0\%} & \textcolor[rgb]{ .329,  .51,  .208}{67\%} & \textcolor[rgb]{ .329,  .51,  .208}{27\%} & \textcolor[rgb]{ .329,  .51,  .208}{20\%} & \textcolor[rgb]{ .329,  .51,  .208}{43\%} \\
     \rowcolor[rgb]{ .886,  .937,  .855} \textcolor[rgb]{ .329,  .51,  .208}{Joaquín} & \textcolor[rgb]{ .329,  .51,  .208}{Vera} & \textcolor[rgb]{ .329,  .51,  .208}{Sepúlveda} & \textcolor[rgb]{ .329,  .51,  .208}{100\%} & \textcolor[rgb]{ .329,  .51,  .208}{100\%} & \textcolor[rgb]{ .329,  .51,  .208}{100\%} & \textcolor[rgb]{ .329,  .51,  .208}{100\%} & \textcolor[rgb]{ .329,  .51,  .208}{43\%} & \textcolor[rgb]{ .329,  .51,  .208}{40\%} & \textcolor[rgb]{ .329,  .51,  .208}{17\%} & \textcolor[rgb]{ .329,  .51,  .208}{25\%} & \textcolor[rgb]{ .329,  .51,  .208}{0\%} & \textcolor[rgb]{ .329,  .51,  .208}{9\%} & \textcolor[rgb]{ .329,  .51,  .208}{30\%} & \textcolor[rgb]{ .329,  .51,  .208}{30\%} \\
     \hline
     \end{tabular}%
 \end{table}%
  • 1
    You can some like \parbox{4cm}{Organización, estructura y actividad celular} but consider the complete redesign of the table (for instance, transposing row and columns). BTW, you can use \color{} only one time before of the table instead of textcolor{} in each cell. – Fran Jun 24 at 4:11
  • Thanks, actually \parbox{} is useful, but now, the problem is that the distance between the text and hline is not enough. – Mijail Littin Jun 24 at 4:21
  • 1
    Add before ~, or \hspace{1em}, or any other horizontal spacer. – Fran Jun 24 at 4:32
  • In addition to what posted in the answers what do you think about to rotate of 45 degrees the vertical headers (having care to use for the last one(s) a shorter text)? BTW when a table is so unbalanced it may be useful also to exchange rows and columns or to split it in more tables – Hastur Jun 24 at 14:56
3
  • With use of the makecell package (for rotating cells in column headers)
  • Exploit \rowcolors from xcolor 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
\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}

enter image description here

5

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.

enter image description here

\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}
  • Thank you. The multitude of \textcolor is because of Excel2Latex package. The table looks much cleaner with your code.Can I replace \begin{sidewaystable} with \begin{table}? – Mijail Littin Jun 24 at 5:15
  • @MijailLittin - You asked, "Can I replace \begin{sidewaystable} with \begin{table}?" (and replace \end{sidewaystable} with \end{table}, right?) The short answer is, "you certainly can". The far more difficult issue is, will the tabular material will fit inside the text block if it is displayed in portrait mode? Assuming you're willing to reduce the relative font size to \scriptsize -- warning: many readers will find the result to be well-nigh unreadable -- and if use 10pt as the main font size, the tabular material could indeed (just) fit in portrait mode. – Mico Jun 24 at 12:37
  • You convert my table into another one so fast, how did you do that? I ask you because I have to fix more tables. – Mijail Littin Jun 24 at 18:24
  • @MijailLittin - First off, I had to make a slew of guesses about your document setup; these guesses may or may not be correct. Only you know. Second, I really made only three significant changes to your code snippet. These changes were (a) to get rid of the dozens of \textcolor directives and to insert a single \color directive, (b) to switch to landscape format -- the alternative (portrait format) would have required making the text so small as to make it virtually unreadable -- and (c) to implement your request to introduce automatic line breaks in the rotated column headers. – Mico Jun 25 at 3:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.