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}
  • 5
    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

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.

| 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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