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!

Note: titlepic only works with the “standard” document classes article, report and book!. You may have some luck with other classes such as AMS, but no promises.

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}

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

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"

Have I left out a heap of important stuff??

Many thanks

\documentclass[a4paper]{report}

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

\title{Report Title}
\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}.

Thanks Thomas, much appreciated.
Cheers,

Jan said...

Thomas, you're a hero!

Anonymous said...

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

Anonymous said...

Doesn't seems to work for me. Here is my trail.tex

\documentclass[a4paper,10pt]{book}
\usepackage[tc]{titlepic}
\usepackage{graphicx}
\usepackage{titlepage}

\begin{document}
\author{Rav}
\title{ABCD}
\date{\today }
\titlepic{\includegraphics[width=0.7\textwidth]{uni-logo2.jpg}}
\maketitle
\end{document}

I do get a single page i.e. the title page, but with no picture. I tried everything on the blog, but it seems I must check the titlepage.sty, which I borrowed from someone, but what shall I check for?

Any hints or clues will help.
thanks
Raveesh

Anonymous said...

okay I found my mistake, i MUST ask the titlepage.sty to show this pic. Sorry fellows, as they say "half knowledge is dangerous". I learnt about titlpic.sty, but didn't bother to learn titlepage.sty

thanks nevertheless...
Raveesh

Zolley said...

At last, something that worked immediately, without haveing to do some hacking. Thanks!

jm2010 said...

Hi, in holgerl's comment (near the top), I've swapped the code but how do i save the .sty file - it wont let me!

jm2010 said...

Hi, in holgerl's comment (near the top), I've swapped the code but how do i save the .sty file - it wont let me!

jm2010 said...

Solved it - just saved it under a modified name. Thanks again clever LaTeX people!

Aaron said...

How about having the author and date below the image? So from the top down you would have; title, image, author, date.

Aaron said...

I got it, I just modified the .sty file. It is a permanent change, but it would be cool if it was worked in as an option. Thanks for the nice package.

Neil Harvey said...

Just used this package to dress up a report. Thanks for developing it!

Anupama said...

Just what I was looking for.
Works perfectly well, in the first attempt! Thanks a ton, Thomas.

And Holgerl, Thanks for simple swap to change the order. :)

Anonymous said...

Quite a nice package. Is there any way to get a figure to take over the entire page (i.e., not just the scaled area of \textwidth, but the entire 8.5 x 11 inches if you're working on US letter-sized paper)?

Many thanks!

Thomas ten Cate said...

This is not currently supported. But you give the package "textpos" a try. Maybe you can even simply replace the \includegraphics command by a textblock environment from that package.

kimberly said...
This comment has been removed by a blog administrator.
Anonymous said...

Hi, thanks so much for writing this!! It was useful for my report!!!

Anonymous said...

My thanks to the author, I'm little better than a novice, and the package worked like a champ on the first try. Thank you!!

Dave, South Carolina

Anonymous said...

Please, would you show how to put this logo in the upper right corner along with a left corner some words.

Thomas ten Cate said...

@Anonymous: Have a look at the package "textpos": http://purl.org/nxg/dist/textpos It allows you to put text and graphics at an absolute position on the page.

Anonymous said...

This worked for me, and I didn't need to download or install anything.

\documentclass[11pt,oneside]{amsart}

......

\title{Title}

\author{author name}
\date{\today}
\begin{document}
\maketitle
\vspace{10 mm}

\begin{figure}[H]
\centering
\includegraphics[scale=0.8]{picture}
\end{figure}
\newpage

Put the picture right on the titlepage underneath the title!

Cheers, is there a hack to put the picture under the \title{} but over the \author{}?

Best,
Jørgen (Norway)

Thomas ten Cate said...

Not currently, but you can easily modify the package to do that. It's quite simple.

Yeah, I saw Holgers' comment above:

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

I'm using TexShop on a mac, and I cant find the titlepic.sty file. I've Googled it, but no help there. Anyone?

Thomas ten Cate said...

Well, that depends on where you put it when you first downloaded it, according to my instructions above :)

Yep, I read your post. Unfortunately titlepic.sty came preinstalled with my TeXshop for mac. I've been searching my computer libraries but can't seem to find the .sty file(s)...

Jorge said...

It kills all title formatting done by scrreprt, from the KOMA class.

Jorge said...

For the record, I needed a picture in the title page, below title and author, and my code ended up looking like this (using KOMA script):

\documentclass[paper=a4, fontsize=12pt, spanish]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage{float}

\title{title}
\author{me}
\date{\today}
%\subject{subject}
%\dedication{dedication}

\publishers{
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{fig/figure.jpg}
\end{figure}
}

\begin{document}

\maketitle

doc

\end{document}

Thomas ten Cate said...

@Jorge: It was never intended to work with anything but the standard classes article, report and book. But it seems that with KOMA you don't need it, so that's fine! :)

Mayank said...

I was using your package with IEEE layout but its not working can you help ?

\documentclass[conference]{IEEEtran}
\usepackage[top=2.5cm, bottom=2.5cm, left=2.5cm, right=2.5cm]{geometry}
\usepackage{graphicx}
\usepackage{titlepic}
\ifCLASSINFOpdf
\else
\fi
\hyphenation{op-tical net-works semi-conduc-tor}
\begin{document}

\title{EVENT LOGGER}
%\begin{figure}
%\titlepic
%{\includegraphics[width=5cm,height=0.5cm]{m.png}}
\titlepic{
\begin{figure}[h]
\centering
\includegraphics[2cm,-1cm][5cm,5cm]{m.png}
\end{figure}
}
%\end{figure}
\author{\IEEEauthorblockN{Mayank Gupta}
\and
\IEEEauthorblockN{Sandeep Aggarwal}
}
\maketitle
\pagebreak
\newpage
\begin{abstract}
fffff
\end{abstract}
\IEEEpeerreviewmaketitle
\section{Introduction}
fgnngfjnfg
Subsection text here.

Subsubsection text here.

\section{Conclusion}
The conclusion goes here.
\section*{Acknowledgment}
The authors would like to thank...
\begin{thebibliography}{1}

\bibitem{IEEEhowto:kopka}
\end{thebibliography}
\end{document}

Thomas ten Cate said...

Sorry, it doesn't support that document class -- but it might work anyway. You need to get rid of the \begin{figure} and \end{figure}, and the \centering. See the titlepic manual for examples.

Anonymous said...

This nicely rounded of my project. Brilliant package,
Cheers!

Anonymous said...

I want put title OVER image, superimposted, for design purposes....

Anonymous said...

Thanks a lot, it worked perfectly.

If you want to put your picture BETWEEN the title and the author, simple cut :

\@tpsepspace%
{\centering\@titlepic\par}
\vfil

and paste right after :

\begin{center}%
{\LARGE \@title \par}%
\vskip 3em%

Amine

Anonymous said...

Thanks for the package!

kaberett said...

Exactly what I was after, & in other respects beautiful and perfect. Thank you. :-)