Document ClassesModifying Section titles using titlesec/titletoc Package

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
centurion555
Posts: 6
Joined: Thu Nov 06, 2008 1:15 pm

Modifying Section titles using titlesec/titletoc Package

Post by centurion555 »

I am trying to produce Section titles with numbers. I also want a decimal point after the number in Section titles. I used these commands in
preamble of my document.

\titlelabel{\thetitle.\quad} %Why this is not working when using \titleformat commands in next line
\titleformat{\section}{\bf}{\thesection}{1em}{}
\titlespacing{\section}{0pt}{12pt}{6pt}

Problem 1:

The first command \titlelabel.... produces the required decimal points but it doesn't work when I use the second command \titleformat......
please help me to both command works at the same time.

Problem 2:

The third command above shows my required spacing before and after the paragraph. In one of my sections I am producing text in two columns using multicol package with commands:

\section*{Acknowledgements}
\begin{multicols}{2}
We Acknowledge this ..........text here............
\end{multicols}

I am getting extra space (than defined by \titlespacing above) between section heading "Acknowledgement" and the text "We Acknowlege........" . I think this extra space is coming from the multicol package. I tried to redefined spacing with \titlespacing
before this section but it doesn't help.

Thanks for your kind suggestion/hint
Regards
Nadeem

Recommended reading 2024:

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

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

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

Modifying Section titles using titlesec/titletoc Package

Post by gmedina »

Hi Nadeem,

the code below contains some suggestions to help you solve your problems:

Code: Select all

\documentclass{article}
\usepackage{titlesec}
\usepackage{multicol}
\usepackage{lipsum}%just to generate some text

\titleformat{\section}{\bfseries}{\thesection.}{1em}{}
\titlespacing{\section}{0pt}{12pt}{6pt}

\begin{document}

\section*{Acknowledgements}
\vspace*{-1em}
\begin{multicols}{2}
  \lipsum[1-3]
\end{multicols}

\section{Test section one}
\lipsum[1-5]

\section{Test section two}
\lipsum[1-5]

\end{document}
Notice the dot "." that goes after \thesection in the third argument of \titleformat. To correct the issue with the vertical spacing between the heading and the text in the "Acknowledgements" section, you can use \vspace* as suggested.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
centurion555
Posts: 6
Joined: Thu Nov 06, 2008 1:15 pm

Re: Modifying Section titles using titlesec/titletoc Package

Post by centurion555 »

Hi gmedina,
You are great. It worked without any problem.
Thanks, Nadeem
Post Reply