8

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?

8

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
  • 1
    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
6

You can use \vspace command as it follows :

\documentclass{book}
\begin{document}

\begin{center}
\vspace*{\stretch{1}}
Your text centered
\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
  • 1
    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
4
\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}

enter image description here

2

Using picture mode via eso-pic is straight forward:

enter image description here

\documentclass{article}

\usepackage{eso-pic,xcolor}

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

\begin{document}

\AddToShipoutPictureFG{% Add content to page ForeGround
  \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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.