5

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

Werner
  • 603,163

2 Answers2

6

You can put a \centering command right after the beginning of the document.

\documentclass{article}
\usepackage{lipsum}
\begin{document}
    \centering
    \lipsum
\end{document}

enter image description here

Franck Pastor
  • 18,756
  • \lipsum{1}? Did you mean \lipsum[1]? – karlkoeller Mar 26 '15 at 19:48
  • \centering centers each: \begin{align}\end{align} but inside of align* how do you center? – user1531503 Mar 26 '15 at 19:59
  • @karlkoeller Yes, my bad, but now I see it is better without argument, optional or not :-) – Franck Pastor Mar 26 '15 at 20:06
  • 2
    @user1531503 -- if you want to center each line of a multi-line math display, don't use align*, use gather*. i haven't time to research the details of how the amsmath structures interact with \centering, but gather all by itself centers each line of its content, so shouldn't cause a problem. – barbara beeton Mar 26 '15 at 20:07
  • Crosspost http://latex-community.org/forum/viewtopic.php?f=44&t=26055&p=89285#p89285 – Johannes_B Apr 01 '15 at 13:55
6

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

karlkoeller
  • 124,410