0

I'm using the titling package to allow me to have multiple \maketitle tags in a document.

I also want to have headers telling me which "section" (as given by the title) I am in.

However, the header changes before the chapter changes, see page 2 of the minimal example below.

\documentclass{article}
\usepackage[pagestyles]{titlesec} 
\usepackage{titling}
\usepackage{lipsum}

%% header
\makeatletter
\newpagestyle{main}{
\sethead[\@title][][] % even
{}{}{\textsl{\@title} % odd
\setfoot[\thepage][][] % even
{}{}{\thepage} % odd
}}
\pagestyle{main}

\renewcommand{\@maketitle}{\flushleft\LARGE\bfseries \@title \par}
\makeatother

\begin{document}

\title{First Title}
\maketitle

\lipsum


\title{Second Title}
\maketitle


\end{document}
5
  • 2
    My advice is to use a standard sectioning command such as \section
    – egreg
    Apr 17, 2014 at 21:40
  • If you want chapters, why are you using article? Plus why load titling but then redefine the low level command \@maketitle?
    – cfr
    Apr 18, 2014 at 0:08
  • To answer the first comment: This is a minimal example. In reality, we are writing many stand-alone worksheets that are then dropped into a master document. It is important that the stand-alone worksheets have "standard" latex syntax with \maketitle etc. Then using \input, and turning off \documentclass etc, we can get ourselves into a situation like the one above. So using \section doesn't help
    – Bart Snapp
    Apr 18, 2014 at 11:45
  • To answer the second comment: This may only be due to my ignorance. I needed to completely redo how tiles/abstracts are displayed. In fact, looking at the titling package, I am not sure it had the flexibility I needed. Again, this is a minimal working example, it shows the pathology I'm trying to fix.
    – Bart Snapp
    Apr 18, 2014 at 11:48
  • Ah! The fix is as simple as adding a \clearpage before the \title{Second Title}
    – Bart Snapp
    Apr 18, 2014 at 15:15

0

Browse other questions tagged .