Page LayoutPeriod after section number

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
ditrans
Posts: 9
Joined: Fri Dec 11, 2009 7:17 pm

Period after section number

Post by ditrans »

Hello everyone,

could someone please tell me how I can put a period after section numbers (without then having two periods between a section and a subsection number)?

Thanks!!

Recommended reading 2024:

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

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

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

Period after section number

Post by gmedina »

Hi,

for the standard document classes you can use the titlesec package. Take a look at the following example:

Code: Select all

Code, edit and compile here:
\documentclass{article}
\usepackage{titlesec}
\titleformat{\section}
{\normalfont\Large\bfseries}{\thesection.}{1em}{}
\begin{document}
\section{Test section}
\subsection{Test subsection}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Addendum: of course, my previous response will place a period after section numbers only (as originally requested). If the period must appear after every sectional unit (from sections down), then a redefinition of \@seccntformat would be a better choice:

Code: Select all

Code, edit and compile here:
\documentclass{article}
\makeatletter
\renewcommand\@seccntformat[1]{\csname the#1\endcsname.\quad}
\makeatother
\begin{document}
\section{Test section}
\subsection{Test subsection}
\subsubsection{Test subsubsection}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
In fact, the previous code can be modified to allow the period to appear only on certain sectional units (without using additional packages); the following example code will produce a perior after the section and subsubsection numbers, but not after the subsection numbers:

Code: Select all

Code, edit and compile here:
\documentclass{article}
\makeatletter
\renewcommand\@seccntformat[1]{%
\@ifundefined{#1@cntformat}%
{\csname the#1\endcsname\quad}%
{\csname #1@cntformat\endcsname}}
\newcommand\section@cntformat{\thesection.\quad}
\newcommand\subsubsection@cntformat{\thesubsubsection.\quad}
\makeatother
\begin{document}
\section{Test section}
\subsection{Test subsection}
\subsubsection{Test subsubsection}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1,1,2,3,5,8,13,21,34,55,89,144,233,...
ditrans
Posts: 9
Joined: Fri Dec 11, 2009 7:17 pm

Re: Period after section number

Post by ditrans »

Thank you a lot for your indepth response. I tried your first solution and just added commands for subsection etc., but your second solution seems cleaner so I think I'll use that.

Thanks again!
Post Reply