# How to get the code on a single page [duplicate]

Hi I am new to Latex and am trying to create a latex document with the following preamble and content.

While, the code produces the desired output, somehow all the output comes on page 2, leaving page 1 totally blank.

\documentclass[a4paper,12pt]{article}
\topmargin 0pt
\advance \topmargin by -\headheight
\advance \topmargin by -\headsep
\textheight 8.9in
\usepackage{enumerate}
\oddsidemargin 0pt
\evensidemargin \oddsidemargin
\marginparwidth 0.5in
\textwidth 6.5in

\begin{document}

\title{ MISC \\
Homework II \\
Computer Science \\Fall 2011\\}
\date{ September 17, 2011 }

\begin{center}
\begin{Large}
\maketitle{All the code here is entirely mine}\\
\end{Large}
\end{center}

\end{document}


Could someone help me in figuring out what I am doing wrong.

P.S. If I dont center my title, the output does show on a single page, but the formatting is not very presentable.

-

## marked as duplicate by Marco Daniel, Harish Kumar, percusse, morbusg, Claudio FiandrinoSep 18 '12 at 18:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Don't use the center environment as it adds vertical space. Instead use \centering. See Should I use center or centering for figures and tables?. – Peter Grill Sep 17 '12 at 5:48
@PeterGrill: that is only important if you have another command which adds also vertical space like \caption. In the above example it is correct to use the environment center – Herbert Sep 17 '12 at 6:05
This looks very much like tex.stackexchange.com/questions/29440/… – Joseph Wright Sep 17 '12 at 7:01

## 3 Answers

\maketitle takes no arguments. To get the desired output, the code is

\begin{document}

\title{ MISC \\
Homework II \\
Computer Science \\Fall 2011\\}
\date{ September 17, 2011 }

\maketitle

\begin{center}
\begin{Large}
All the code here is entirely mine
\end{Large}
\end{center}
\end{document}


Note that the title and date definition may be done in the preamble, that is, before \begin{document}.

-

There are a few problems with your code: \maketitle does not take any arguments. It just print the title, author, data data according to the predefined style. For article the title is on the same page as the text. You can use the titlepage option for the document class article or switch to report class.

The \\ in the line of \maketitle is useless.

\documentclass[a4paper,12pt,titlepage]{article}
\topmargin 0pt
\advance \topmargin by -\headheight
\advance \topmargin by -\headsep
\textheight 8.9in
\usepackage{enumerate}
\oddsidemargin 0pt
\evensidemargin \oddsidemargin
\marginparwidth 0.5in
\textwidth 6.5in

\begin{document}

\title{ MISC \\
Homework II \\
Computer Science \\
Fall 2011}
\date{ September 17, 2011 }
\author{Your Name\thanks{All the code in this report is entirely mine}}

\maketitle

\end{document}

-

use the environment titlepage if you want to create your own title and set the margins with package geometry:

\documentclass[a4paper,12pt]{article}
\usepackage{geometry}
\geometry{textheight=8.9in,textwidth=6.5in,marginparwidth=0.5in}
\usepackage{enumerate}
\begin{document}

\begin{titlepage}
\begin{center}
\Large
MISC \\
Homework II \\
Computer Science \\Fall 2011

\vspace{1cm}
September 17, 2011

\vspace{1cm}
All the code here is entirely mine
\end{center}
\end{titlepage}

next page
\end{document}

-