2

I have a block of text that I want to be in the center of the page, i.e. there is the same amount of space between the top of the paper and the start of the bock and between the bottom of the paper and the end of the block. The block has to be centered regardless of other blocks on the page

To be more specific, I want to write a letter that consists of two paragraphs, centered vertically on the page. There also has to be an address on the top, but I do not want this to influence the centering.

I want to achieve the effect from this question, but not for Beamer.

2
  • 1
    solution in given link works at any \documentclass{...} ...
    – Zarko
    Oct 27, 2017 at 17:46
  • You on one hand say at the center of the "page" which many will take to mean the printable area of the paper (excluding margins), while you also indicate centering with respect to the "paper". Since the printable page may not be centered on the paper, the distinction is quite important what you seek. Oct 28, 2017 at 19:24

2 Answers 2

2

Centered with respect to the PAPER, regardless of other content on page, stealing my answer from What are the ways to position things absolutely on the page?

REVISED ANSWER

This accounts for the OP's edited purpose, namely "I want to write a letter that consists of two paragraphs, centered vertically on the page. There also has to be an address on the top, but I do not want this to influence the centering."

\documentclass{article}
\usepackage{everypage}
\usepackage{lipsum}
% THESE ARE LaTeX DEFAULTS; CAN CHANGE IF NEEDED.
\def\PageTopMargin{1in}
\def\PageLeftMargin{1in}
\newcommand\atxy[3]{%
 \AddThispageHook{\smash{\hspace*{\dimexpr-\PageLeftMargin-\hoffset+#1\relax}%
  \raisebox{\dimexpr\PageTopMargin+\voffset-#2\relax}{#3}}}}
% VERIFIED THAT SETTING \hoffset AND \voffset DO NOT BREAK SOLUTION.
%\hoffset=0.4in
%\voffset=0.2in
\begin{document}
\noindent Name\\
Address\\
Anytown, USA 12345

\atxy{.5\paperwidth}{.5\paperheight}{%
  \makebox[0pt]{\parbox{\textwidth}{\parindent1em\relax\lipsum[1-2]}}}
\end{document}

enter image description here

ORIGINAL ANSWER

\documentclass{article}
\usepackage{everypage}
\usepackage{lipsum}
% THESE ARE LaTeX DEFAULTS; CAN CHANGE IF NEEDED.
\def\PageTopMargin{1in}
\def\PageLeftMargin{1in}
\newcommand\atxy[3]{%
 \AddThispageHook{\smash{\hspace*{\dimexpr-\PageLeftMargin-\hoffset+#1\relax}%
  \raisebox{\dimexpr\PageTopMargin+\voffset-#2\relax}{#3}}}}
% VERIFIED THAT SETTING \hoffset AND \voffset DO NOT BREAK SOLUTION.
%\hoffset=0.4in
%\voffset=0.2in
\begin{document}
\atxy{.5\paperwidth}{.5\paperheight}{%
  \fboxsep=200pt\relax\makebox[0pt]{\fbox{\Huge I AM CENTERED}}}
\lipsum[1]
\end{document}

enter image description here

1

Try this:

\documentclass{article}% or book, report, etc
\usepackage{lipsum}
\begin{document}
\lipsum[1] % some text
\clearpage % go to next page.
\mbox{}
\vfill
\lipsum[2] % more text, vertically centered
\vfill
\mbox{}
\clearpage % go to next page
\lipsum[3] % yet more text
\end{document}

Or if you want the middle text centered with respect to the before and after texts then delete the two \clearpage and \mbox{} macros.

3
  • Thank you! However, can I have the three pages "merged"? The point is that I need to put an address into the top corner, but I do not want it to influence the centering of the 2nd text. Oct 31, 2017 at 14:09
  • @cubeception Your original question was just about centering text on a page with no mention that there might be other text before and after. I have extended my answer. Nov 1, 2017 at 19:09
  • @cubeception My apologies, I did not read your question carefully enough. You did mention other text on the page. Nov 1, 2017 at 20:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .