[Tex/LaTex] centering does not center text

horizontal alignment

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.

enter image description here

What am I missing?

Best Answer

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} 

enter image description here

\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