# vertically center all slides in ConTeXt with minimal setups

I would like to emulate beamer's centred framed behaviour in my ConTeXt presentation. Thanks to this post, I figured out how to have my (sub)section titles centred. I am also using a makeup for my main title. My main text wasn't vertically centred however. Today, I realized I could use a custom framed environment.

Here is how I get my vertically centred presentations now (all the setups are in an environment, I past the relevant item in the MWE for convenience):

``````\setuppapersize[S5]
\setupbodyfont[18pt]
\setuplayout[topspace=1cm,backspace=1.5cm,
width=14.5cm,height=11cm,%margin=0cm,
\definelayout[titre][topspace=0cm,backspace=1.5cm,
width=15cm,height=11cm,
\definemakeup[titre]
alternative=middle,%titre centré sur la ligne
before={\leavevmode \vfill},after={\vfill \page},
style=\tfd]
before={\page\leavevmode \vfill},after={\vfill},
style=\tfc,conversion=I,
numbercommand=\groupedcommand{}{~)},%) après le numéro
align={flushleft, nothyphenated, verytolerant}]
\defineframedtext
[Diapo]
[frame=no,
before={\page\leavevmode\vfill},after={\vfill}]

\starttext
\startmakeup[titre]
\starttitle[title={Un test}]
\stopmakeup

\startsection[title={Bonjour}]
\startDiapo
Hello world!
\stopDiapo
\stopsection
\stoptitle
\stoptext
``````

Here is my question : how can I minimize those setups? Especially:

• is there any way to get my texts centred without framing them (`\start/stopDiapo`)?
• I couldn't find any global command that gives a vertically centred layout. Is there a way to do it?

# Makeup environment

The best method to center the content of each frame is the use of a `makeup` environment. With the `top` and `bottom` you can control the vertical alignment of the text and with the `align` key you can change the horizontal alignment.

``````\setuppapersize [S3] [S3,doublewide]

\showframe [page]

\setuparranging [2SIDE]

\starttext

First page

Second page
\stopstandardmakeup

\stoptext
``````

When you use the environment form of section header get additional keys to insert commands before and after the content of each section.

When you have a header without content (e.g. for the title page) you can use the regular form and pass the title as argument to the command.

``````\setuppapersize [S3] [S3,doublewide]

\showframe [page]

\setuparranging [2SIDE]

\define[1]\ShowKey
{\par
\leftaligned{\tttf [key: #1]}%
\par}

[subject]
[       before=\ShowKey{before},
after=\ShowKey{after},
beforesection=\ShowKey{beforesection},
insidesection=\ShowKey{insidesection},
aftersection=\ShowKey{aftersection}]

\starttext

\subject {First subject}

\page

\startsubject [title={Second subject}]
Subject content
\stopsubject

\stoptext
``````

# Combination of both mechanism

You can combine the `makeup` environment with the environment form of section headers and use the `insidesection` and `aftersection` keys to center the content of each section.

``````\setuppapersize [S3]

\definemakeup
[section]
[pagestate=start,
align=middle]

\definemakeup
[frame]
[pagestate=start,
align=middle]

[frametitle]
[align=middle,
before=\startsectionmakeup,
after=\stopsectionmakeup]

[framesection]
[align=middle,
before=\startsectionmakeup,
after=\stopsectionmakeup,
insidesection=\startframemakeup,
aftersection=\stopframemakeup]

\starttext

\frametitle{Un test}

\startframesection[title={Bonjour}]
Hello world!
\stopframesection

\stoptext
``````

• Could you edit your example to have "Hello world" vertically centered and justified? Thanks. – sztruks Nov 5 '18 at 6:47
• I suggested an edit for your post that makes it closer to my MWE. Anyway, could you tell me what the key `pagestate` stands for? Wiki does not explain it AFAIK. – sztruks Nov 5 '18 at 17:31
• @sztruks As I wrote you can use the `align` key to change the horizontal alignment, by default you get justified text. With the `pagestate` key you can control whether `makeup` pages are included or excluded (which is the default setting) from the page counter. – Wolfgang Schuster Nov 5 '18 at 17:35
• OK, I misunderstood what you wrote about `align`. One last question: I understand makeups are one page-only output. Am I right? `\pages` are ignored within them, which seems consistent to the wiki makeup definition. – sztruks Nov 5 '18 at 17:41
• Yes, the `makeup` environment creates a unbreakable block which is placed on a separate page. You can use the environment for standalone pages like a title page. – Wolfgang Schuster Nov 5 '18 at 17:52