创建具有不同列的表

创建具有不同列的表

我正在尝试创建一个如下所示的表格:

在此处输入图片描述

但不知道如何处理不同列的数量。例如,“学期计划”行有 1 列,第 17 周有 2 列,其他行有 3 列。如果表格可以像这个 tcolorbox 表格一样分页,那就更好了:

\documentclass[12pt,a4paper]{article}
\usepackage{lipsum}
\usepackage{tcolorbox}
\tcbuselibrary{breakable}
\newtcolorbox{mybox}[1]{colframe=gray,fonttitle=\bfseries,adjusted
title=\centering#1,breakable}

\begin{document}

\begin{mybox}{Stuff}
\lipsum
\end{mybox}

\end{document}

编译后显示:

在此处输入图片描述

谢谢。

答案1

以下是使用 实现此目的的方法,它将ltablex的功能带入。请注意,此类表格可以跨页拆分,但只能在行之间拆分,而不能在多行行内拆分:longtabletabularx

\documentclass {article}
\usepackage[showframe]{geometry}
\usepackage[table, svgnames]{xcolor}
\usepackage{enumitem}

\usepackage{ltablex, ragged2e, bigstrut, multirow, makecell}
\setlength{\bigstrutjot}{10pt}
\setlength{\extrarowheight}{3pt}

\begin{document}

{\keepXColumns\sffamily
\setlist{wide=0pt, leftmargin=*}
\begin{tabularx}{\linewidth}{|c|*{2}{>{\arraybackslash\RaggedRight}X|}}
    \hline
\rowcolor{Gainsboro!60!Lavender} \multicolumn{3}{|c|}{\bfseries TERM PLAN\bigstrut} \\
\hline
\rowcolor{Gainsboro!60!Lavender}\bfseries WEEK & \centering\bfseries LEARNING OUTCOMES & \centering\bfseries TOPICS {\&} SKILLS \bigstrut\tabularnewline
\hline
\endfirsthead
  \multirow{5}{*}{15}
  & \begin{itemize}[nosep, before=\vspace*{-\baselineskip}, after=\vspace*{-\baselineskip}]
\item find the maximum or minimum value of a quadratic function
\item use the maximum or minimum value of a function to sketch the graph or determine the range for a given domain
\end{itemize}
 & \textbf{Quadratic Functions}
\begin{enumerate}[label=4.\arabic*, noitemsep, after=\vspace*{-\dimexpr\baselineskip-3pt}]
\item Maximum/Minimum value of a qua\-dratic expression
\item Roots of a quadratic equation
\item Solving quadratic inequalities
\end{enumerate} \\
\hline
17 & \multicolumn{2}{c}{\makecell{Revision for Continuous Assessment 3\\
 Continuous Assessment 3}\bigstrut} \\
 \hline
\end{tabularx}}

\end{document} 

在此处输入图片描述

答案2

可以使用多行和多列创建此类表格。请参阅多行文档

这是您表格的 MWE:

\documentclass[12pt,a4paper]{article}

\usepackage{multirow}
\usepackage{longtable}

\begin{document}

\begin{longtable}{cll}
\hline
\multicolumn{3}{c}{F}\\
\hline
Week & Learning Outcomes & Topics \& Skills\\
\hline
15 & Text... & Text... \\
\hline
16 & Text... & Text... \\
\hline
17 & \multicolumn{2}{c}{This is demo text}\\
\hline
18 & \multirow{2}{*}{This is demo text} & Hi\\
19 &  & Hi\\
\hline
\end{longtable}

\end{document}

这是最低要求,实际上并不美观。它产生以下内容: 表格来自 MWE

漂亮一点

更漂亮的内容看起来像这样(使用 booktabs 包):

\documentclass[12pt,a4paper]{article}

\usepackage{multirow}
\usepackage{longtable}
\usepackage{booktabs}

\begin{document}

\renewcommand{\arraystretch}{1.5} 

\begin{longtable}{cll}
\toprule
\multicolumn{3}{c}{F}\\
\midrule
Week & Learning Outcomes & Topics \& Skills\\
\hline
15 & Text... & Text... \\
\hline
16 & Text... & Text... \\
\hline
17 & \multicolumn{2}{c}{This is demo text}\\
\hline
18 & \multirow{2}{*}{This is demo text} & Hi\\
19 &  & Hi\\
\bottomrule
\end{longtable}

\end{document}

改进的表格

相关内容