# Proper Horizontal and Vertical Centering (for Sections)

I have the following problem: I attempted to center it both vertically and horizontally, however the second line, as you can see, is not centered. For clarity, here is how I'd expect it to look (taken from Word): I am aware that it is a different font, but that doesn't matter.

Any help to make the first Section Heading look like the second would be greatly appreciated!

To center it, I used the code from this answer

Here is the code (it is probably terrible, I just started using Latex):

\documentclass{article}
\usepackage{titlesec}
\usepackage{lmodern}

\titleformat{\section}{\fontfamily{lmr}\selectfont\fontsize{72pt}{86.4pt}\bfseries}{\thesection}{1em}{}

\begin{document}

\clearpage
\vspace*{\fill}
\begin{center}
\begin{minipage}{\textwidth}
\centering
\section*{Example Section}
\end{minipage}
\end{center}
\vfill
\clearpage
\end{document}

• a section heading formatting needs to be part of the heading definition, if you mean by your link you put \section inside begin{center} that's wrong, but as you have shown no code it is hard to guess – David Carlisle Mar 5 '18 at 21:41
• Can you please make a minimal working example (MWE)? – user36296 Mar 5 '18 at 21:45
• @DavidCarlisle yes, you are completely right! Sorry for forgetting about it – Crowley Astray Mar 5 '18 at 21:45
• your example can still not be used to make the image you show, we do not know the text width (which seems to be very narrow based on your image) or the definition of \section, – David Carlisle Mar 5 '18 at 22:03
• do you have no text in the section? centering the heading is very common but vertically centering it is rather odd (and consequently not as directly supported by standard definitions for section headings) – David Carlisle Mar 5 '18 at 22:05

All the formatting should be in the definition of \section not in the document.

\documentclass{article}
\usepackage{titlesec}
\usepackage{lmodern}

\newcommand\zzz[1]{%
\clearpage
\vspace*{\fill}
{\centering\fontfamily{lmr}\selectfont\fontsize{72pt}{86.4pt}\bfseries#1\par}
\vspace*{\fill}
\clearpage}

\titleformat{\section}{\zzz}{\thesection}{1em}{}

\begin{document}

\section*{Example Section}

zzz
\end{document}