# When I include url on a line, it shows up left-justified instead of centered

If I use the url package and include a url on a line inside the centering environment, it shows up left-justified instead of centered. How can I make it centered?

MWE:

\documentclass{article}
\usepackage{url}
\pagestyle{empty} % no page numbers

\begin{document}
\begin{centering}
\par My Name
\par My Department
\par My Department But With More Words
\par My phone number and e-mail address
\par Website: \url{http://my.web.site/}
\end{centering}

\end{document}

-

The setting of a paragraph is done when encountering a \par (or empty line). Adding \par to the last line provides the appropriate horizontal alignment:

\documentclass{article}
\usepackage{url}% http://ctan.org/pkg/url
\pagestyle{empty} % no page numbers

\begin{document}
\begin{centering}
My Name \par
My Department \par
My Department But With More Words \par
My phone number and e-mail address \par
Website: \url{http://my.web.site/}\par
\end{centering}

\end{document}​


As such, your initial \par has no effect. Of course, there are other ways of obtaining this output as well:

\begin{center}
My Name \\
My Department \\
My Department But With More Words \\

\centering is not designed to be used as an environment. As @Werner noted it does not center the last paragraph if used without an explicit paragraph end. Use center instead of centering. The problem is unrelated to \url you would see the same effect with plain text.