How do I vertically center the text on a page?
Asked
Active
Viewed 4e+01k times
5 Answers
276
This is what I found:
\begin{document}
\topskip0pt
\vspace*{\fill}
text
\vspace*{\fill}
%
\end{document}
Neil G
- 17,947
67
The memoir document class provides, among a lot of other excellent things, the vplace environment.
Try:
\documentclass{memoir}
\begin{document}
\begin{vplace}[0.7]
This is some text to be centered vertically.
\end{vplace}
\end{document}
[0.7] is an optional parameter specifying the ratio of space above to space below. The default value is [1].
jackw11111
- 212
Brent.Longborough
- 27,991
-
1
-
4
-
3I haven't tried your code above. But I am not sure your code will produce an exact vertically-centered object since I notice your code does not specify
\topskip0ptright before\begin{vplace}[1]. For more details, see http://tex.stackexchange.com/questions/7286/how-to-make-an-exact-vertically-centered-object-in-a-page – Display Name Dec 23 '10 at 02:30 -
1@JoeCorneli Thanks for your suggested edit. I've left the brackets, simply to emphasise that it's an optional parameter, and reworded to clarify the rest. – Brent.Longborough Mar 07 '13 at 09:52
-
2Perhaps the anonymous down-voter would care to share his/her reasons here, so that I, and others, can learn and improve? – Brent.Longborough Oct 19 '14 at 12:37
-
1
-
2@Nikos That's because it isn't a package but a documentclass type. So instead of
\documentclass{article}you can usedocumentclass{memoir}. – jackw11111 Jun 02 '19 at 03:17 -
2This isn't quite a solution to the original question, since it requires the user to change their documentclass. There are many other document classes, and good reasons for users to use them. Therefore, a solution that works over a broad range of document classes is more appropriate, unless the question specifically asks to use this class, or specifically states that the document class is not constrained. – MRule Jan 15 '22 at 16:50
-
@MRule There is no perfect solution to this question. If you're using memoir, this answer is probably the best solution. If you're not using memoir, one of the other answers is more appropriate. – Neil G Jun 24 '23 at 18:00
63
This did the job for me:
\pagebreak
\hspace{0pt}
\vfill
Centered text.
\vfill
\hspace{0pt}
\pagebreak
Bora M. Alper
- 1,072
-
8
-
1
-
I really don’t know/remember either, but as Mars said it’s required. @CiprianTomoiagă – Bora M. Alper Nov 22 '18 at 08:51
-
6
\hspace{0pt}is required because vertical space is removed on the start of a document (e.g. pagebreak). – Mateen Ulhaq May 23 '19 at 12:00 -
2
-
This put it a little too far down on the page for my liking, but getting rid of the first
\hspace{0pt}moved it up a bit. – kgrafton Feb 25 '22 at 16:12 -
4
4
In ConTeXt MkIV you use standardmakeup. For horizontal centering add the additional key align=middle as in the example below.
\starttext
\startstandardmakeup[align=middle]
Centered text!
\stopstandardmakeup
\stoptext
Henri Menke
- 109,596
1
Very simple way, like described here.
Text at the top of the page.
\vspace{5mm} %5mm vertical space
This text still at the top, 5mm below the first paragraph.
\vspace{25mm} %25mm vertical space
This text is somewhere in the middle.
\vfill
Text at the bottom of the page.
Sim Son
- 264
-
1you should provide an example of document (regardless that op didn't) which show vertical centering of text on page. – Zarko Feb 22 '18 at 01:36
\clearpage \vspace*{\fill} \begin{center} \begin{minipage}{\textwidth} \centering{This is some text to be centred vertically.} \end{minipage} \end{center} \vfill % equivalent to \vspace{\fill} \clearpage
– Jh0an1 Uzca73gu1 Jan 22 '16 at 11:39