How to vertically center a text on a page in LaTeX?
In this tutorial, I will show you various methods to center a text or block of text vertically on a page in LaTeX.
Method 1.
You can use the \vfill
command before and after the text to make this text centered vertically. But if the text is the first text on this page then you have to use a \null
command before the first \vfill
command.
\documentclass{article} \begin{document} \null \vfill This text will be centered vertically. \vfill \end{document}
Output:
Method 2.
Also, you can use the \vspace{\fill}
command before and after the text. You have to use the \null
command here also. Like this.
\documentclass{article} \begin{document} \null \vspace{\fill} This text will be centered vertically. \vspace{\fill} \end{document}
Method 3.
You can use the \vspace*{\fill}
command before and after the text. In this case, you don’t have to use the \null
command.
\documentclass{article} \begin{document} \vspace*{\fill} This text will be centered vertically. \vspace*{\fill} \end{document}
Output:
Leave a Reply