How to set maintitle and subtitle in LaTeX?
In this tutorial, I will show you how to set the main title and subtitle in LaTeX in every document class.
Usually, we use the \title{}
command to set the title in LaTeX. There are no specific commands for adding subtitles to LaTeX.
So, to add the main title and subtitle to the document you need to do this.
\title{Main title \\ Subtitle}
Now if you want to reduce the font size of the subtitle from the main title then you can do it by \large
command. Like this
\title{Main title \\ \large Subtitle}
\documentclass{article} \title{This is Main title \\ \large This is Subtitle} \author{Parvez Akhtar Pasha \\ \texttt{CodeSpeedy}} \begin{document} \maketitle \end{document}
Output:
Set vertical space between main title and subtitle
You can also set the vertical space between main title and subtitle with \\[<len>]
. You can set the value of any unit here <len>
that LaTeX accepts. Like this
\title{Main title \\[<len>] \large Subtitle}
\documentclass{article} \title{This is Main title \\ [0.2em]\large This is Subtitle} \author{Parvez Akhtar Pasha \\ \texttt{CodeSpeedy}} \begin{document} \maketitle \end{document}
Output:
Custom font size for subtitle in LaTeX
If you want a custom font size for the subtitle then you have to use the \fontsize{<size>}{<baseline>}
command, it sets the font size and the baseline skip (the space between the baseline of two consecutive lines). Then you have to use \selectfont
before the subtitle.
\documentclass{article} \title{This is Main title \\ {\fontsize{12pt}{14pt}\selectfont This is Subtitle}} \author{Parvez Akhtar Pasha \\ \texttt{CodeSpeedy}} \begin{document} \maketitle \end{document}
Output:
Leave a Reply