如何调整表格中某一列的文本?

如何调整表格中某一列的文本?

首先我要感谢您给予我的帮助。

在我制作的表格中,我想调整垂直文本的宽度(如图所示),以使其看起来更短。(我不知道用英语怎么说,希望你能理解)。在此处输入图片描述

 \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

  • 使用makecell包(用于旋转列标题中的单元格)
  • 利用包\rowcolors中的漏洞添加到列定义中 (`r<{\%}xcolor~%
  • 表格的宽度大于文本宽度。要适合文本区域,您有两种选择:
    • 进一步减小字体大小(至\scriptsize)或
    • 按照@Mico 在他的精彩回答中的建议旋转故事
\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}

在此处输入图片描述

答案2

像这样?请注意,我还 (a) 将多个\textcolor语句替换为单个\color语句,以及 (b) 将最后 8 列的列类型从 更改cr

我不得不对文档类别、主文档字体大小以及文档中使用的文本块的宽度和高度做出很多猜测。如果这些猜测大错特错,请告诉我。

在此处输入图片描述

\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}

相关内容