# How to vertically center content of page without makeup in ConTeXt?

I need to vertically center the content of page, content is forced to be on a separate page (delimeted with \page command).

previous page content

\page

this content must be verticaly centered on it's page.

\page

next page

placing \vfill after first \page does nothing. I need to center content without using makeup, because makeup removes page numbering, but I need to typeset this page as usual.

• \dontleavehmode \vfill foo bar \vfill. – Philipp Gesang Jan 23 '14 at 6:20
• That works! You can post your answer to get score. – s9gf4ult Jan 23 '14 at 11:11

When entering a page in normal typesetting mode, Context

1. is in vertical mode, and
2. will gobble all skips that follow immediately so as to align the top of the first line of the text body appropriately.

For this reason, inserting a vertical skip has no effect at the top of a page.

To work around this behavior you need to force TeX into horizontal mode, which you can do by

1. inserting horizontal material, for instance a strut, or
2. terminating vertical mode explicitly, which is usually done by means of the \dontleavehmode directive (the Context synonym for the \quitvmode primitive), or alternatively the lesser known \leavevmode [0].

The idiomatic solution would look like this:

\starttext
\dontleavehmode \vfill
foo
\vfill
\stoptext

Thus, if you intend to vertically center a page without using makeups, you could define an environment as follows (thanks to /u/Aditya for the suggestion):

\definestartstop [centeredpage] [
before=\dontleavehmode \vfill,
after=\vfill,
]

\starttext
\startcenteredpage
foo
\stopcenteredpage
\stoptext

On a related note, what you are asking for can actually be achieved conveniently by tweaking the options to \setupmakeup. The key settings are pagestate whose value is passed to an implicit \setuppagenumber, as well as headerstate and footerstate that govern the behavior of running heads and footers, respectively. To make headers and footers appear on the makeup, and to prevent the page numbering from ignoring that page, these options need to be set to start (they default to stop). For example:

\definemakeup [centeredpage]
\setupmakeup [centeredpage] [
pagestate=start,
top=\vfill,
bottom=\vfill,
footerstate=start,
page=yes,
]

\setupfootertexts [dummy footer] [{\getnumber [userpage]}]

\starttext
text on page before
\startcenteredpagemakeup
\input ward
\stopcenteredpagemakeup
text on page after
\stoptext

[0] For a discussion of \leavevmode vs. \dontleavehmode / \quitvmode see this post by Taco on the Pdftex list.

• It may be better to define a startstop environment for this rather than entering the raw commands in the text – Aditya Jan 24 '14 at 14:00
• @Aditya That’d amount to some makeshift version of makeups, wouldn’t it? – Philipp Gesang Jan 24 '14 at 18:08
• Yes. But my comment was motivated by the idea that all markup in a document should be semantic markup. The OP probably want a dedication page (or copyright page), so the markup should show that. – Aditya Jan 24 '14 at 19:27
• @Aditya I incorporated your suggestion into the answer, though it’s not really semantic because OP didn’t give the purpose of the centered content. – Philipp Gesang Jan 25 '14 at 20:08