Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you extend article document class in LaTeX?

I don't really need a lot of changes to the default article document class. All I want is:

  • redefine page margins (I want them to be the same on all pages, but different from the default values);
  • use title page;
  • add more elements on the title page (title, author and date is not enough for me, I want company and company logo to be on the title page as well);
  • change styles of the sections, subsections and subsubsections (I don't want the numbers to be shown, otherwise - they're good).

Perhaps, there are some packages that could be helpful in this case?

like image 830
Paulius Avatar asked Feb 24 '09 14:02

Paulius


People also ask

Why do we use document class articles in LaTeX?

The article class does not start a new page by default, while report and book do. Instructs LaTeX to typeset the document in two columns instead of one. Specifies whether double or single sided output should be generated. The classes article and report are single sided and the book class is double sided by default.

What does Documentclass mean in LaTeX?

Classes in LaTeX. The first line of code in any LaTeX document is the document class declaration command. It is here that we declare the class of which we'd like to build our document around. \documentclass{ class_name } So a document starting \documentclass{article} may be called “an article document”


1 Answers

There are a number of packages that can help you achieve the results you're looking for. The packages I've selected below are the ones I like, but there is more than one way to do it.

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{paulius-article}[2009/02/25 v0.1 Paulius' modified article class]

% Passes and class options to the underlying article class
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions

% Load LaTeX's article class with the `titlepage' option so that \maketitle creates a title page, not just a title block
\LoadClass[titlepage]{article}

% Redefine the page margins
% TODO: Adjust margins to your liking
\RequirePackage[left=1in,right=1in,top=1in,bottom=1in]{geometry}

% Remove the numbers from all the headings (\section, \subsection, etc.)
\setcounter{secnumdepth}{-1}

% To modify the heading styles more thoroughly use the titlesec package
%\RequirePackage{titlesec}

% Adjust the title page design
% NOTE: This is the default LaTeX title page -- free free to make it look like whatever you want.
% TODO: Add company name and logo somewhere in here.
\newcommand{\maketitlepage}{%
  \null\vfil
  \vskip 60\p@
  \begin{center}%
    {\LARGE \@title \par}%
    \vskip 3em%
    {\large
     \lineskip .75em%
      \begin{tabular}[t]{c}%
        \@author
      \end{tabular}\par}%
      \vskip 1.5em%
    {\large \@date \par}%       % Set date in \large size.
  \end{center}\par
  \@thanks
  \vfil\null%
  \end{titlepage}%
}

% This some before-and-after code that surrounds the title page.  It shouldn't need to be modified.  
% I've pulled out the part the actually typesets the title page and placed it in the \maketitlepage command above.
\renewcommand\maketitle{\begin{titlepage}%
  \let\footnotesize\small%
  \let\footnoterule\relax%
  \let \footnote \thanks%
  \maketitlepage%
  \setcounter{footnote}{0}%
  \global\let\thanks\relax
  \global\let\maketitle\relax
  \global\let\@thanks\@empty
  \global\let\@author\@empty
  \global\let\@date\@empty
  \global\let\@title\@empty
  \global\let\title\relax
  \global\let\author\relax
  \global\let\date\relax
  \global\let\and\relax
}

% TODO: If there are any other article modifications required, add them here.

% That's all, folks!
\endinput

You'll want to read the documentation for the geometry package to adjust the margins. The titlesec package can be used if you want to modify the appearance of the headings (aside from just turning off the numbers).

The titlepage is LaTeX's default title page. You'll need to modify it to add your company name and logo. I've separated out the "stuff to be printed" from all the other code associated with the title page. You should only need to change the \maketitlepage command. In your document, use \maketitle to print the title page.

\documentclass{paulius-article}

\title{My New Document Class}
\author{Paulius}

\usepackage{lipsum}% provides some filler text

\begin{document}
\maketitle% Actually makes a title page

\section{Section Heading}
\subsection{Look no numbers!}
\lipsum[1-10]

\end{document}

Let me know if I missed any of your requirements.

like image 167
godbyk Avatar answered Nov 10 '22 06:11

godbyk