TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would center horizontally and vertically a block of text as if it was an abstract text block.How can I do?

I tried this:

\null\vfill
\begin{center}

\end{center}
\vfill\null

it It correct?

share|improve this question
    
The second \null should be \clearpage; I'd use \vspace*{\fill} instead of \null\vfill, but it's personal preference. – egreg Sep 8 '12 at 19:32
    
But how can I justify text...? – Mazzy Sep 8 '12 at 19:33
2  
Use a minipage inside center. – egreg Sep 8 '12 at 19:33
    
How does minipage work? – Mazzy Sep 8 '12 at 19:38
up vote 31 down vote accepted

A "correct" way could be

\clearpage
\vspace*{\fill}
\begin{center}
\begin{minipage}{.6\textwidth}
Text that will be justified
...
\end{minipage}
\end{center}
\vfill % equivalent to \vspace{\fill}
\clearpage

The top vertical space should be \vspace*, so it doesn't disappear at the break. The justified text will be on a line width that's 6/10 of the normal line width, change the fraction to suit you.

You can in a similar way decide also for different spaces at the top and at the bottom; for instance

\clearpage
\vspace*{\stretch{2}}
\begin{center}
\begin{minipage}{.6\textwidth}
Text that will be justified
...
\end{minipage}
\end{center}
\vspace{\stretch{3}}
\clearpage

will leave spaces in the proportion 2/3; something of this kind can turn useful for a dedication page, as the dedication is usually not in the center of the page.

If you need that the text inside the minipage has indented paragraphs as the normal text, then center and minipage are not good. This can be accomplished by a more complicated construction:

\documentclass{article}
\usepackage{lipsum}

\begin{document}

\clearpage
\vspace*{\fill}
\begin{list}{}{%
  \leftmargin=.2\textwidth
  \rightmargin=.2\textwidth
  \listparindent=\parindent
  \itemindent=\parindent
  \itemsep=0pt
  \parsep=0pt}
\item\relax
\lipsum[1-2]
\end{list}
\vfill % equivalent to \vspace{\fill}
\clearpage

\end{document}

The package lipsum just produces some text.

share|improve this answer
    
The \vspace*{\fill} just added an additional page for me. Any explanation as why that's happening? Any why do you use it would be helpful. – user14492 Dec 14 '15 at 15:32
    
@user14492 A bit too generic, isn't it? – egreg Dec 14 '15 at 15:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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