I'm trying to write my own class file for subsequent documents based on my template.

What I did is simply copy everthing from \documentclass to (but not including) \begin{document} and paste it into a new file called myclass.cls. Then I went on and replaced every \usepackage with \RequirePackage and \documentclass with \LoadClass. The document actually compiles but I'm missing lines in my header and footer.

This is my MWE which doesn't display any lines:

myclass.cls

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{myclass}[2016/02/21 My Class]

a4paper,
footsepline,
numbers=noenddot,
listof=totoc,
bibliography=totoc,
fontsize=10.5pt,
toc=flat
]{scrartcl}

\RequirePackage{scrlayer-scrpage}


mydoc.tex

\documentclass{myclass}

\begin{document}

Text
\end{document}


Without the separated class and everything in one file it works:

\documentclass[
a4paper,
footsepline,
numbers=noenddot,
listof=totoc,
bibliography=totoc,
fontsize=10.5pt,
toc=flat
]{scrartcl}

\usepackage{scrlayer-scrpage}

\begin{document}

Text
\end{document}


What am I missing? I think somehow the headsepline options isn't loaded with \LoadClass

• Writing a proper (wrapper-)class is not that easy. Converting some template is even more complicated and the result often bad (imho). – Johannes_B Feb 21 '16 at 15:25
• I get the header and also the footer if I add \ifoot{footer} – egreg Feb 21 '16 at 15:29
• @egreg header and footer are there but not the thin line between text body and header/footer. – user3105453 Feb 21 '16 at 16:42

With class option headsepline there will be a line below of the header when page style headings is used. With class option footsepline the line above the footer is printed with both page style headings and page style plain. Note that these class options set also the typearea options headinclude and footinclude.

But you are loading package scrlayer-scrpage and this package has its own options headsepline and footsepline. They also have a different syntax: Using them you can also set a width and a length to the lines. But without any values they simple activate the lines with .4pt width and the same length as header/footer.

While \documentclass passes the options to the packages options set with \LoadClass are not seen by the packages. So scrlayer-scrpage does not know that there should be lines below header and above footer. So you have to set the options explicitly for scrlayer-scrpage.

\begin{filecontents*}{myclass.cls}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{myclass}[2016/02/21 My Class]
\RequirePackage{fix-cm}
numbers=noenddot,
listof=totoc,
bibliography=totoc,
fontsize=10.5pt,
toc=flat,
DIV=calc
]{scrartcl}

\KOMAoptions{
footinclude
}
\recalctypearea

\end{filecontents*}

\documentclass{myclass}
\usepackage{blindtext}% dummy text
\clearpairofpagestyles

\begin{document}
\tableofcontents
\blinddocument
\end{document}


or

\begin{filecontents*}{myclass.cls}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{myclass}[2016/02/21 My Class]
\RequirePackage{fix-cm}
numbers=noenddot,
listof=totoc,
bibliography=totoc,
fontsize=10.5pt,
toc=flat,
DIV=calc
]{scrartcl}
\RequirePackage{scrlayer-scrpage}
\KOMAoptions{
footsepline
}
\recalctypearea
\end{filecontents*}

\documentclass{myclass}
\usepackage{blindtext}% dummy text
\clearpairofpagestyles

\begin{document}
\tableofcontents
\blinddocument
\end{document}


Some remarks:

I have replaced the old command \clearscrheadfoot by \clearpairofpagestyles. Loading scrlayer-scrpage already activates pagestyle scrheadings. Note that this package also redefines headings and plain as aliases of scrheadings and plain.scrheadings.

Note that there is no DIV value predefined for fontsize=10.5pt and the default paper size a4. So you will get a warning that DIV=1 is used. That means a good DIV value will be calculated. To avoid this warning I set DIV=calc explicitly.

In the first example I have used

\KOMAoptions{
footinclude
}
\recalctypearea


because the class options headsepline and footsepline sets the typearea options headinclude and footinclude. But if I use headsepline and footsepline as package options for scrlayer-scrpage I have to set the options headinclude and footinclude for typearea explicitly. The command \recalctypearea recalculates the page layout taking these options into account.

In the second example with

\usepackage{scrlayer-scrpage}
\KOMAoptions{
footsepline
}
\recalctypearea


headsepline and footsepline are used for both the package scrlayer-scrpage and the KOMA-Script class. So headinclude and footinclude are set automatically. But I have to use \recalctypearea too to recalculate the page layout.

If you do not want to set the typearea options headinclude and footinclude use headsepline and footsepline only as package options for scrlayer-scrpage.

• Thank you very much. Would you mind explaining the following lines briefly? DIV=calc and \KOMAoptions{ headinclude, footinclude } \recalctypearea – user3105453 Feb 22 '16 at 12:32
• See my updated answer. – esdd Feb 22 '16 at 13:43