How do I vertically center the text on a page?
5 Answers
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]
.
-
4Fantastic! I think we ought to start a memoir fanclub... Commented Aug 27, 2010 at 11:49
-
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
\topskip0pt
right before\begin{vplace}[1]
. For more details, see tex.stackexchange.com/questions/7286/… Commented Dec 23, 2010 at 2:30 -
2Perhaps the anonymous down-voter would care to share his/her reasons here, so that I, and others, can learn and improve? Commented Oct 19, 2014 at 12:37
-
2@Nikos That's because it isn't a package but a documentclass type. So instead of
\documentclass{article}
you can usedocumentclass{memoir}
. Commented Jun 2, 2019 at 3: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.– MRuleCommented Jan 15, 2022 at 16:50
This is what I found:
\begin{document}
\topskip0pt
\vspace*{\fill}
text
\vspace*{\fill}
%
\end{document}
-
5Very useful for stuff that does not take the placement modifiers, like equations. thanks– rllCommented Jan 8, 2016 at 11:17
-
10With this suggestion, I get a perfect vertically center text on a page, but I get several blank pages in other areas of the document. Commented Jan 21, 2016 at 11:12
-
4How do you solve the problem with extra blank pages like @Jh0an1Uzca73gu1 mentioned? Commented Jan 21, 2016 at 15:24
-
2I use the following code, suggestion of other tex.stackexchange.com thread: \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 Commented Jan 22, 2016 at 11:39
-
1
This did the job for me:
\pagebreak
\hspace{0pt}
\vfill
Centered text.
\vfill
\hspace{0pt}
\pagebreak
-
9
-
1
-
7
\hspace{0pt}
is required because vertical space is removed on the start of a document (e.g. pagebreak). Commented May 23, 2019 at 12:00 -
2Of all solutions proposed here, this is the one that worked for me. Commented Dec 5, 2020 at 10:45
-
5it's easier to replace
\hspace{0pt}\vfill
with\vspace*{\fill}
Commented Sep 28, 2022 at 12:01
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
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.
-
1you should provide an example of document (regardless that op didn't) which show vertical centering of text on page.– ZarkoCommented Feb 22, 2018 at 1:36