16

This is the barebones of my document:

\documentclass[12pt]{article}

\begin{document}

\begin{center}
    \textbf{\LARGE{Topic I}}
 \end{center}

\section{Section I}
content

\section{Section II}
content

\subsection{Subsection I} 
content

\subsection{Subsection II}
content

\section{Section III}
content

\begin{center}
    \textbf{\LARGE{Topic II}}
 \end{center}

\section{Section I}
content

\section{Section II}
content

\subsection{Subsection I} 
content

\subsection{Subsection II}
content

\section{Section III}
content

\end{document}

which displays like

this.

I want the section numbering to restart at Topic II.

14

Instead of providing headings manually (which can be prone-error and implies a lot of manual intervention), you can redefine the \part command to give the desired layout; then you can make the section counter reset every time part is incremented:

\documentclass[12pt]{article}

\makeatletter
\@addtoreset{section}{part}
\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >\m@ne
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    {\parindent \z@ \raggedright
     \interlinepenalty \@M
     \normalfont\centering
     \ifnum \c@secnumdepth >\m@ne
       \LARGE\bfseries \partname\nobreakspace\thepart
       \par\nobreak
     \fi
     \huge \bfseries #2%
     \markboth{}{}\par}%
    \nobreak
    \vskip 3ex
    \@afterheading}
\renewcommand\partname{Topic}
\makeatother

\begin{document}

\part{}
\section{Section I}
content

\section{Section II}
content

\subsection{Subsection I} 
content

\subsection{Subsection II}
content

\section{Section III}
content

\part{}
\section{Section I}
content

\section{Section II}
content

\subsection{Subsection I} 
content

\subsection{Subsection II}
content

\section{Section III}
content

\end{document}

enter image description here

Adendum:

Using the xpatch package you can simplify the code:

\documentclass[12pt]{article}
\usepackage{xpatch}

\makeatletter
\@addtoreset{section}{part}
\xpatchcmd{\@part}{\normalfont}{\normalfont\centering}{}{}
\xpatchcmd{\@part}{\Large}{\LARGE}{}{}
\renewcommand\partname{Topic}
\makeatother

\begin{document}

\part{}
\section{Section I}
content

\section{Section II}
content

\subsection{Subsection I} 
content

\subsection{Subsection II}
content

\section{Section III}
content

\part{}
\section{Section I}
content

\section{Section II}
content

\subsection{Subsection I} 
content

\subsection{Subsection II}
content

\section{Section III}
content

\end{document}

Adendum 2:

Another variant, using this time the titlesec package to easily customize the \part command, suppressing the "Part #" label and centering the title:

\documentclass[12pt]{article}
\usepackage{titlesec}

\makeatletter
\@addtoreset{section}{part}
\makeatother
\titleformat{\part}[display]
{\normalfont\LARGE\bfseries\centering}{}{0pt}{}

\begin{document}

\part{Polynomials}
\section{Section I}
content

\section{Section II}
content

\subsection{Subsection I} 
content

\subsection{Subsection II}
content

\section{Section III}
content

\part{Functions}
\section{Section I}
content

\section{Section II}
content

\subsection{Subsection I} 
content

\subsection{Subsection II}
content

\section{Section III}
content

\end{document}

enter image description here

  • Ok I like the solution suggested in your addendum. But... one more favor to ask.... I don't want "Topic I", "Topic II", etc; those were just placeholders for actual topic names that I will add in (for example, "Polynomials", "Functions") – Frank Epps Jul 20 '13 at 0:14
  • @FrankEpps OK. Give me some minutes more. – Gonzalo Medina Jul 20 '13 at 0:18
  • 1
    +1, I'm never going to catch up with @egreg at this rate:-) – David Carlisle Jul 20 '13 at 0:20
  • @FrankEpps please see my updated answer. – Gonzalo Medina Jul 20 '13 at 0:21
  • THANK YOU SO MUCH!!!! And David, don't feel bad, you're a great guy!! – Frank Epps Jul 20 '13 at 0:22
9
\documentclass[12pt]{article}

\makeatletter
\@addtoreset{section}{part}
\makeatother

\begin{document}

\part{Topic I}

\section{Section I}
content

\section{Section II}
content

\subsection{Subsection I} 
content

\subsection{Subsection II}
content

\section{Section III}
content


\part{Topic II}

\section{Section I}
content

\section{Section II}
content

\subsection{Subsection I} 
content

\subsection{Subsection II}
content

\section{Section III}
content

\end{document}

Note \LARGE does not take an argument and should always include the following end of paragraph so the syntax would be \begin{center}\bfseries\LARGE Topic I\end{center} but using explicit font changes rather than a section head is just not the LaTeX way:-) The formatting for a \part head can be separately customised to use a centred heading if that is desired.

  • I'm a LaTeX noob and I can never seem to get things right using the built-in functionality of LaTeX so I just make my own headings lol. – Frank Epps Jul 20 '13 at 0:02
  • can you make it look exactly like what I had? (center "Topic I" and delete the "Part I" headers) – Frank Epps Jul 20 '13 at 0:04
  • @FrankEpps Did you see my answer? ;-) – Gonzalo Medina Jul 20 '13 at 0:05
  • yes I did, I see that it works and it's exactly what I wanted :) but the large mass of code is putting me off... – Frank Epps Jul 20 '13 at 0:06
  • @FrankEpps please see my updated answer. – Gonzalo Medina Jul 20 '13 at 0:11

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.