[Tex/LaTex] Change Section titles to Small Caps only in ToC

sectioningsmall-capstable of contents

I'm new to LaTeX and already facing my first problem. I want to change all section titles to small caps in the table of contents but not in the text.

I'm using WriteLaTeX and article as document class.

This is how my document is structured

\documentclass{article}

\begin{document}

\tableofcontents

\newpage
\section{Section 1}
\subsection{Section 1.1}
\subsection{Section 1.2}

\newpage
\section{Section 2}

\newpage
\section{Section 3}
\end{document}

Best Answer

Optimal Solution

Load the tocloft package and put \renewcommand{\cftsecfont}{\scshape} after it in the preamble. MWE:

\documentclass[11pt]{article}
\usepackage{tocloft}
\renewcommand{\cftsecfont}{\scshape}
\begin{document}

\title{My document}
\maketitle

\tableofcontents

\section{first section}
bla

\subsection{a subsection}
bla

\section{second section}
bla
\end{document}

This will only change the TOC, not your headings.

Subpar solution

If, for any reason, you cannot load tocloft, this is the ugliest hack ever:

% make your sections using \newsection{title}

\newcommand{\newsection}[1]{
\stepcounter{section}
\section*{\arabic{section}. #1}
\addcontentsline{toc}{section}{\scshape \arabic{section}. #1}
}