[Tex/LaTex] How to center everything

horizontal alignment

Is there a way to center everything in a LaTeX document even the text?

Best Answer

Apart from centering normal text, you probably want to center also sectioning titles.

This can be done by loading the sectsty package and issuing

\allsectionsfont{\centering}

Also, for centering multi-line math, use the gather environment.

MWE:

\documentclass{book}
\usepackage{amsmath}
\usepackage{sectsty}
\allsectionsfont{\centering}
\usepackage{lipsum}
\begin{document}
\centering
\chapter{A chapter}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
\section{A section}
\lipsum[1]
\subsection{A subsection}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
\begin{gather*}
a+b=c\\
x^2+y^2=z^2
\end{gather*}
\end{document} 

Output:

enter image description here