我正在尝试创建一个用户定义的环境来创建section
代码
\newenvironment{rSection}[1]{ % 1 input argument - section name
\sectionskip
\MakeUppercase{\bf #1} % Section title
\sectionlineskip
\hrule % Horizontal line
\begin{list}{}{ % List for each individual item in the section
\setlength{\leftmargin}{1.5em} % Margin within the section
}
\item[]
}{
\end{list}
}
定义环境后,我运行以下代码来创建一个部分
\begin{document}
\begin{rSection}{Education}
{\bf Institute of Business Administration, Karachi} \hfill {\em July 2016 - May 2020}
\\ BS Economics \& Mathematics \hfill { Overall CGPA: 3.03 }
\end{rSection}
\end{document}
上述代码导致以下错误
! Undefined control sequence.
\rSection #1-> \sectionskip
\MakeUppercase {\bf #1} \sectionlineskip \hrule ...
l.32 \begin{rSection}{Education}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
我是 Latex 的新手,不明白问题出在哪里?
我的序言如下
\documentclass{article}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage[parfill]{parskip} % Remove paragraph indentation
\usepackage{array} % Required for boldface (\bf and \bfseries) tabular columns
\usepackage{ifthen} % Required for ifthenelse statements
\pagenumbering{gobble}
我该如何解决这个问题?
答案1
欢迎使用 TeX.SE!错误消息:
! Undefined control sequence.
\rSection #1-> \sectionskip
\MakeUppercase {\bf #1} \sectionlineskip \hrule ...
l.32 \begin{rSection}{Education}
表示当从正在处理的文件的第 32 行开始扩展内容时,TeX\sectionskip
从宏的扩展中发现,而宏本身根据您对环境的定义\rSection
来自的扩展:\begin{rSection}{Education}
rSection
\newenvironment{rSection}[1]{ % 1 input argument - section name
\sectionskip
...
}
为了修复这种错误,需要让 TeX 知道这\sectionskip
意味着什么。在某些情况下,加载提供缺失命令的特定包就足够了。在您的例子中,这显然是您忘记定义的用户命令。
注意:这里可能存在间距错误,您应该删除百分号前的空格,如下所示:
\newenvironment{rSection}[1]{% <-- here
\sectionskip
...
}
(虽然,如果在垂直模式下使用,空间标记不会做任何事情;但严格一点更安全而且不花费任何东西,所以开始时最好谨慎行事)。