如果我使用该url
包并在环境内的一行中包含一个 URL centering
,它会显示为左对齐而不是居中。我该如何让它居中?
梅威瑟:
\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 department's Address
\par My phone number and e-mail address
\par Website: \url{http://my.web.site/}
\end{centering}
\end{document}
答案1
段落的设置是在遇到\par
(或空行)时完成的。添加\par
到最后一行可提供适当的水平对齐:
\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 department's Address \par
My phone number and e-mail address \par
Website: \url{http://my.web.site/}\par
\end{centering}
\end{document}
因此,你的初始值\par
没有效果。当然,还有其他方法可以获得此输出:
\begin{center}
My Name \\
My Department \\
My Department But With More Words \\
My department's Address \\
My phone number and e-mail address \\
Website: \url{http://my.web.site/}
\end{center}
答案2
\centering
并非设计为用作环境。正如@Werner 指出的那样,如果使用时没有明确的段落结尾,它不会将最后一段居中。请使用center
而不是。该问题与您在纯文本中看到相同效果centering
无关。\url