Text Formatting ⇒ Change section heading styles
Change section heading styles
Thanks,
Marco
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
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Change section heading styles
Best regards and welcome to the board
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 50
- Joined: Sat May 23, 2009 10:13 pm
Change section heading styles
Code: Select all
\usepackage{titlesec}
% how many levels of text structure should get numbered?
% NOTE: this has to be >= 3 for subsubsection to have whatever kind of content before its name in report or book documentclass!
\setcounter{secnumdepth}{3}
% how should text structure elements be formatted textually?
% chapter
\renewcommand{\thechapter}{\Roman{chapter}}
% section
\renewcommand{\thesection}{\arabic{section}.}
% subsection
\renewcommand{\thesubsection}{\arabic{section}.\arabic{subsection}.}
% subsubsection
\renewcommand{\thesubsubsection}{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}.}
% fonts setup here
% chapter
\newcommand{\mychapterfont}
{
\addfontfeature{Colour=000060}
\Huge
}
% section
\newcommand{\mysectionfont}
{
\addfontfeature{Colour=000060}
\Large
}
% subsection
\newcommand{\mysubsectionfont}
{
\addfontfeature{Colour=000040}
\large
}
% subsubsection
\newcommand{\mysubsubsectionfont}
{
\addfontfeature{Colour=000030}
\normalsize
}
% how should text structure elements look?
% chapter
\titleformat{\chapter}
{
\mychapterfont
}
{\thechapter}{0.7em}{}
% for appendix I like alternative formatting
% appendix
\newcommand{\appendixTOC}
{
\titleformat{\chapter}
{
\mychapterfont
}
{}{0em}{}
}
% section
\titleformat{\section}
{
\mysectionfont
}
{\thesection}{0.7em}{}
% subsection
\titleformat{\subsection}
{
\mysubsectionfont
}
{\thesubsection}{.5em}{}
% subsubsection
\titleformat{\subsubsection}
{
\mysubsubsectionfont
}
{$\diamond$}{.4em}{}
Code: Select all
\usepackage{fontspec} % provides font selecting commands
[1] http://mirror.ctan.org/macros/xetex/lat ... ntspec.pdf
Re: Change section heading styles
\def\section{\@startsection{section}{1}%
\z@{.7\linespacing\@plus\linespacing}{.5\linespacing}%
{\normalfont\scshape\centering}}
\def\subsection{\@startsection{subsection}{2}%
\z@{.5\linespacing\@plus.7\linespacing}{-.5em}%
{\normalfont\bfseries}}
\def\subsubsection{\@startsection{subsubsection}{3}%
\z@{.5\linespacing\@plus.7\linespacing}{-.5em}%
{\normalfont\itshape}}
but I'm not sure what it means. How can I find out more on this?
-
- Posts: 50
- Joined: Sat May 23, 2009 10:13 pm
Re: Change section heading styles
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Change section heading styles
From this you can see that giving all necessary information at the beginning like the used document class is very important. Both of the packages I suggested earlier don't work with amsart. But you already picked the relevant code from the class file. Now we have to modify these declarations. Add the following to your preamble.marcdein wrote:[…] Unfortunately the "titlesec" package doesn't seem to be compatible with the amsart document class, which is what I am using. […]
Code: Select all
\makeatletter
\def\section{\@startsection{section}{1}%
\z@{.7\linespacing\@plus\linespacing}{.5\linespacing}%
{\normalfont\bfseries\centering}}
\def\subsection{\@startsection{subsection}{2}%
\z@{.5\linespacing\@plus.7\linespacing}{-.5em}%
{\normalfont\bfseries\itshape}}
\def\subsubsection{\@startsection{subsubsection}{3}%
\z@{.5\linespacing\@plus.7\linespacing}{-.5em}%
{\normalfont\bfseries}}
\makeatother
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10