0

I am trying to write title in first page, and after table of contents:

\documentclass{article}

\begin{document}


    \title{My Title}
    \author{My Name}

    \newpage


    \tableofcontents


    \section{Installation}
    aaaaaaaaaaaa
    \subsection{Getting started}
    \subsection{Jamaican rice rat}
    \subsection{White-footed rabbit-rat}

    \section{Butterflies}
    \subsection{Nymphalidae}
    \subsection{Lycaenidae}
    \subsection{Uraniidae}



\end{document}

but it displays only one page with table of contents

  • What document class are you using? If you are using book, just add \maketitle before \tableofcontents. – user156344 Apr 2 '19 at 7:54
  • I'm using \documentclass{article} – Codey Apr 2 '19 at 7:54
  • How do you want the title page to look like? – user156344 Apr 2 '19 at 7:55
  • @JouleV After I added \maketitle it works, please post as answer – Codey Apr 2 '19 at 7:56
  • I added an answer. – user156344 Apr 2 '19 at 8:05
0

You just have to add \maketitle before \newpage. This command will generate the title.

\documentclass{article}
\begin{document}
    \title{My Title}
    \author{My Name}
    \maketitle
    \newpage
    \tableofcontents
    \section{Installation}
    aaaaaaaaaaaa
    \subsection{Getting started}
    \subsection{Jamaican rice rat}
    \subsection{White-footed rabbit-rat}
    \section{Butterflies}
    \subsection{Nymphalidae}
    \subsection{Lycaenidae}
    \subsection{Uraniidae}
\end{document}

enter image description hereenter image description here

However, IMHO you should not use \newpage in this case. article already provides titlepage option.

\documentclass[titlepage]{article}
\begin{document}
    \title{My Title}
    \author{My Name}
    \maketitle
    \tableofcontents
    \section{Installation}
    aaaaaaaaaaaa
    \subsection{Getting started}
    \subsection{Jamaican rice rat}
    \subsection{White-footed rabbit-rat}
    \section{Butterflies}
    \subsection{Nymphalidae}
    \subsection{Lycaenidae}
    \subsection{Uraniidae}
\end{document}

and the title page is much nicer

enter image description here

For more customization, you can use titlepage environment.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.