This is a follow up to my last question, but since the question I'm asking is substantially different despite trying to solve the same problem, I figured I'd make a new thread.

Anyway, I am trying to make a common title page to use in my documents, where I can just call a package to make a commonly formatted title. I'm hoping to just be able to put something like this in the preamble:


I know that I will need to use the form course={Viscous flow} type of input with the xkeyval package. However, I am having a lot of trouble passing in the values because the TeX language style is much different from the other codes in which I've written.

The limited information that I can find is in a post like this one, but I really don't understand what's going on in the answers section, or how I might be able to apply it to this. Additionally, it looks like I might need to do something different in passing in the values, considering multiple values are embedded in a single set of { } (for example, course, title, AND date all go inside the \title command).

Here is my current style file:

% This style file requires at least LaTeX version 2e.

\ProvidesPackage{customTitle}[2020/07/29 Custom LaTeX title]



\ProcessOptions\relax   %end options processing and return to normal LaTeX syntax

\title{ \normalsize \textsc{[[course]]}
        \\ [2.0cm]
        \\ [0.3cm]
        \LARGE \textbf{\uppercase{[[title]]}}
        \\ [0.5cm]
        \normalsize [[date]] \vspace*{3\baselineskip}}

        \Large\textbf{[[name]]} \\
        \small Student ID [[id]] \\ [0.5cm]
        \small [[school]]\\
        \small [[department]] 


I have no idea where to go from here. I also know that there's a way to set default values, but I haven't been able to find anything solid on that which will compile. If an option isn't specified in the package input, I'm just hoping to have it be blank.

Even just help getting the \title{ } tag with multiple values set up will be a great help, hopefully I'll be able to figure the rest out based on that. Thank you!

1 Answer 1


I have found a way around using xkeyval that I wanted to share.

In my efforts to create a title page that is easily modified from each document, but which does not have a lot of code inside each document, I have been helped to create this. It requires the use of two custom packages, one of which I was going to use anyway (in my standard preamble package), and the other which needs to be inserted after the declarations. Some sample code is below, all of would appear in the preamble of a document.

%Group 1: "variable" definitions - this will appear in a custom package if needed or in a standard preamble package which is called before everything else that follows.

    %This section, also a part of Group 1, is optional -- it simply sets the default values if they are not specified later.

For example, if I type \myauthor{Me!}, this declaration will store "Me!" as \theauthor.

This code segment I have left in my standard preamble package. The next part is specific to each document, and is where one would set the title, date, etc.:

\mytitle{Some title for the document}
\mydate{The date, or alternatively, \today}
\mycourse{the course}
\myauthor{the author's name}
\myid{author's ID}
\myschool{the university or school}
\mydepartment{the department of the author}

One would declare each of these things in their specific document. If default values are set, then these don't all have to be included, and the default values will be used without an error being thrown.

Finally, I included this last code block in a custom package called customTitle. It is what actually generates the title (so if you have another title page or the like that you prefer, this is where you'd change the style):

% This style file requires at least LaTeX version 2e.

% Provide the name of your page, the date it was last updated, and a comment
\ProvidesPackage{customTitle}[2020/07/29 Generate custom LaTeX title]

\title{ \normalsize \textsc{\thecourse}
        \\ [2.0cm]
        \\ [0.3cm]
        \LARGE \textbf{\uppercase{\thetitle}}
        \\ [0.5cm]
        \normalsize \thedate \vspace*{3\baselineskip}

        \Large\textbf{\theauthor} \\
        \small Student ID \theid \\ [0.5cm]
        \small \theschool\\
        \small \thedepartment 

% Use \endinput to indicate that LaTeX can stop reading this file (anything after this like will be ignored)

Notice how the original variable declarations are utilized here in the form of \mytitle, etc.

Note These code segments, whether they are used in another package or all in the same document, must appear in the same order. The logical order follows "variable" declarations, (optional: default variable settings), setting the variables, and finally generating the title page off of the custom variable settings.

Hope this helps someone else out there.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .