I have created a custom title page format within the titlepage environment. I'd like to put that in a class or package, and be able to use that format in every document by simply specifying the \title and \author and calling the \maketitle command at the beginning of the document. How could I do it?
Asked
Active
Viewed 4,700 times
4
noibe
- 2,084
1 Answers
5
You can use \renewcommand and \@title and \@author (as John Kormylo pointed out). This is one way to do it (you can customize titlepage to anything you want):
\documentclass{book}
\usepackage{lipsum}
\usepackage{tikz}
\usepackage{anyfontsize}
\usepackage{geometry}
\usetikzlibrary{positioning,calc}
\makeatletter
\renewcommand{\maketitle}{%
\begin{titlepage}
\topskip0pt
\vspace*{\fill}
\noindent\begin{tikzpicture}
\node[
text width=\textwidth-2cm,
align=left,
font=\fontsize{40}{40}\selectfont\scshape,
inner xsep=.5cm
] (x) {\@title};
\draw (x.north west) node[
draw,
above right=2cm and 0pt,
font=\huge,
inner sep=.2cm
] (y) {\textit{\bfseries By} \textsc{\@author}};
\draw (y.south west)--($(x.south west)+(0,-2)$);
\end{tikzpicture}
\vspace*{\fill}
\end{titlepage}
}
\makeatother
\begin{document}
\author{My name}
\title{Lorem Lipsum}
\maketitle
\lipsum[1]
\end{document}

\maketitlecommand. – Mar 23 '19 at 20:08\renewcommand{\maketitle}{\begin{titlepage}...\end{titlepage}}using @title and @author. This is actually how \maketitle is defined for standard document classses, only the ... part changes. – John Kormylo Mar 23 '19 at 20:15titlingpackage might be helpful for that. – Bernard Mar 23 '19 at 20:18