TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

    \noindent\textbf{\LARGE Lecture \thelectcount: #1}\par\bigskip%

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

\lecture{My First Lecture}
share|improve this question
Why don't you just use a chapter based class (like »report«) and rename "Chapter" to "Lecture"? – Thorsten Donig Oct 9 '11 at 8:50
Why would that be easier than editing "Part"? – PineApple Oct 9 '11 at 10:01
Because you only need to insert \renewcommand{\chaptername}{Lecture} into your preamble. – Thorsten Donig Oct 9 '11 at 10:05
But as I wanted with the part sectioning, I want to enter its name in the header, and also edit it's font. So it's not just changing the name – PineApple Oct 9 '11 at 10:22
Could all be done easily by the titlesec package. – Thorsten Donig Oct 9 '11 at 11:07
up vote 6 down vote accepted

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.



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

% Let's customize \part
\usepackage{etoolbox}% for \patchcmd
\patchcmd{\@part}{\par\nobreak}{: }{}{}


\lecture{How to write lectures}
\section{First step: how to copy}

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.

share|improve this answer
Thanks. btw is your first definition \def\lecturemark{} really necessary? it worked for me without it. and how do I override the fonts of the part sectioning? for example if I want the \part (and therefore the \lecture) to write **Lecture 1: How to write lecture ** in the same fontsize, unlike the part defaults. – PineApple Oct 9 '11 at 10:43
I see. Thanks again! and just out of curiousity, Why is editing the "Chapter" in book class easier than the "Part" in article, isn't it the same principle? and also, is it complicated to define a new counter and then fit it inside the hierarchy of the section, subsection etc.? (for example, if I want to use all sectioning commands, including "part".) Edit: you defined the font of the Lecture to be large. How do I change both the font name "Lecture 1", and it's name "My Lecture", to huge? – PineApple Oct 9 '11 at 10:44
@PineApple Just switch: \patchcmd{\@part}{\Large}{\huge}{}{} – egreg Oct 9 '11 at 11:00

Your Answer


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.