Page LayoutSection Heading vertically centered on its own Page

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
eelkefolmer
Posts: 1
Joined: Sat Oct 01, 2011 1:05 am

Section Heading vertically centered on its own Page

Post by eelkefolmer »

I'm trying to vertically center headers on their own page using the following code.

Code: Select all

\titleformat{\section}[display]
{\Huge \bfseries}
{}
{0.4\textheight}
{\thesection.}
This does the trick. Just found it by randomly trying. I wish someone would write some better documentation for titlesec.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Section Heading vertically centered on its own Page

Post by localghost »

eelkefolmer wrote:[…] I wish someone would write some better documentation for titlesec.
You just need to learn how to read manuals. Your code does not exactly do what you plan. The heading is neither properly centered nor on its own page.

Code: Select all

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{titlesec}

\titleformat{\section}
{\clearpage\null\vfil\bfseries\Huge}
{\filright\thesection}
{1em}
{\filright\Huge}
[\vfil\newpage]

\begin{document}
  \section{Foo}
    The quick brown for jumps over the lazy dog.

  \section{Bar}
    The quick brown for jumps over the lazy dog.
\end{document}
And by the way, full examples are more helpful than some code snippets to comprehend a problem.


Best regards and welcome to the board
Thorsten
Post Reply