## Thursday, 3 January 2008

### Removing the author and date items from LaTeX titles

The template required for my interim project report uses a header on page 1 to provide name and date information, making those elements of the title which LaTeX usually generates with the \maketitle command redundant. Unfortunately, if you leave them blank, the space for them is still there (rather, the padding around the elements is still there). The code below, inserted into the preamble of a document using article.sty, redefines the \maketitle behaviour by changing the internal \@maketitle variant.

% Remove the author and date fields and the space associated with them
% from the definition of maketitle!
\makeatletter
\renewcommand{\@maketitle}{
\newpage
\null
\vskip 2em%
\begin{center}%
{\LARGE \@title \par}%
\end{center}%
\par} \makeatother

1. Thank you but is there an easier way to do this

2. There may well be, but I don't know of one!

LaTeX is notoriously flexible. Indeed, it is the flexibility that I exploit here to remove the author and date fields, but there are often many ways to achieve the same thing. This one seemed the most obvious to me; redefine what \maketitle does to make it do what I want!

3. \date{} removes date and not including a \author seems to remove it for me.

4. Anonymous,

Using \date{} and not specifying \author prevents those fields being filled, but you'll notice that (unless you are using a document class other than article) the space for them, or rather, the padding around those fields, is retained.

In my case, I wanted to completely remove those paddings, so that the document text begins immediately below the title.

5. Thanks .. I was looking for the same thing :-)

6. Is it possible to explain what you're doing in each line?

7. Here's what is happening in each line.

The first two lines, beginning with the % character, are comments; they just describe what the effect of the next few lines is.

The third line, \makeatletter, tells LaTeX that we want to be in a mode where we can play with the macro definitions. In essence, it makes the @ character special, allowing us to do the stuff we want. For more details on this, google makeatletter and makeatother.

The \renewcommand{\@maketitle}{ tells LaTeX that we want to change the meaning of the macro \@maketitle, which \maketitle calls internally when it generates a title page. The opening brace at the end starts the new command definition.

\newpage should be fairly self-explanatory!

\vskip 2em% introduces 2 em of space (google typographic units for details of what an em is). The % character at the end stops unnecessary whitespace being treated as part of the command, since anything after a % character is treated as a comment.

Next, we tell LaTeX to center our text on the page, with \begin{center}%.

The line {\LARGE \@title \par}% causes the text defined by the \title{...} command to be substituted in here.

\end{center}% leaves the centered text environment, and finally we close the curly brace corresponding to the definition of \@maketitle and issue \makeatother to revert to normal LaTeX mode.

The \par command is equivalent to a blank line.

I hope this helps to understand what is going on here!

8. Thanks! This is exactly what I needed

9. AAAAAHHHH this is so awesome! It took me a while to find this Web page. Thanks for posting it!

10. Although not very elegant, the easiest way for me is to put
\author{}
\date{}
and then manually removing the spaces by setting
\maketitle{Title}\vspace{-2cm}

11. I wanted a document that had no title, no authors, and no date. I just wanted the first Section header to begin right below the top page margin. This helped me figure out how to do that. I just took out all the commands after "\renewcommand{\@maketitle}{" and before "}\makeatother".

thanks!

12. Awesome, I just use some of it to make a simple title:

\makeatletter
{\LARGE \@title \par}
\makeatother