# How to get Section without numbers in Title and TOC, but subsections with them

First of all, I have been searching on the web and I have found similar cases but nothing useful for my problem, and more over, I'm pretty new in LaTeX.

# The Problem

• If I take off the numbers from \section, then, numbering of subsections are equal in every section (this is in the Content itself).

                              Centered Section Title
1  Subsection
1.1 Subsubsection
1.2 Subsubsection
Other Section Title
1  Subsection
1.1 Subsubsection
1.2 Subsubsection

• It is the same in the TOC and additionally, sections are right shifted. Represented with []:

                        Index

[ ]Section Title...................................xx
[ ]1  Subsection...................................xx
[ ]   1.1 Subsubsection............................xx
[ ]   1.2 Subsubsection............................xx
[ ]Other Section Title.............................xx
[ ]1  Subsection...................................xx
[ ]   1.1 Subsubsection............................xx
[ ]   1.2 Subsubsection............................xx


# What I want

• I need to get sections without numbers neither in the title nor in the TOC, but \subsection and \subsubsection must have that numeration.

                              Centered Section Title
1.1  Subsection
1.1.1 Subsubsection
1.1.2 Subsubsection
Other Section Title
2.1  Subsection
2.1.1 Subsubsection
2.1.2 Subsubsection

• Get aligned sections in TOC.

I'm so sorry if I have miswritten something, English is not my native language

My current code:

\documentclass[12pt]{article}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[spanish,activeacute]{babel}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{amsmath,amsthm}
\usepackage[left=1.58in,right=0.98in,top=0.5in,bottom=0.5in]{geometry}

%to do not put numbers in sections
\usepackage{titlesec}
\titleformat{\section}{\centering}{\thesection}{0em}{\Large\bfseries}
\renewcommand{\thesection}{}% Remove section references...
\renewcommand{\thesubsection}{\arabic{subsection}}%... from subsections

% to fill TOC with dots
\usepackage{tocloft}
\renewcommand{\cfttoctitlefont}{\hfill\Large\bfseries}
\renewcommand{\cftaftertoctitle}{\hfill\hfill}%center TOC title

%to replace TOC title
\renewcommand{\contentsname}{Indice General}
}

\setcounter{secnumdepth}{3}

\begin{document}
\tableofcontents

\section*{Introduction}

\section[First Things]{Capítulo 1: First Things}
\subsection{Algo}
\subsubsection{Algo más}

\section[Title for TOC]{Capítulo 2: Title for section}
\subsection{Algo}
\subsubsection{Algo más}

\section[Again for TOC]{Capítulo 3: Title for Text}

\section[Conclutions]{Conclutions}

\clearpage
% Bibliography.
\begin{thebibliography}{99}
\bibitem{Someone}
\emph{...}.
\end{thebibliography}
\end{document}

• I found some approach to answer my own question, surely there are better than this one. \titleformat{\section}{\centering}{}{0em}{\Large\bfseries} instead of \titleformat{\section}{\centering}{\thesection}{0em}{\Large\bfseries} to do not write the numbers in the pages header. and delete all \setcounter{secnumdepth}{X} in the document I have deleted the first and modified the document environment. But I still need to do not write the numbers in the TOC. – onlycparra Nov 29 '14 at 19:47
• Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – karlkoeller Nov 29 '14 at 20:52

I wouldn't recommend to hardcode something like "Capítulo 1: First Things" in a sectional heading. The following code looks a little bulky because it does a more than you requested, but it induces a more LaTeXnish manuscript file.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage[spanish,activeacute]{babel}
\usepackage{tocloft}
\renewcommand{\cfttoctitlefont}{\hfill\Large\bfseries}
\renewcommand{\cftaftertoctitle}{\hfill\hfill}

\makeatletter
\renewcommand\section{\secdef\@section\@ssection}
\def\@section[#1]#2{%
\ifnum \c@secnumdepth >\@ne
\refstepcounter{section}%
\typeout{\sectionname\space\thesection.}%
{\protect#1}%
\else
\fi
\sectionmark{#1}%
\if@twocolumn
\else
\fi}
\vspace*{10\p@}%
{\parindent \z@ \centering \normalfont
\ifnum \c@secnumdepth >\@ne
\interlinepenalty\@M
\Large\bfseries \sectionname\space \thesection: #1\par\nobreak
\fi
\vskip 10\p@}}%
\def\@ssection#1{%
\if@twocolumn
\else
\fi}%
\vspace*{10\p@}%
{\parindent \z@ \centering\normalfont
\interlinepenalty\@M
\Large \bfseries  #1\par\nobreak
\vskip 10\p@}}%
\def\sectionname{Section}
\makeatother

\setcounter{secnumdepth}{3}
\renewcommand{\contentsname}{Indice General}
\renewcommand{\sectionname}{Sección}}% or Capítulo of course...

\begin{document}
\tableofcontents

\section*{Introduction}

\section{First Things}
\subsection{Algo}
\subsubsection{Algo más}

\section[Title for TOC]{Title for section}
\subsection{Algo}
\subsubsection{Algo más}
\end{document}


• Hi Ruben. The OP wants sections (starred and non-) left-aligned in the TOC. – karlkoeller Nov 29 '14 at 20:57
• @karlkoeller, not so sure about this because in fact the sections are somehow numbered in the running text, i.e. "Capítulo 1: First Things". I was about to add a titletoc solution as an addendum to my answer, in order to have a less bulky option. Now that you have written one were pretty complete here, i'd say. – Ruben Nov 29 '14 at 21:01
• @karlkoeller, ... and note that the alignment of the starred sections and the regular ones are differenetly sketched in the OP (regarding your answer). Don't knoe yet if it is important. But, it is worth a thought. – Ruben Nov 29 '14 at 21:03
• @onlycparra, does the update cover anything you need now? – Ruben Nov 29 '14 at 21:45
• Almost, because "Algo" from Section "First Things" should have number 1.1 and "Algo más" 1.1.1. "Algo" from next section should have 2.1 and "Algo más" 2.1.1... and so on Am I too confusing? :S – onlycparra Nov 29 '14 at 22:17

You can use the package titletoc instead of tocloft to achieve what you want.

First of all, forget about redefining \thesection, that is remove the lines

\renewcommand{\thesection}{}% Remove section references...
\renewcommand{\thesubsection}{\arabic{subsection}}%... from subsections


Then remove the stuff from tocloft and add these lines:

\usepackage{titletoc}
\titlecontents{section}
[0em]
{}
{}
{\mdseries\titlerule*[.75pc]{.}\bfseries\contentspage}


This is the result:

Complete code:

\documentclass[12pt]{article}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[spanish,activeacute]{babel}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{amsmath,amsthm}
\usepackage[left=1.58in,right=0.98in,top=0.5in,bottom=0.5in]{geometry}

%to do not put numbers in sections
\usepackage{titlesec}
\titleformat{\section}{\centering}{}{0em}{\Large\bfseries}

\usepackage{titletoc}
\titlecontents{section}
[0em]
{}
{}
{\mdseries\titlerule*[.75pc]{.}\bfseries\contentspage}

%to replace TOC title
\renewcommand{\contentsname}{Indice General}
}

\setcounter{secnumdepth}{3}

\begin{document}
\tableofcontents

\section*{Introduction}

\section[First Things]{Capítulo 1: First Things}
\subsection{Algo}
\subsubsection{Algo más}

\section[Title for TOC]{Capítulo 2: Title for section}
\subsection{Algo}
\subsubsection{Algo más}

\section[Again for TOC]{Capítulo 3: Title for Text}

\section[Conclutions]{Conclutions}

\clearpage
% Bibliography.
\begin{thebibliography}{99}
\bibitem{Someone}
\emph{...}.
\end{thebibliography}
\end{document}


## EDIT

As per your comment, to have Roman numerals for sections in the TOC (although I don't approve this choice), do the following.

Declare \thesection as \Roman and \thesubsection as \arabic:

\renewcommand{\thesection}{\Roman{section}}
\renewcommand{\thesubsection}{\arabic{section}.\arabic{subsection}}


In this case it is better to use tocloft instead of titletoc.

\cftsetindents{section}{0em}{3em}
\cftsetindents{subsection}{3em}{2.3em}
\cftsetindents{subsubsection}{5.3em}{3em}


and this is the result:

Note that the spacing between Roman numerals and titles is deliberately large so to leave space for large numerals.

Complete code:

\documentclass[12pt]{article}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[spanish,activeacute]{babel}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{amsmath,amsthm}
\usepackage[left=1.58in,right=0.98in,top=0.5in,bottom=0.5in]{geometry}

%to do not put numbers in sections
\usepackage{titlesec}
\titleformat{\section}{\centering}{}{0em}{\Large\bfseries}

\renewcommand{\thesection}{\Roman{section}}
\renewcommand{\thesubsection}{\arabic{section}.\arabic{subsection}}

% to fill TOC with dots
\usepackage{tocloft}
\renewcommand{\cfttoctitlefont}{\hfill\Large\bfseries}
\renewcommand{\cftaftertoctitle}{\hfill\hfill}%center TOC title
\cftsetindents{section}{0em}{3em}
\cftsetindents{subsection}{3em}{2.3em}
\cftsetindents{subsubsection}{5.3em}{3em}

%to replace TOC title
\renewcommand{\contentsname}{Indice General}
}

\setcounter{secnumdepth}{3}

\begin{document}
\tableofcontents

\section*{Introduction}

\section[First Things]{Capítulo 1: First Things}
\subsection{Algo}
\subsubsection{Algo más}

\section[Title for TOC]{Capítulo 2: Title for section}
\subsection{Algo}
\subsubsection{Algo más}

\section[Again for TOC]{Capítulo 3: Title for Text}

\section[Conclutions]{Conclutions}

\clearpage