我想在 latex 中创建下面的表格。我正在使用xltabular
(12 列),但我无法使用 4 x 4 单元格 (菲玛)
我到目前为止已经做到了这一点...但我该如何实现这一目标呢?
(请查看新命令 \xltmulticolumn,通过这个我在 12 列网格中创建多列)
\documentclass[10pt,table]{report}
%%%%%%% Document configuration %%%%%%%
\usepackage[spanish,es-tabla]{babel}
\usepackage[table]{xcolor}
\usepackage[letterpaper, margin=25mm,includeheadfoot, headheight=33mm]{geometry}
\usepackage{ragged2e}
\decimalpoint
%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% Figures %%%%%%%%%%
\usepackage{graphicx}
%\usepackage{float}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[capposition=top]{floatrow}
%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%% Other %%%%%%%%%%%
\usepackage{xltabular}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{adjustbox}
\usepackage[normalem]{ulem}
%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%% Configuration %%%%%%%%%
%%%%%%%
% Color
%%%%%%%
\definecolor{codeColor}{RGB}{89,156,255}
\definecolor{blue}{RGB}{4, 121, 181}
\definecolor{link}{RGB}{25, 74, 141}
\definecolor{cherry}{RGB}{90, 18, 54}
\definecolor{lilac}{RGB}{174, 182, 211}
\definecolor{lightwhite}{RGB}{241, 241, 241}
%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%% Table %%%%%%%%%%%
\newcommand{\xltmulticolumn}[3]{
\multicolumn{#1}
{|>{\hsize=\dimexpr#1\hsize+\tabcolsep * (2 * (#1 - 1) )+\arrayrulewidth* (#1 - 2)\relax}#2|}
{#3}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%% Title %%%%%%%%%%%
\title{My title}
\author{Lorem ipsum}
\date{\today}
\newcommand{\inlinemaketitle}{{\let\newpage\relax\maketitle}}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\pagenumbering{gobble}
\nocite{*}
\frenchspacing
\renewcommand{\arraystretch}{2}
\begin{xltabular}{\textwidth}{| X | X | X | X | X | X | X | X | X | X | X | X |}
\endhead \hline
\endfoot \hline
% Título del protocolo %
\rowcolor{cherry}
\xltmulticolumn{12}{X}{
\centerline{\textcolor{white}{TÍTULO DEL PROTOCOLO}}
} \\ \hline
\xltmulticolumn{12}{X}{
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut sit amet turpis metus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae
} \\ \hline
% Datos del protocolo%
\rowcolor{cherry}
\xltmulticolumn{12}{X}{
\centerline{\textcolor{white}{DATOS DEL PROTOCOLO}}
} \\ \hline
\xltmulticolumn{4}{X}{
\raggedleft Número de revisión \\
\tiny{(Primera, segunda tercera o Protocolo para registro)}
} &
\xltmulticolumn{2}{X}{
Primera
} &
\xltmulticolumn{3}{X}{
\raggedleft Semestre
} &
\xltmulticolumn{3}{X}{
2022-2
}\\ \hline
\xltmulticolumn{4}{X}{
\raggedleft Número de proyecto asignado \\
\tiny{(Número asignado por el profesor de especialidad)}
} &
\xltmulticolumn{2}{X}{
} &
\xltmulticolumn{3}{X}{
\raggedleft Fecha\\
\tiny{(Fecha programada)}
} &
\xltmulticolumn{3}{X}{
2022
}\\ \hline
\rowcolor{cherry}
\xltmulticolumn{12}{X}{
\centerline{\textcolor{white}{ALUMNO 1}}
} \\ \hline
% Datos alumno %
\rowcolor{lightwhite}
\xltmulticolumn{8}{X}{
\centerline{DATOS ALUMNO 1}
} &
\xltmulticolumn{4}{X}{
\centerline{FIRMA}
} \\ \hline
% Inicio datos%
\xltmulticolumn{3}{c}{
\raggedleft Nombre del alumno
} &
\xltmulticolumn{5}{c}{
Lorem ipsum
} &
\xltmulticolumn{4}{c}{
\multirow{2}{*}{}
} \\ \hline
\xltmulticolumn{3}{c}{
\raggedleft Número de boleta
} &
\xltmulticolumn{5}{c}{
this is secret
} &
\xltmulticolumn{4}{c}{
} \\ \hline
\end{xltabular}
\end{document}
编辑:已改变 \xltmulticolumn{4}{X}
到 \xltmulticolumn{4}{c}
快速解决方案:更改
\hline
为\cline{1-8}
但我想知道是否有多行解决方案
答案1
像这样吗?
- 定义了新的列类型(C、L 和 R)
- 删除了所有本地
\raggedleft
命令 multirow
在使用\cline{1-8}
cel之前\multirow spned 8 lines in 4 rows, do it had to be declared as
\多行{8}{...}{...}`
\documentclass{report}
\usepackage[table]{xcolor}
%%%%%%%%%%% Fonts %%%%%%%%%%%
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\usepackage[altbullet]{lucidabr}
\usepackage{graphicx}
\usepackage{caption}
%%%%%%%%%%% Table %%%%%%%%%%%
\usepackage{multicol, multirow, xltabular}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newcolumntype{R}{>{\raggedleft\arraybackslash}X}
\newcommand\xltmulticolumn[3]%
{
\multicolumn{#1}
{|>{\hsize=\dimexpr#1\hsize + \tabcolsep*(2*(#1-1))
+ \arrayrulewidth*(#1-2)\relax}#2|}
{#3}
}
%%%%%%%%%%% Other %%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[hidelinks]{hyperref}
\usepackage[spanish]{cleveref}
\definecolor{codeColor}{RGB}{89,156,255}
\definecolor{blue}{RGB}{4, 121, 181}
\definecolor{link}{RGB}{25, 74, 141}
\definecolor{cherry}{RGB}{90, 18, 54}
\definecolor{lilac}{RGB}{174, 182, 211}
\definecolor{lightwhite}{RGB}{241, 241, 241}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\frenchspacing
\renewcommand{\arraystretch}{2}
\begin{xltabular}{\textwidth}{| *{12}{X}}
\endhead
\hline
\endfoot
\hline
\rowcolor{cherry}
\xltmulticolumn{12}{C}{\textcolor{white}{TÍTULO DEL PROTOCOLO}} \\
\hline
\xltmulticolumn{12}{X}{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut sit amet turpis metus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae} \\
\hline
% Datos del protocolo%
\rowcolor{cherry}
\xltmulticolumn{12}{C}{\textcolor{white}{DATOS DEL PROTOCOLO}} \\
\hline
\xltmulticolumn{4}{R}{Número de revisión
\tiny{(Primera, segunda tercera o Protocolo para registro)}}
& \xltmulticolumn{2}{R}{Primera}
& \xltmulticolumn{3}{R}{Semestre}
& \xltmulticolumn{3}{R}{2022-2} \\
\hline
\xltmulticolumn{4}{R}{Número de proyecto asignado
\tiny{(Número asignado por el profesor de especialidad)}}
& \xltmulticolumn{2}{X}{}
& \xltmulticolumn{3}{R}{Fecha
\tiny{(Fecha programada)}}
& \xltmulticolumn{3}{R}{2022} \\
\hline
\rowcolor{cherry}
\xltmulticolumn{12}{C}{\textcolor{white}{ALUMNO 1}} \\
\hline
\rowcolor{lightwhite}
\xltmulticolumn{8}{C}{DATOS ALUMNO 1}
& \xltmulticolumn{4}{C}{FIRMA} \\
\hline
\xltmulticolumn{3}{R}{Nombre del alumno}
& \xltmulticolumn{5}{C}{}
& \xltmulticolumn{4}{R}{\multirow{8}{=}{}} \\
\cline{1-8}
\xltmulticolumn{3}{R}{Número de boleta}
& \xltmulticolumn{5}{C}{}
& \xltmulticolumn{4}{C}{} \\
\cline{1-8}
\xltmulticolumn{3}{R}{Telefono de boleta}
& \xltmulticolumn{5}{C}{Lorem lipsum}
& \xltmulticolumn{4}{C}{} \\
\cline{1-8}
\xltmulticolumn{3}{R}{Correa Electronico}
& \xltmulticolumn{5}{C}{this is secret}
& \xltmulticolumn{4}{C}{} \\
\hline
\end{xltabular}
\end{document}