0

How to format the section with capital letters and leave the TOC text in normal format.

I want to use this command:

\section{Section Text}

with the result similar to this:

\section[Section Text]{\MakeUppercase{Section Text}}

I'm using the following section configuration:

\def\section{\@startsection{section}{1}{\z@}{\baselineskip}{\baselineskip}{\centering\normalfont\sffamily\bfseries}}%

To get a result of this type:

Contents

  1. Section Text . . . . . page number
  2. ...

1 SECTION TEXT

text text text. I would like to use the section title in sans serif font and uppercase.

is it possible?

2
  • Have you looked into titletoc's companion titlesec?
    – Teepeemm
    Commented Jun 6, 2022 at 1:55
  • just put \MakeUppercase in \section def. Like: \def\section{\@startsection{section}{1}{\z@}{\baselineskip}{\baselineskip}{\centering\normalfont\sffamily\bfseries\MakeUppercase}}
    – Tom
    Commented Jun 6, 2022 at 2:12

1 Answer 1

1

While you can certainly do it other ways, I find it easiest to use the titlesec package to customize headings and its companion titletoc to customize TOC entries; see the documentation.

\documentclass{article}
\usepackage{titlesec}% package for customizing headings
\usepackage{titletoc}% package for customizing the toc
\titleformat{\section}% the command you want to format
    {\bfseries\sffamily\MakeUppercase}% the style/commands applied to entire title
    {\thesection}% format of the number label; here just the number
    {0.5em}% spacing after the number
    {}% additional styles applied to just the title itself

\dottedcontents{section}% level of toc you want to customize
    [1em]% spacing on left of number
    {}% code before each section entry
    {1em}% width of section number in toc
    {1pc}% spacing between dots


\titlecontents{section}% level of toc you want to customize
    [1em]% spacing to the left where titles start
    {}% code applied before entry
    {\thecontentslabel. }%formatting of numbered entry labels
    {}% format of unnumbered entry labels
    {\dotfill\rlap{\makebox[1em][r]{\thecontentspage}}}% formatting after the title
    {}% filler

\usepackage{lipsum}% for dummy text
\begin{document}

\tableofcontents

\section{First Section}

\lipsum[1]

\section{Second Section}

\lipsum[2]

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .