[Tex/LaTex] How to add components to \maketitle

articletitles

The \maketitle function for articles and reports proves useful, but the format required for my situation is different from the standard Title that is given. I am using LaTeX from MiKTeX on Windows, and have found the class and style files for article, but can't understand the code completely. I need to modify:

  • Add a component to be created called \class, which would work the same was as \author.
  • Make the Title show below the author, class, and date.
  • Flush the author, class, and date to the right.

To illustrate, I want to be able to write my maketitle code like the following:

\documentclass[notitlepage,12pt,Arial]{article}
\author{Me}
\date{April 14, 2015}
\class{1}
\title{Example Title}
\begin{document}
\maketitle
Some Text here.
\end{document}

It should turn out Something like the following:
Example created with a word processor

Best Answer

If there are only one author and one class (i.e., without using \and), some like this could be enough:

MWE

\documentclass[11pt]{article}

\makeatletter
\def\class#1{\gdef\@class{#1}}
\def\@class{\@latex@warning@no@line{Hey you, no \noexpand\class given}}
\def\@maketitle{%
  \newpage \null  \vskip 2em%
  \begin{flushright}%
  \let\footnote\thanks
    \vskip 1.5em%
    {\large  \lineskip .5em%
      \begin{tabular}[t]{r@{}}%
        \@author    
     \end{tabular}\par 
      \begin{tabular}[t]{r@{}}%
      {\sffamily \@class}   
     \end{tabular}\par 
  \par}%
    \vskip .5em%
   {\small\@date}\par\bigskip%
    {\LARGE\scshape \@title \par\bigskip\hrule}%
  \end{flushright}%
  \par   \vskip 1.5em}
\makeatother


\title{Some long Wonderfull Title}
\class{UFO affairs\thanks{Area 51}} 
\author{Clever Reporter\thanks{No dot disturb.}}
\date{\today}

\begin{document}
\maketitle
\end{document}

If you can have several authors and classes, then left the tabular as environment as originally defined (with one ccolumn type) and simply use \author{author\\class \and author\\class \and ...}