Download Untitled

Transcript
Chapter 2
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.
1.
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}
2.
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 sometimes for headings.
Using environments for justification
As there's a corresponding environment for every declaration, as we learned, we could
have written \begin{centering} … \end{centering} in our previous example. It
could be done similarly for ragged-right and ragged-left text. There's a couple of predefined
environments acting similarly but starting a new paragraph at the same time.
[ 63 ]