Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Suppose you have a title page layout that you like and want to use it for many different projects.

Thus the only change you will make to it will be the project name, subtitle, date, author, ... etc

How would I create a function that generates a title page layout from some variables and then inputs it into my project file?

Thanks!!

share|improve this question
    
With the environment titlepage you can use \maketitle. Define your variables and use them in titlepage. –  Kurt Sep 4 '12 at 22:17

1 Answer 1

up vote 12 down vote accepted

One possibility is to write a little package, say titlepage.sty; in this package you can define some commands to provide the information that you will use for the titlepage and define a command to effectively produce the titlepage.

A little example: since standard LaTeX provides \author, \title, and \date, in the folowing example I only defined \subtitle and \institute in a way completley analogous to the definition of \author.

Once all the preparations have been done, you define your command to produce the titlepage, using the desired formatting for the elements that will be used.

Here's a very simple version of mytitlepage.sty:

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mytitlepage}

\def\subtitle#1{\gdef\@subtitle{#1}}
\def\@subtitle{\@latex@warning@no@line{No \noexpand\subtitle given}}
\def\institute#1{\gdef\@institute{#1}}
\def\@institute{\@latex@warning@no@line{No \noexpand\institute given}}

\newcommand\mytitlepage{%
\clearpage
\thispagestyle{empty}
{\noindent\huge\bfseries\@author\par}
\vspace*{.25\textheight}
{\raggedleft\Huge\itshape\@title\par
\large\normalfont\@subtitle\par}
\vfill
{\Large\noindent\@institute\par\medskip
\noindent\large\@date\par}
\clearpage
}

\endinput

You can save this file in your local tree and then all you have to do is to load the package in the preamble of your document, use the commands to provide the fields and invoke \mytitlepage:

\documentclass{book}
\usepackage{mytitlepage}

\title{The Title}
\subtitle{The Subtitle}
\author{The Author}
\institute{The Institute}
\date{The date}

\begin{document}

\mytitlepage

\end{document}
share|improve this answer
    
That's exactly what i wanted. Thank you so much. –  Fawkes5 Sep 6 '12 at 22:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.