[Tex/LaTex] Table of Contents with custom section titles

table of contentstitlesec

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}

Best Answer

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.

Related Question