Tuesday, August 5, 2008

A picture on the title page in LaTeX

In LaTeX, there is by default no way to put a picture on the title page or cover page that is produced by \maketitle. Surprisingly, no package seemed to exist for this either. Until now, because I wrote it.

The package titlepic.sty, which can be downloaded from CTAN, is very simple and easy to use. Install it by putting it in your texmf tree and rehashing, or simply drop titlepic.sty in the same directory as your .tex source document. It works with the default document classes article, report and book.

Include it as normal, with \usepackage{titlepic}. Then, along with the usual \title, \author and \date, put a command like the following:
\titlepic{\includegraphics[width=\textwidth]{cover.jpg}}
The argument to \titlepic will usually be an \includegraphics command, but it can actually be pretty much anything. The output produced by this argument will be typeset centered on the title page when you invoke \maketitle. (When you use the article document class, be sure to pass it the titlepage option, because articles do not have a title page by default.)

There are three optional arguments that control the vertical layout of the title page:

tt
Put both the title (and author, and date) and the picture at the top of the page, separated by a fixed amount of space.
tc
Put the title at the top of the page as with tt, but center the picture vertically on the page.
cc
Separate the title and the picture by a fixed amount of space, and center both together vertically on the page.

A full manual is also available. I hope this is of some use to someone. Enjoy!

32 comments:

itisthus said...

Thank you for creating this package, it has worked very nicely.

Just as a query, does the package provide any way of switching the print order of title and graphic, so that the graphic might be placed above the title text?

Good work.

-it

Thomas ten Cate said...

Sorry, the current version does not support that. But you could have a look at the code... it shouldn't be too difficult to hack it in yourself.

itisthus said...

I might give that a try.

Thanks again,

-it

Tommy Ohlsson said...

Hi,

Thanks! It worked perfectly for me.

Greetings,
Tommy

holgerl said...

Thanks! It worked great.

You can put the picture above the text by swapping the code

{\centering\@titlepic\par}
with
\begin{center}%
[...]
\end{center}\par

and leaving
\@tpsepspace%
in the middle of them

Jonas said...

Worked perfectly on the first try, not often that happens. Thanks a lot.

/Jonas

Anonymous said...

thanks for this work.

Zachary Sarver said...

You just saved my paper. I owe you one. Great package, man!

Kate said...

Hi I think i must be doing something wrong because nothing is happening with my picture, i am gettin no errors but it seems to be just ignoring it, this is the code i used above title author and \maketitle

\titlepic{
\begin{figure}[h]
\centering
\includegraphics[2cm,-1cm][5cm,5cm]{ucc.pdf}
\end{figure}
}

Gerrit Holl said...

Kate, I think it doesn't work as a float. Include only the \includegraphics command.

M. Hampton said...

Thanks! I'm surprised this isn't addressed by maketitle somehow.

Anonymous said...

Thanks for creating this package! It is very useful, it makes the article much nicer. Nice work!

Anonymous said...

Hello!
Im having some trouble!

I want to include the figure fleravalspar.eps but when creating the pdf file the figure is not there.

Whats wrong?

Thank you !
My code is:

\documentclass{article}
\usepackage{geometry}
\usepackage{titlepic}
\usepackage{graphicx}
\geometry{letterpaper,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm}

\usepackage[layout=modern]{advancedcoverpage}

\title{my title}
\author{\emph{By}\\John Doe}

\titlepic{\includegraphics[width=\textwidth]{fleravalspar}}

\organization{\textsc{KTH}}
\date{June 2009}
\location{Stockholm}
\begin{document}
\maketitle
\end{document}

Thomas ten Cate said...

If you include an EPS file, you have to use latex (not pdflatex), then use dvips to convert the resulting DVI file to a PS file.

A possibly easier route is to convert the EPS file to a PDF file, for example using epstopdf. Then include the PDF file into your LaTeX document, and you can use pdflatex as normal.

Anonymous said...

It didn´t work when I was using a jpg file either..

I have always used .eps files with Latex. It always works..

Thomas ten Cate said...

How do you compile your file, exactly?

Does (pdf)latex spit out any messages?

Anonymous said...

I just use "quick build" in my texmaker.

Anonymous said...

and no, it doesn´t spit out any error message or warnings.

Thomas ten Cate said...

Oh! I now see what's wrong with your code!

As noted in my original post: "When you use the article document class, be sure to pass it the titlepage option, because articles do not have a title page by default."

So this should help:
\documentclass[titlepage]{article}

Thomas ten Cate said...

And, next time, I will drink my coffee before I answer. I now also see that you use the advancedcoverpage package. Unfortunately, this is not compatible with titlepic; you'll have to choose one or the other.

Adrian McC said...

Hi Thomas

I'm sorry to trouble you but I'm brand new to LaTeX and trying to use your package.

I have the following code, but I keep getting "!Undefined control sequence"

I wondered if you can please help?

Have I left out a heap of important stuff??

Many thanks

Adrian.

\documentclass[a4paper]{report}

\usepackage[cc]{titlepic} % Include the titlepic package.

\title{Report Title}
\author{Adrian McCallum}
\date{June 2009}

\titlepic{\includegraphics{greenland}}

\begin{document}

\maketitle

Thomas ten Cate said...

Like you figured out yourself, posted here for the record: you're missing \usepackage{graphicx}.

Adrian McC said...

Thanks Thomas, much appreciated.
Cheers,
Adrian.

Jan said...

Thomas, you're a hero!

Anonymous said...

Having problems downloading the package

Thomas ten Cate said...

I know... the plug has been pulled on the server that was hosting it. I will see if I can host the package on CTAN instead.

Thomas ten Cate said...

The package has been submitted to CTAN. I'll update this post as soon as the maintainers put it online.

Queru said...

Hi. The package its available at:

http://www.tex.ac.uk/tex-archive/help/Catalogue/entries/titlepic.html

Thanks for the great work!

Queru said...

It don't works for me... no error or warning, but the image not appears.

When I use only "\includegraphics[width=350px]{./logo.jpg}" it works fine.

Any idea? Thanks.

Thomas ten Cate said...

Do you happen to be using the article class without the titlepage option?

Queru said...

Yeah! That's the problem. Thanks!

sandeep p said...

nice....very useful and time saving....thanks a lot to the author..