对于标题,我想让它由三行组成,每行的单元格数量不同。但是,我尝试了以下方法,将三个表格堆叠在一起,导致最终结果不太理想。
因此,我想:
1-优化标题并找到更好的方法,如果可能的话,而不是三个表格相互叠放,
2- 使突出显示的单元格中的颜色覆盖整个单元格,而没有周围的白色边缘
3- 删除标题规则前第三行多余的垂直跳过。
小评论:
1-是否可以让标题高度预测所需的额外高度并自动设置,而不是反复试验?
2-为什么第一行单词右边有一个空格"right"
?
\documentclass[
addpoints,
]{exam}
\usepackage{lipsum,graphicx,mdframed,array,ragged2e,booktabs,fmtcount}
\usepackage[table]{xcolor}
\newcolumntype{L}[1]{>{\RaggedRight\hspace{0pt}}p{#1}}
\newcolumntype{R}[1]{>{\RaggedLeft\hspace{0pt}}p{#1}}
\newcolumntype{C}[1]{>{\Centering\hspace{0pt}}p{#1}}
\pagestyle{headandfoot}
\extraheadheight{3cm}
\firstpageheadrule
\firstpageheader%
{}%
{%
\setlength{\tabcolsep}{0em}
\begin{tabular*}{\textwidth}{@{}L{0.33\textwidth}C{0.33\textwidth}R{0.33\textwidth}@{}}
\toprule
left & center & right\\
\midrule
\end{tabular*}
\begin{tabular*}{\textwidth}{C{\textwidth}}
\cellcolor{gray!30}loooooooooooong text\\
\midrule
\end{tabular*}
\begin{tabular*}{\textwidth}{L{0.5\textwidth}R{0.5\textwidth}}
Some looooooooooooooooong sentence. & another one
\end{tabular*}
}%
{}
\begin{document}
\begin{questions}
\question some question
\end{questions}
\end{document}
答案1
\strut
此解决方案使用方框而不是表格。可以使用s 或增加轻松调整间距,使其更像表格\fboxsep
。
\documentclass[addpoints,]{exam}
\usepackage{lipsum,graphicx,mdframed,array,ragged2e,booktabs,fmtcount}
\usepackage[table]{xcolor}
\pagestyle{headandfoot}
\newsavebox{\headbox}
\savebox{\headbox}{\def\strut{\vrule height\arraystretch\ht\strutbox
depth\arraystretch\dp\strutbox width0pt}%
\parbox{\textwidth}{\hrule
\strut\rlap{left}\hfill\mbox{center}\hfill\llap{right}\hrule
\fboxsep=1pt
\colorbox{gray!30}{\makebox[\dimexpr \textwidth-2\fboxsep][c]{\strut loooooooooooong text}}\hrule
\strut Some looooooooooooooooong sentence.\hfill another one}}
\extraheadheight{\dimexpr \ht\headbox+\dp\headbox}
\firstpageheadrule
\firstpageheader%
{}%
{\usebox\headbox}%
{}
\begin{document}
\begin{questions}
\question some question
\end{questions}
\end{document}