[Tex/LaTex] New sectioning level above section

counterssectioning

I would like to create a newcounter (lectcount) which will be one level above the "section" in article class, and use its name in the headings (I am using fancyhdr).
I don't know how to set the hierarchy level above section, and also I don't know how to refer to its name in order to write it in the page headings.

I have come out with the following code. The end of \lecture definition was supposed to capture the lecture's name argument, which doesn't work. Any help will be appreciated.

\newcounter{lectcount}
\newcommand{\lecture}[1]{\refstepcounter{lectcount}%
    \noindent\textbf{\LARGE Lecture \thelectcount: #1}\par\bigskip%
    \let\lectname\#1}

\fancyhead[L]{Lecture \thelectcount: \lectname}

\begin{document}
\lecture{My First Lecture}
...
\end{document}

Best Answer

The easiest way is to use the report or book class and their \chapter command.

However, also the article class provides \part, that you can use above \section.

\documentclass[a4paper]{article}
\usepackage{fancyhdr}

\pagestyle{fancy}
\def\lecturemark{}
\fancyhf{}
\fancyhead[L]{\lecturemark}
\fancyfoot[C]{\thepage}

\newcommand{\lecture}[1]{\part{#1}\def\lecturemark{\partname\ \thepart: #1}}
\renewcommand{\partname}{Lecture}

% Let's customize \part
\usepackage{etoolbox}% for \patchcmd
\renewcommand{\thepart}{\arabic{part}}
\makeatletter
\patchcmd{\@part}{\par\nobreak}{: }{}{}
\patchcmd{\@part}{\huge}{\Large}{}{}
\makeatother

\usepackage{lipsum}

\begin{document}
\lecture{How to write lectures}
\section{First step: how to copy}
\lipsum
\end{document}

For more extensive changes to the appearance of the lecture title, copy in your document the definition of \@part in article.cls and modify that directly.

Related Question