# modular title pages

How to achieve having modular title pages in latex (xelatex), to only have to change one word in the .tex file and have it changed?

All the files must be defined in the project's directory, not somewhere else on the system (the project is versioned and shared).

I am defining my class on top of book called yapbook.

The relevant piece of the class:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{yapbook}[2010/10/04 Yet Another Project''s book class]

%------------------------------------------------------------------------------
% useful for tex programming
%------------------------------------------------------------------------------
\RequirePackage{needspace}
\RequirePackage[usenames,dvipsnames]{color}
\RequirePackage{kvoptions}

\SetupKeyvalOptions{
family=YAPBOOK,
prefix=YAPBOOK@
}
\DeclareStringOption[phpro]{titlepagestyle}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}}

\ProcessKeyvalOptions*
\ProcessOptions

% here more code

\def\@maketitle{
\RequirePackage{titlepage-\YAPBOOK@titlepagestyle}
}
\renewcommand*{\maketitle}{
\@maketitle
%here more stuff
}


And the class titlepage-phpro looks like this:

\begin{titlepage}
\thispagestyle{empty}
\null
\vskip 2em%
\begin{center}%
\textsc{\huge \@title}
\vspace{1em}
%\hrule
\vspace{3em}
\textit{\textbf{\shorttitle}}
\vspace{3em}
\hrule
\vspace{8em}
\authors \\
\vspace{3em}
\@date
\end{center}
\vfill
\begin{flushright}
O iniţiativă \emph{Yet Another Project}\\
Homepage: \url{http://yet-another-project.github.com/}
\end{flushright}
\end{titlepage}


Now I do realize, that this is completely wrong, but I don't know how to wire these pieces correctly so that it works. The individual chucks of latex code used to work. It is a requirement to have the definition of title pages in individual files, to have it modularized, and to not have to specify too many things in the "client code" (the .tex master file).

Another very important requirement is to make the usage of this infrastructure semantic, so there should be no \include in the client code.

The complete code can be found at https://github.com/yet-another-project/booktemplate

-
What is the question? –  Guido Aug 10 '12 at 22:44
You mean the first line is not clear? I've added a few more sentences. –  Flavius Aug 11 '12 at 2:15

I hope I understand your question correctly. This is my understanding: you want to change the style of the titlepage by setting the titlepage option of the class, and the titlepage styles need to be defined in separate files.

In your code, \RequirePackage is called within the body of the document, since this is where \maketitle is called. I think this is why your approach does not work.

I have modified your code to input the modular titlepage definition in the preamble, based on the given value of titlepage. The titlepage style file defines @\maketitle which is called by \maketitle.

The class:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{yapbook}[2010/10/04 Yet Another Project''s book class]

%------------------------------------------------------------------------------
% useful for tex programming
%------------------------------------------------------------------------------
\RequirePackage{needspace}
\RequirePackage[usenames,dvipsnames]{color}
\RequirePackage{kvoptions}

\SetupKeyvalOptions{
family=YAPBOOK,
prefix=YAPBOOK@
}
\DeclareStringOption[phpro]{titlepagestyle}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}}

\ProcessKeyvalOptions*
\ProcessOptions

% here more code

\RequirePackage{titlepage-\YAPBOOK@titlepagestyle}
\renewcommand*{\maketitle}{
\@maketitle
%here more stuff
}


titlepage-phpro (\shorttitle and \authors are commented out since they do not compile on my system):

\ProvidesPackage{titlepage-phpro}
\RequirePackage{url}
\def\@maketitle{%
\begin{titlepage}
\thispagestyle{empty}
\null
\vskip 2em%
\begin{center}%
\textsc{\huge \@title}
\vspace{1em}
%\hrule
\vspace{3em}
%\textit{\textbf{\shorttitle}}
%\vspace{3em}
\hrule
\vspace{8em}
%\authors \\
\@author
\vspace{3em}
\@date
\end{center}
\vfill
\begin{flushright}
O iniţiativă \emph{Yet Another Project}\\
Homepage: \url{http://yet-another-project.github.com/}
\end{flushright}
\end{titlepage}%
}


Test .tex file:

\documentclass[titlepage=phpro]{yapbook}
\title{The title}
\author{The author}
\begin{document}
\maketitle
\end{document}

-
I'm terribly sorry, I was on vacation and I couldn't give you the well-deserved boundy! I'll upvote your answers and questions every now and then on this website, to make up for it! –  Flavius Aug 23 '12 at 18:54
No problem... glad I could help. –  Sašo Živanović Aug 24 '12 at 11:18