2

I just want to add my class and professor information to title. I don't want to use a page break.

I want title like this and right aligned:

Anthony Sample

Intro to Expos

Prof. Selinsky

Summary: Draft

How to achieve this? Any help is appreciated.

\documentclass[12pt]{article}
\begin{document}

\title{}
\author{}
\date{}

\end{document}
2
  • Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – Tobi
    Feb 12 '13 at 20:13
  • 3
    You could just add the information as part of \title in the following way: \title{\begin{tabular}{@{}r@{}} Anthony Sample \\ Intro to Expos \\ Prof.\ Selinsky \\ Summary: Draft \end{tabular}} and then \maketitle would print it as the "title." But this looks weird. Could you supply an image of the intended output?
    – Werner
    Feb 12 '13 at 20:24
5

Does this do what you want?

\documentclass[12pt]{article}
\title{\hfill Anthony Sample\\
\ \\
\hfill Intro to Expos\\
\ \\
\hfill Prof. Selinsky\\
\ \\
\hfill Summary: Draft}
\date{\hfill\today}
\begin{document}
\maketitle
\end{document}

The key ideas are:

  • You can put just about anything you want in \title{}.
  • Line breaks can be added with \\ (as in Werner's suggestion).
  • You need to put something on a line in order to add \\, so I use \ to add a hard space before \\ when I want to create a blank line.
  • \hfill tries to fill up as much space as possible. By putting it before the text on a line, it pushes the text all the way to the right.

The same points apply to \date{}, but \author{} seems to be less flexible.

2
  • 1
    Two or more consecutive linebreak `\\` should be avoided because TeX is not a typewriter. :-) Feb 13 '13 at 3:59
  • 1
    Yes, that's an ideal, and it's good. Fortunately, LaTeX is not designed to prevent compromises. (As for myself, I am a not a typesetter, but a(n academic) writer. I want to get the job done, and am willing to use kludges to do so, but I'm happy to learn more elegant methods when they are available (and are actually more elegant!).)
    – Mars
    Feb 14 '13 at 5:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.