# centering does not center text

I am trying to simply center the text in latex in simple article.

The following code does not center the text - the full width can be seen on print screen and is higlighted

\documentclass[11pt]{article}
\begin{document}
\begin{center}
\Huge
Surname1
\newline
Name1
\newline
\normalsize
Institution
\end{center}

\centering
\Huge
Surname1
\newline
Name1
\newline
\normalsize
Institution

\end{document}


This is so simple that there can't be a place for a mistake.

What am I missing?

• you probably want \documentclass[a4paper][article} if you have specified A4 as your default paper size when installing texlive – David Carlisle Oct 6 '16 at 21:36
• What if I would like to specify a6paper? – Marcin Kosiński Oct 6 '16 at 21:37
• easiest is to use geometry package to specify page size – David Carlisle Oct 6 '16 at 21:44
• I had a code with geometry package included with the same issue : P – Marcin Kosiński Oct 7 '16 at 10:16

You need to use \\ in the scope of center

\documentclass[a4paper,11pt]{article}
\begin{document}
\begin{center}
\Huge
Surname1
\\
Name1
\\
\normalsize
Institution
\end{center}

\centering
\Huge
Surname1
\\
Name1
\\
\normalsize
Institution

X\dotfill X
\end{document}


\newline is designed to leave lines short in justified text so it adds glue to one side of the line, that throws the text off centre. Normally you do not need either, just leave a blank line in the source., note also that \normalsize does not start a new paragraph which was why the text was touching as you were setting Huge text on a normal baseline

• Wow, that works. But why? – Marcin Kosiński Oct 6 '16 at 21:39
• @MarcinKosiński \newline is designed to leave lines short in justified text so it adds glue to one side of the line, that throws the text off centre. Normally you do not need either, just leave a blank line in the source., note also that \normalsize does not start a new paragraph which was why the text was touching as you were setting Huge text on a normal baseline – David Carlisle Oct 6 '16 at 21:42
• shouldn't the \\  come immediately after the text on that line? or is it defined beginning with \unskip? (spaces are ignored at the beginning of a line, but not at the end.) – barbara beeton Oct 7 '16 at 1:09
• @barbarabeeton usually it's better but actually in center it makes no difference as \ is more or less just \par really in this context:-) – David Carlisle Oct 7 '16 at 6:38

\centering redefines \\, but not \newline. Thus, \newline uses the setup for left aligned text (an additional \hfil on the right side of the previous line, ...). Using \\ solves the problem:

\documentclass[11pt]{article}
\usepackage[pass,showframe]{geometry}
\begin{document}
\begin{center}
\Huge
Surname1
\\
Name1
\\
\normalsize
Institution
\end{center}

\centering
\Huge
Surname1
\\
Name1
\\
\normalsize
Institution

\end{document}