# Center the text in whole page

I have just a single line on one page. I want to bring it on the center of page both through length and breadth. How can it be done?

My try:

\documentclass{scrartcl}
\begin{document}
\
\vfil
\hfil Centered text \hfil
\vfil
\end{document}

• Damn, you were quicker by a few seconds ;-) – user31729 Jan 1 '16 at 18:34
• Thanks it worked. What if the text is in three lines? – user87834 Jan 1 '16 at 18:43
• Then suppress the \hfil commands and insert the \centering command just before your text (or enclose this text in a center environment). – Franck Pastor Jan 1 '16 at 18:57

You can use \vspace command as it follows :

\documentclass{book}
\begin{document}

\begin{center}
\vspace*{\stretch{1}}
\vspace*{\stretch{1}}
\end{center}

\clearpage

\end{document}


It works without text before and the text centered can be as long as possible (one page). \stretch makes nice effects.

• \clearpage should be added, if more pages follow. – egreg Jan 1 '16 at 18:59
• This is not horizontally centered for me. – Alenanno Jan 1 '16 at 19:16
• You also need a center environment, if you want horizontal centering – egreg Jan 1 '16 at 21:36
• Yes, egreg is right. Before you may use \begin{center} and at the end \end{center}. – PMC1234 Jan 2 '16 at 12:38
\documentclass{article}
\usepackage[paper=a6paper]{geometry}% Just for this example
\pagestyle{empty}% Just for this example

\begin{document}
\vspace*{\fill}% * is needed here
\noindent
\makebox[\textwidth]{\Huge SoMeTHiNG}

\vfill
\end{document}


Using picture mode via eso-pic is straight forward:

\documentclass{article}

\usepackage{eso-pic,xcolor}

\usepackage[paper=a6paper]{geometry}% Just for this example
\pagestyle{empty}% Just for this example

\begin{document}

\AtPageCenter{% Add content to page centre
\raisebox{-.5\height}{\makebox[0pt]{%
\Huge SoMeTHiNG%
}}
}
}

\mbox{}% Just for something on the page

\clearpage

% Comparison to http://tex.stackexchange.com/a/285473/5764
\vspace*{\stretch{1}}
{\centering\Huge\textcolor{black!50}{SoMeTHiNG}\par}%
\vspace*{\stretch{1}}

\end{document}