我正在尝试创建一个如下所示的表格:
但不知道如何处理不同列的数量。例如,“学期计划”行有 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
的功能带入。请注意,此类表格可以跨页拆分,但只能在行之间拆分,而不能在多行行内拆分:longtable
tabularx
\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}
漂亮一点
更漂亮的内容看起来像这样(使用 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}