Text FormattingCustomization of Headings

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Hrs
Posts: 16
Joined: Sat May 12, 2012 3:13 pm

Customization of Headings

Post by Hrs »

Hi all!

How should I redefine \section (or something else, that this command use) (but I need to customize not only sections) to customize it's output in according with the following requirements:
  1. \chapter{ChapName.} must output as: "CHAPNAME" with a normal text size (selected in all document (in our standards, using extsizes package it must be 14pt)), bold faced, capital and centered, and without any number. It must be separated from upper and lower text with 1 (one) line.
  2. \section and \subsection headings must be separated the same as \chapter from previous item, and it's sizes must also be normal (14pt). Also I need a space before a number of this with a length of \parindent. All other standard things of \section and \subsection headings are good to go, but I like to see a dot after number i.e.: \section{SecName} should give a "1. SecName".
Thank you very much in advance.

p.s. I have forgotten to write one more requirement to the item above, for \section and \subsection, and now I have added it there.

p.p.s. Thank you for good editing of this post.

Recommended reading 2024:

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

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

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Customization of Headings

Post by cgnieder »

You may want to have a look at the titlesec package. It provides a handy interface for customizations of headings. You can use the example below as an idea to start with:

Code: Select all

\documentclass[14pt]{extbook}

\usepackage{titlesec}

% definitions for chapters:
\titleformat{\chapter}[display]
  {\filcenter}
  {}
  {1ex minus .1ex}
  {\normalfont\bfseries\uppercase}
\titlespacing{\chapter}
  {0pt}{\baselineskip}{\baselineskip}

\makeatletter
\renewcommand\chapter{%
  \global \@topnum \z@ \@afterindentfalse
  \secdef \@chapter \@schapter}
\makeatother

% definitions for (sub-)sections:
\newlength\sectionindent
\setlength\sectionindent{\the\parindent}

\titleformat{\section}
  {\normalfont\bfseries}
  {\hspace*{\sectionindent}\thesection.}
  {0pt plus .5\baselineskip}
  {}
\renewcommand*\thesection{\arabic{section}}

\titleformat{\subsection}
  {\normalfont\bfseries}
  {\hspace*{\sectionindent}\thesubsection.}
  {0pt plus .5\baselineskip}
  {}
\renewcommand*\thesubsection{\thesection.\arabic{subsection}}

\usepackage{lipsum}% for dummy text

\begin{document}
\chapter{ChapName}
\section{SecName}
\subsection{SubSecName}
\lipsum[1-3]

\chapter{ChapName}
\section{SecName}
\subsection{SubSecName}
\lipsum[1-3]

\end{document}
Regards
site moderator & package author
Post Reply