As per this answer, \par
should properly end the effect of \centering
. But in the following case, it doesn't. Why?
\documentclass{article}
\makeatletter
\newcommand\@mytitle{} % create macro for title
\newcommand\mytitle[1]{\renewcommand\@mytitle{#1}}
\newcommand\@myauthor{} % create macro for author
\newcommand\myauthor[1]{\renewcommand\@myauthor{#1}}
\newcommand{\articletitle}{%
\centering%
\fontsize{18bp}{18bp}\selectfont%
\@mytitle\par%
\vspace{\baselineskip}%
\fontsize{14bp}{14bp}\selectfont%
\@myauthor\par%
\fontsize{12bp}{12bp}\selectfont%
\vspace{2\baselineskip}\par}%
\makeatother
\mytitle{This is my title}
\myauthor{This is the author}
\AtBeginDocument{\articletitle}
\begin{document}
I start writing here
\end{document}
Best Answer
\par
does not end the effect of\centering
, the end of the paragraph is just the place, where TeX uses the values set by\centering
. A group can be used to limit the effect of\centering
. After the group, the settings before the group are in force again.or
{\centering ...\par}
.