[Tex/LaTex] Custom `maketitle` definition in report

reporttitles

Following this answer I'm trying to customize the cover of a report, which works fine for articles, but doesn't seem to work for reports. For example:

\documentclass[a4paper,12pt]{article}
\usepackage{geometry}

\makeatletter         
\def\@maketitle{
\raggedright
\begin{center}
{\Huge \bfseries \sffamily \@title }\\[4ex] 
{\Large  \@author}\\[4ex] 
\@date\\[8ex]
\end{center}}
\makeatother

\begin{document}

\title{Report}
\author{Author}
\date{Septembre 2013}

\maketitle

\end{document}

works, but when I change article to report the custom title page layout is lost. I could manually use e.g. \begin{titlepage} .., but I actually like the idea of having the definition of the title page elsewhere (for example a custom .sty file) and only including title{}, author{}, and date{} in each document.

Can this somehow be done using the report class?

Best Answer

\maketitle is not a core command; it is defined in each classes. In article, it is defined differently from in report or book.

So why don't you redefine \maketitle directly? No need of redefining \@maketitle.

Btw to keep the formatting, i.e. apply \raggedright for only the title, you need to place the whole thing inside a group.

\documentclass[a4paper,12pt]{report} % Not a4paper12pt
\usepackage{geometry}

\makeatletter         
\renewcommand\maketitle{
{\raggedright % Note the extra {
\begin{center}
{\Huge \bfseries \sffamily \@title }\\[4ex] 
{\Large  \@author}\\[4ex] 
\@date\\[8ex]
\end{center}}} % Note the extra }
\makeatother

\usepackage{lipsum}
\begin{document}

\title{Report}
\author{Author}
\date{Septembre 2013}

\maketitle

\lipsum[1]
\end{document}

enter image description here