views:

3273

answers:

3

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?

+5  A: 

You start with

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{classname}[2009/02/24]
\LoadClass{article}

and add any customizations after that.

UPDATE: I recommend you to read LaTeX2e for class and package writers: PDF, HTML. The examples in Section 3 (The structure of a class or package) should be helpful.

Can Berk Güder
Well, I already got this far, I even have a bunch of \setlength{..}, but it doesn't seem to work for me. Do you have any well-commented extensions you could share? Perhaps a link to somewhere?
Paulius Maruška
I updated my answer with a link.
Can Berk Güder
Good link. I slept with that thing for a week or so trying to make my dissertation meet the margin lady's approval...
dmckee
@dmckee: those margin ladies... =)
Can Berk Güder
rofl... Yeah, I'll read the link. :)
Paulius Maruška
+3  A: 

A couple of points that might be interesting:

  • You can redefine the margins in the header (i.e. before \begin{document}} by reseting the controlling lengths like \setlength{\textwidth}{6.80in}, \setlength{\oddsidemargin}{0.0in} and so on.

  • \section*{...} will give you un-numbered sections already. Likewise for \subsection* and \subsubsection*. If you do use this trick and also want working references, you might have a look at http://stackoverflow.com/questions/522838/how-do-i-emit-the-text-content-of-a-reference-in-latex.

  • Have you looked at the titlepage environment?

But perhaps most important, the memoir class may give you all the control you need without any class hacking. Check out the documentation.

Or use Can Berk Güder's suggestion.

dmckee
Well, I only looked through it, but it looks very promising.
Paulius Maruška
+5  A: 

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.

godbyk
Very good example. I'll try this stuff now... Thanks! :)
Paulius Maruška