When creating a document in LaTeX, we need different font sizes. There are two ways to change the font size in LaTeX.
First, you can change the font size of the entire document or at the global level which will affect all parts of the document such as headings, normal text, etc.
And secondly changing the font size locally or a particular element or a small sentence affects it where you need it.
Change the font size on a global level
Normally Latex has a global level font size of 10pt which is the default font size of the document. Standard classes (Article, Book, Report, Letter) support three font sizes 10pt, 11pt, and 12pt, and these font sizes are passed as optional arguments in square brackets to the Document class. like this
\documentclass[12pt]{article}
Below are examples of default 10pt and 12pt font sizes.
\documentclass{article}
\usepackage{lipsum}
\begin{document}
\begin{center}
\lipsum[1]
\end{center}
\end{document}
Output :
\documentclass[12pt]{article}
\usepackage{lipsum}
\begin{document}
\begin{center}
\lipsum[1]
\end{center}
\end{document}
Output :
In the above example, you can see the output difference between 10pt(default) and 12pt font sizes.
Usually, these font sizes are enough for the global level, but if you want to use more font sizes, you can use the extsizes package. This package gives you the option to use 8pt, 9pt, 10pt, 11pt, 12pt, 14pt, 17pt, 20pt sizes.
\documentclass[9pt]{article}
\usepackage{lipsum}
\usepackage{extsizes}
\begin{document}
\begin{center}
\lipsum[1]
\end{center}
\end{document}
Output :
Change the font size locally
LaTeX has several commands to change the font size locally, of which \normalsize
is the default size. The commands are given below
{\Huge LaTeXhelp}
{\huge LaTeXhelp}
{\LARGE LaTeXhelp}
{\Large LaTeXhelp}
{\large LaTeXhelp}
{\normalsize LaTeXhelp} % Default size
{\small LaTeXhelp}
{\footnotesize LaTeXhelp}
{\scriptsize LaTeXhelp}
{\tiny LaTeXhelp}
You can use these font sizes in LaTeX inline or as an environment. Above shows how to change font size inline and below are some examples by environment.
\documentclass{article}
\begin{document}
\begin{huge}
LaTeXhelp
\end{huge}
\begin{large}
LaTeXhelp
\end{large}
\end{document}
Output :
An important point here is that to change the font of a paragraph the gap between two successive lines is not adjusted well, in that case, you can use the \par
command at the end of the text it adjusts baselineskip . take a look
\documentclass{article}
\begin{document}
\textbf{The gap between lines not adjusted}\\[4pt]
\begin{huge}
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text
\end{huge}
\end{document}
Output :
In the output above you can see that the line spacing is too bad to not use the \par
command.
Using this command in the example below, the line spacing is adjusted very well. And you can also use this command for inline font change at the end of the text.
\documentclass{article}
\begin{document}
\textbf{The gap between lines adjusted}\\[4pt]
\begin{huge}
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text
\par
\end{huge}
\end{document}
Output :
Change font size using package
LaTeX has a package called anyfontsize to manually change the font size, by which you can use smaller than \tiny
and larger than \Huge
, and you can also use exact sizes like 3.5pt, 4.6pt, 15.5pt, etc.using this command below
{\fontsize{size}{baselineskip}\selectfont TEXT}
This command takes two arguments. Here in the place of size you need to put the font size as per your need and in the place of baselineskip, you have to put how much space between two successive lines. And the most important baselineskip is always 1.2x the font size you use.
\documentclass{article}
\usepackage{mathptmx}
\usepackage{anyfontsize}
\begin{document}
{\fontsize{40pt}{48pt}\selectfont 40pt,}
{\Huge It's Huge,}
{\fontsize{20pt}{24pt}\selectfont 30pt,}
{\tiny It's tiny,}
{\fontsize{3.5pt}{4.2pt}\selectfont 3.5pt,}
\end{document}
Output :
Very good article