Document ClassesReport vs. Article

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
the_obs
Posts: 9
Joined: Mon Oct 18, 2010 9:18 pm

Report vs. Article

Post by the_obs »

Hey all!
I am beginning with Latex, and find it awesome. However I have a problem seriously bugging me.

I would like to use report as my document class as I find it perfect (title on seperate page, vertically and horizontally centered, parts on seperate pages, etc.). However, I DO NOT want to use chapters, only parts, sections, subsections, etc. My table of contents thus show sections as 0.1, 0.2, etc. as I have not defined any chapter. How can I change numbering in a report-class Table of Content to be PART.SECTION instead of CHAPTER.SECTION?
Thanks!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Report vs. Article

Post by gmedina »

Hi,

you can do a redefinition of the representation of the section counter and some adjustment to make this counter restart with every new part; an example:

Code: Select all

\documentclass{report}
\usepackage{chngcntr}

\renewcommand\thesection{\thepart.\arabic{section}}
\counterwithin{section}{part}

\begin{document}
\tableofcontents

\part{Test part one}
\section{Test section one one}
\section{Test section one two}
\part{Test part two}
\section{Test section two one}
\section{Test section two two}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
the_obs
Posts: 9
Joined: Mon Oct 18, 2010 9:18 pm

Report vs. Article

Post by the_obs »

gmedina wrote:Hi,

you can do a redefinition of the representation of the section counter and some adjustment to make this counter restart with every new part; an example:

Code: Select all

\documentclass{report}
\usepackage{chngcntr}

\renewcommand\thesection{\thepart.\arabic{section}}
\counterwithin{section}{part}

\begin{document}
\tableofcontents

\part{Test part one}
\section{Test section one one}
\section{Test section one two}
\part{Test part two}
\section{Test section two one}
\section{Test section two two}

\end{document}
Great, except parts are numbered with roman numerals and sections are displayed as I.1, II.1, etc. in the TOC. I would like either parts as arabic and sections as 1.1, 2.1, etc. in the TOC or parts as roman and sections as 1.1, 2.1, etc.
As long as section are pure arabic, parts can be roman or arabic. How do I go about it?
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Report vs. Article

Post by gmedina »

Code: Select all

\renewcommand\thepart{\arabic{part}}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
the_obs
Posts: 9
Joined: Mon Oct 18, 2010 9:18 pm

Report vs. Article

Post by the_obs »

gmedina wrote:

Code: Select all

\renewcommand\thepart{\arabic{part}}
Ahhhh great! That worked perfectly. Thank you very much.
If I understand correctly, the above command (re)sets part numbers to arabic.
However what I don't understand is the \counterwithin command, is it a TOC-specific command?

Thanks again!
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Re: Report vs. Article

Post by gmedina »

\counterwithin{<count1>}{<count2>} forces <count1> to restart whenever <count2> is increased.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply