Time for action – centering a title
We shall create a nice looking title for our document. It should contain the title, the author, and the date. All those lines have to be centered.
Write a document containing this code:
\documentclass{article} \pagestyle{empty} \begin{document} {\centering \huge\bfseries Centered text \\ \Large\normalfont written by me \\ \normalsize\today } \end{document}
Typeset to see the output:
What just happened?
Because only the title should be centered, we opened a group to limit the centering. Through the declaration \centering
, we made the remaining text of this group horizontally aligned to the center. We inserted a paragraph break: it's always a good idea to do it before ending the group when paragraph-affecting commands were used. By the brace after \today
, we ended the group. If you complement some following text, it will be typeset normally, not centered.
\centering
is commonly used when pictures or tables are inserted, further on title pages and...