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
    Commented Feb 12, 2013 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
    Commented Feb 12, 2013 at 20:24

1 Answer 1

4

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. :-) Commented Feb 13, 2013 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
    Commented Feb 14, 2013 at 5:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .