0

I was given a solution to include "Chapter" before my section entries in the ToC, however the number of the section does not get transferred to the ToC! For instance, in the MWE below, the sections are called "Chapter 1 \break Section One" and "Chapter One \break Section Two", however in the ToC, the sections are listed as "Chapter Section One" and "Chapter Section Two", and thus omitting the section numbers. I'd like to include these section numbers in the ToC.

Thanks!

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[showframe]{geometry}
\usepackage{titlesec}
\usepackage{titletoc}

\addto\captionsenglish{ \renewcommand*\contentsname{\centerline{TABLE OF CONTENTS}}}

\titleformat{\section}[display]%
{\null\vskip1em\sffamily\bfseries\filcenter}{Chapter \thesection}{0em}{}[]
\titleformat{name = \section, numberless}[block]%
{\null\vskip1em\sffamily\bfseries\filcenter}{}{0em}{}
\titlespacing*{\section}{0em}{1em}{1em}

\titlecontents{section}
[7em] % ie, width of contentslabel + 0.5em
{\medskip}
{\contentslabel[\MakeUppercase\chaptername~]{6.5em}}%\thecontentslabel
{\hspace*{-6.5em}}
{\titlerule*[0.5pc]{.}\contentspage}

\begin{document}

\tableofcontents
\newpage

\section*{An Unnumbered Section}
\addcontentsline{toc}{section}{An Unnumbered Section}
\section{Section One}
\subsection{A first subsection}
\section{Section Two}
Content

\end{document} 
Conor
  • 155
  • 1
  • 8
  • I think I'd just go back to the other question, but would this not be fixed by replacing {Chapter \thesection} with {Chapter 1 \thesection} or similar? It's odd that you talk about writing a thesis with the article class, and wanting chapters. Typically, these would be written with report, book, or other classes with built-in chapters. – Mike Renfro Nov 29 '15 at 23:59
  • I don't mind people answering on the other post, I just realized no one was replying to it anymore and didn't know how to signify that I still have a question on it.

    And that would not work: It would make every chapter be "Chapter 1 # /break Name of Chapter", and the Table of Contents would still say "Chapter Section Name"

    – Conor Nov 30 '15 at 00:05
  • If Bernard's answer isn't sufficient (with or without my untested change above), then I'd edit this question with a new MWE and ask your modified question here. – Mike Renfro Nov 30 '15 at 00:07
  • Done! For anyone else confused I was previously linking a partially answered question, but I've now modified this question to be standalone. – Conor Nov 30 '15 at 00:16
  • Also is there a quick way to add all the 's to the code besides manually typing each line? I noticed you did that a lot quicker than me. – Conor Nov 30 '15 at 00:17
  • just highlight a section of code then use the {} button in the editor (or control-k) – David Carlisle Nov 30 '15 at 00:18
  • Why are you using \section to make Chapter It seems somewhat strange choice of command. It's rather more normal to use \chapter to make chapters and \section to make sections. – David Carlisle Nov 30 '15 at 00:20
  • Please see my updated answer to your initial post. – Bernard Nov 30 '15 at 00:38
  • That worked, thanks! I've marked your previous answer as correct now. – Conor Nov 30 '15 at 01:06
  • 2
    voted to close as duplicate since original now answers this. @Conor please don't edit an unanswered title to say "Answered" the site will still list it as unanswered which is confusing, you could simply delete, or vote to close as duplicate – David Carlisle Nov 30 '15 at 01:13
  • Sorry will do, but deleting it means it won't be archived and closing as duplicate is not very intuitive... is there no way to just mark it as answered? – Conor Dec 01 '15 at 16:35

0 Answers0