后续行动这个答案,我想知道为什么下面的不能编译并给出这个错误
! 未定义控制序列。\tcb@startbox ...x }{\tcb@w@upper }\tcb@lua@color {tcbcolupper}\kvtcb@fontup...
\documentclass{exam}
\usepackage{graphicx}
\usepackage[xparse,breakable,raster,skins]{tcolorbox}
\usepackage{calc}
\newcommand{\exProgram}{3\textsuperscript{rd} Year}
\newcommand{\CourseName}{Engineering}
\newcommand*{\CourseCode}{311}
\newcommand*{\exMidFinal}{Midterm}
\newcommand*{\exSemester}{Fall}
\newcommand\headerBody{%
\begin{tcolorbox}[
raster multicolumn = 3
]
\begin{tcbitemize}[
raster force size=false,
raster columns=2,
valign=bottom,
raster equal skip = 0mm,
blankest,
]
\tcbitem[add to width = 2cm, halign = left,]
University\\ Faculty\\
\exProgram
\tcbitem[add to width =-2cm, halign = right] \includegraphics[height=20 mm]{example-image}
\end{tcbitemize}
\end{tcolorbox}%
%
\vspace{5pt}\hrule\vspace{5pt}%
%
\begin{tcolorbox}[left=0pt,right=0pt]
\exMidFinal\\
\exSemester
\end{tcolorbox}
\begin{tcolorbox}[before upper*=\centering]
Course Code: \textbf{\CourseCode}
\end{tcolorbox}
\begin{tcolorbox}[halign=right]
1\\
2
\end{tcolorbox}%
%
\vspace{5pt}\hrule\vspace{5pt}%
%
\begin{tcolorbox}[
before upper*=\centering, equal height group=A,
interior engine = standard,
colback = gray,
raster multicolumn = 3,
top = 5pt, bottom = 5pt
]
\textbf{\CourseName}
\end{tcolorbox}%
%
\vspace{5pt}\hrule\vspace{5pt}%
%
\begin{tcolorbox}[
before upper*=\centering,
equal height group=A,
raster multicolumn = 3,
]
This exam contains
\end{tcolorbox}%
}
\newcommand\headerContents{%
\begin{minipage}{\linewidth}%
\begin{tcbraster}[
raster columns=3, raster rows=3,
raster equal height = rows,
raster every box/.style={minimum for current equal height group = 8 mm},
valign=center,
raster equal skip = 0mm,
top = 0mm, bottom = 0mm,
blankest,
nobeforeafter,
]
\headerBody%
\vspace*{5pt}%
\hrule%
\end{tcbraster}%
\end{minipage}%
}
\newlength{\headerTotalHeight}
\settototalheight\headerTotalHeight{\headerContents}
\pagestyle{headandfoot}
\firstpageheader{}{\headerContents}{}
\usepackage[
a4paper,
includehead,
top = 0mm,
headheight = \headerTotalHeight,
showframe
]{geometry}
\begin{document}
text
\end{document}
答案1
你永远不应该在序言中测量事物。字体设置可能会在文档开始时延迟。
在正确的地方做设置:
\AtBeginDocument{\settototalheight\headerTotalHeight{\headerContents}}
tcolorbox.sty
现在,如果你想知道为什么以前可以运行但现在却失败了?引入了更改,旨在利用 LuaTeX 颜色管理(如果可用)。这需要\tcb@lua@color
以合适的方式定义,包作者选择在文档开头进行此操作。
这意味着文档序言中的含义\tcb@lua@color
尚未可用,因此出现错误。