Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to use the answer supplied in question Change \headheight for a \pagestyle in my own document, but am having trouble understanding the error messages that come up.

Here is the document: (UPDATED)

\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}

And the style file lecturenotes.sty: (UPDATED)

\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}
}{}
share|improve this question
    
Consider switching to the new package scrlayer-scrpage. It is downwards compatible to scrpage2, but offers more features. –  Speravir Feb 8 at 23:30
add comment

2 Answers 2

up vote 6 down vote accepted

Your use of new page styles is completely incorrect. To define a new page style, the KOMA-Script syntax is (see the KOMA-Script documentation, section 5.2.2. The Interface for Experts, p 217 onward):

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

where <header definition> and <footer definition> should resemble

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

Specifically,

  • <ALL> – above line length: (header = outside, footer = separation line)
  • <ALT> – above line thickness
  • <EP> – definition for even pages
  • <OP> – definition for odd pages
  • <OS> – definition for one-sided layout
  • <BLL> – below line length: (header = separation line, footer = outside)
  • <BLT> – below line thickness

Also, the syntax for creating a macro is \newcommand{\<csname>}, not \newcommand{<csname>}. You've used \newcommand{normalpagehead}. Finally, you create a lecture environment that doesn't have an end:

\newenvironment{lecture}
  {<begin>}% \begin{lecture}
  {<end>}% \end{lecture}
share|improve this answer
1  
Also, there's no \begin{document}... OK. There is, but it is in completely the wrong place... –  cfr Feb 7 at 4:07
    
Thanks for the comprehensive rundown @Werner, I ended up getting completely confused trying to mix the code I saw in the "Change \headheight for a \pagestyle" question with the stuff I already had, which as you probably guessed used fancyhdr. I've straightened everything out, and it runs perfectly. Just one final question, with the code as it is now the header on the first page is lower than other header, and I'm not really sure why? Ill update the code in the question. –  Heisenbugs Feb 7 at 5:25
    
@Heisenbugs: This may be partially as a result of spurious spaces in your definitions (like \firstpagehead) as well as \AtBeginDocument (see What is the use of percent signs (%) at the end of lines?). However, it's sometimes better to mock up what you want and supply what you've tried, than to try and force something into something that it's not. Perhaps a follow-up question could be just that... –  Werner Feb 7 at 6:21
    
@Heisenbugs: Did you notice cfr’s comment? \begin{document} does not belong in a package definition and not even in an environment definition. –  Speravir Feb 7 at 22:28
add comment

For example, though this makes no attempt to emulate your formatting as I don't understand what it is meant to look like. This does, however, include the information in a fairly sane way:

\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}

lecture notes

Obviously this isn't how you want it to look. My code is rather intended to give you an idea about how to go about it. The Koma-Script manual has a lot of information, as Werner indicated.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.