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:
    Time for action – centering a title

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 ...

Get LaTeX Beginners Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.