Generate table of contents when \section* (sections without numbering) has been used

You don't have numbered sections, do you? In this case the simplest arrangement is

\setcounter{secnumdepth}{0} % sections are level 1

\begin{document}

\section{First}

\section{Second}

No sectional unit below \section will be numbered, but sections and subsections will go anyway in the table of contents (as this depends on the value of the tocdepth counter, default 2).


The following is a manual way of adding entries to the table of contents by means of \addcontentsline:

\documentclass[12pt,a4paper]{article}

\begin{document}

\tableofcontents

\section*{Section 1}
\addcontentsline{toc}{section}{\protect\numberline{}Section 1}%
\section*{Section 2}
\addcontentsline{toc}{section}{\protect\numberline{}Section 2}%

\end{document}

Starred sections in ToC

The reason for using \numberline{} is to allow for the traditional numbered space in the table of contents. If you're not interested in this numeric alignment, then you can drop the \protect\numberline{}.


Adapting DevSolar's answer from this question (clearing out the definition of \thesection), and assuming you don't really care if you use \section*, you just want to remove numbers from the headings and ToC entries:

enter image description here

\documentclass[12pt,a4paper]{article}
\renewcommand{\thesection}{}
\begin{document}
\tableofcontents
\section{A Section}
\section{Another Section}
\end{document}