[Tex/LaTex] How to get Section without numbers in Title and TOC, but subsections with them

sectioningtable of contentstitlesectocloft

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
    
    Introduction (manually added)......................xx
    [ ]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
    Bibliography (manually added)......................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{\cftsecleader}{\cftdotfill{\cftdotsep}}
\renewcommand{\cfttoctitlefont}{\hfill\Large\bfseries}
\renewcommand{\cftaftertoctitle}{\hfill\hfill}%center TOC title

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

\setcounter{secnumdepth}{3}

\begin{document}
\tableofcontents

\section*{Introduction}
\addcontentsline{toc}{section}{Introduction}
\paragraph{About:} Some text over here...

\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
\addcontentsline{toc}{section}{Bibliography}
% Bibliography.
\begin{thebibliography}{99}
\bibitem{Someone}
\emph{...}.
\end{thebibliography}
\end{document}

Best Answer

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{\cftsecleader}{\cftdotfill{\cftdotsep}}
  \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.}%
    \addcontentsline{toc}{section}%
                    {\protect#1}%
  \else
    \addcontentsline{toc}{section}{#1}%
  \fi
  \sectionmark{#1}%
  \if@twocolumn
    \@topnewpage[\@makesectionhead{#2}]%
  \else
    \@makesectionhead{#2}%
    \@afterheading
  \fi}
\def\@makesectionhead#1{%
  \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
    \@topnewpage[\@makessectionhead{#1}]%
  \else
    \@makessectionhead{#1}%
    \@afterheading
  \fi}%
\def\@makessectionhead#1{%
  \vspace*{10\p@}%
  {\parindent \z@ \centering\normalfont
    \interlinepenalty\@M
    \Large \bfseries  #1\par\nobreak
    \vskip 10\p@}}%
\def\sectionname{Section}
\makeatother

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

\begin{document}
\tableofcontents

\section*{Introduction}
\addcontentsline{toc}{section}{Introduction}
\paragraph{About:} Some text over here...

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

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

output