5

I am overriding the default section titles for a large document. This consists of adding words such as "Section", and using alpha or roman numbers.

However, the table of contents is continuing to use the arabic numerals and is surpresing the added descriptions. Is it possible to have the TOC update with the titles, as displayed?

\documentclass{article}
\usepackage[explicit]{titlesec}

\titleformat{\section}{} {} {0pt} {Section \Alph{section}. #1}
\begin{document}
    \tableofcontents
    \section{Intro}
        123
\end{document}
  • You should use \renewcommand\thesection{Alphsection} and write {Section \thesection}} in \titleformat. If you also want to have ‘Section’ to appear in the table of contents, you should use the companion titletoc package. – Bernard Nov 14 '14 at 0:01
5

Something like this, perhaps:

\documentclass{article}
\usepackage[explicit]{titlesec}
\usepackage{titletoc}
\renewcommand*\thesection{\Alph{section}}
\newcommand*\Sectionname{Section}

\titleformat{\section}{\normalfont\normalsize}{\Sectionname\ \thesection.\quad}{0pt}{#1}
\titlecontents*{section}[0pt]{\normalfont\normalsize}{\Sectionname\ \thecontentslabel.\quad}{}{}


\begin{document}
    \tableofcontents
    \section{Intro}
        123
\end{document}

sections in ToC

EDIT

If you would like the ToC entry to be upper case, you could use

\titlecontents*{section}[0pt]{\normalfont\normalsize}{\MakeUppercase{\Sectionname} \thecontentslabel.\quad\uppercase}{}{}

This makes both the section name and the section title upper case. If you just want one or the other, change that part back to the original code above.

  • Thank you very much \titlecontents was exactly what I was looking for. Side question, is there a command to make the TOC entry uppercase? Similar to \scshape – DBordello Nov 14 '14 at 18:41
  • @DBordello You are welcome. Please see edited answer above. – cfr Nov 14 '14 at 21:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.