无法理解错误信息

无法理解错误信息

我正在尝试使用问题中提供的答案将 \headheight 改为 \pagestyle在自己的文档中,但无法理解出现的错误消息。

以下是文档:(已更新)

\documentclass{scrartcl}
\usepackage{lecturenotes}

\begin{lecture}{01}{Sample Lecture Notes}{Tom Jack}{01/01/2000}{Chris Karl}{PHYSICS 130: Physics of Energy}

\end{lecture}
\end{document}

以及样式文件lecturenotes.sty:(已更新)

\def\fileversion{1.0}
\def\filedate{2014/02/05}
\NeedsTeXFormat{LaTeX2e}

\usepackage{amsmath,amssymb,amsthm,amsfonts}
\usepackage[top=2cm, bottom=2cm, outer=5.5cm, inner=2cm, heightrounded, marginparwidth=3.5cm, marginparsep=0.4cm, includeheadfoot]{geometry}


\newcommand{\firstpagehead}{
    \framebox{
        \vbox{ 
            \hbox to 12.5cm { {\bfseries {\course}} \hfill {Lecture \lecturenum\ -- \lecturedate} }
            \vspace{4mm}
            \hbox to 12.5cm { {\Large \hfill {\lecturetitle}  \hfill} }
            \vspace{2mm}
            \hbox to 12.5cm { {\itshape {Lecturer: \lecturer} \hfill {Notes by: \lecturescribe}} }
        }
    }

}


\usepackage{scrpage2}

\newpagestyle{normalpage}{
{{\rlap{\lecturedate}\hfill \lecturetitle\hfill\llap{Lecture \lecturenum}}}
{{\rlap{\lecturedate}\hfill \lecturetitle\hfill\llap{Lecture \lecturenum}}}
{{\rlap{\lecturedate}\hfill \lecturetitle\hfill\llap{Lecture \lecturenum}}}
}{
{{\rlap{}\hfill \thepage\hfill\llap{}}}
{{\rlap{}\hfill \thepage\hfill\llap{}}}
{{\rlap{}\hfill \thepage\hfill\llap{}}}
}


\newpagestyle{firstpage}{
{\firstpagehead}
{\firstpagehead}
{\firstpagehead}
}{
{{\rlap{}\hfill \thepage\hfill\llap{}}}
{{\rlap{}\hfill \thepage\hfill\llap{}}}
{{\rlap{}\hfill \thepage\hfill\llap{}}}
}


\usepackage{afterpage}
\pagestyle{normalpage}
\addtolength{\textheight}{-3cm}
\addtolength{\headheight}{3cm}

\AtBeginDocument{
    \thispagestyle{firstpage}
    \addtolength{\textheight}{3cm}
    \afterpage{
        \global\advance\headheight by -3cm
    }
}

\newenvironment{lecture}[6]{
    \global \def \lecturenum {#1}
    \global \def \lecturetitle {#2}
    \global \def \lecturescribe {#3}
    \global \def \lecturedate {#4}
    \global \def \lecturer {#5}
    \global \def \course {#6}
    \begin{document}
}{}

答案1

您对新页面样式的使用完全不正确。要定义新页面样式,KOMA 脚本语法是(参见KOMA-Script 文档, 部分5.2.2. 专家界面,第 217 页起):

\newpagestyle{<name>}{<header definition>}{<footer definition>}

其中<header definition><footer definition>应该类似

(<ALL>,<ALT>){<EP>}{<OP>}{<OS>}(<BLL>,<BLT>)

具体来说,

  • <ALL>– 以上行长度:(页眉 = 外部,页脚 = 分隔线)
  • <ALT>– 高于线宽
  • <EP>– 偶数页定义
  • <OP>– 奇数页的定义
  • <OS>– 单面布局定义
  • <BLL>– 线下长度:(页眉 = 分隔线,页脚 = 外部)
  • <BLT>– 低于线的粗细

另外,创建宏的语法是\newcommand{\<csname>},而不是\newcommand{<csname>}。你使用了\newcommand{normalpagehead}。最后,你创建一个lecture没有结束的环境:

\newenvironment{lecture}
  {<begin>}% \begin{lecture}
  {<end>}% \end{lecture}

答案2

例如,虽然这并没有试图模仿你的格式,因为我不明白它看起来应该是什么样的。然而,这确实以一种相当合理的方式包含了信息:

\documentclass{scrartcl}
\usepackage{lipsum}
\usepackage{filecontents}
\begin{filecontents}{lecturenotes.sty}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{lecturenotes}[2014/02/05 v1.0 lecturenotes]
\def\fileversion{1.0}
\def\filedate{2014/02/05}

\RequirePackage{amsmath,amssymb,amsthm}% use \RequirePackage in a package or class file; \usepackage in the preamble; amssymb calls amsfonts
% \RequirePackage[top=2cm, bottom=2.5cm, outer=5.5cm, inner=2cm, heightrounded, marginparwidth=3.5cm, marginparsep=0.4cm, includeheadfoot]{geometry}% don't use geometry with the koma-script classes - koma-script manages this differently - or you could use a different class and use geometry, of course.

\newcommand*{\lecturenum}{}% make sure stuff is defined
\newcommand*{\lecturetitle}{}
\newcommand*{\lecturescribe}{}
\newcommand*{\lecturedate}{}
\newcommand*{\lecturer}{}
\newcommand*{\course}{}

\RequirePackage{scrpage2}

\clearscrheadfoot
\ihead[\bfseries\course]{\lecturedate}% use \bfseries/\textbf{} - not \bf
\chead[]{\lecturetitle}
\ohead[Lecture \lecturenum --- \lecturedate]{Lecture \lecturenum}
\cfoot{\pagemark}

% \RequirePackage{afterpage}
% \addtolength{\textheight}{-3cm}% don't do this (either use geometry with other classes or koma-script's facilities)
% \addtolength{\headheight}{3cm}
\AtBeginDocument{%
  \pagestyle{scrheadings}%
%     \thispagestyle{firstpage}
%     \addtolength{\textheight}{3cm}
%     \afterpage{
%         \global\advance\headheight by -3cm
%     }
}

\newcommand{\lecture}[6]{%
    \renewcommand*\lecturenum {#1}% use \newcommand/\renewcommand rather than \def etc. whenever possible
    \renewcommand* \lecturetitle {#2}%
    \renewcommand* \lecturescribe {#3}%
    \renewcommand*\lecturedate {#4}%
    \renewcommand* \lecturer {#5}%
    \renewcommand* \course {#6}%
    \cleardoublepage
    \thispagestyle{scrplain}%
    \begin{center}
        \Large\lecturetitle
    \end{center}
    {\itshape Lecturer: \lecturer\hfill Notes by: \lecturescribe}\bigskip\par% \itshape or \textit{} - not \it
}
\end{filecontents}
\usepackage{lecturenotes}

\begin{document}

\lecture{01}{Sample Lecture Notes}{James Cook}{01/01/2000}{Mark Cook}{PHYSICS 130: Physics of Energy}

\lipsum[1-20]% optional arguments in square brackets not curly ones

\end{document}

演讲笔记

显然这不是您想要的样子。我的代码旨在让您了解如何去做。正如 Werner 指出的那样,Koma-Script 手册包含大量信息。

相关内容