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.

70 comments:

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

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

    ReplyDelete
  3. I might give that a try.

    Thanks again,

    -it

    ReplyDelete
  4. Hi,

    Thanks! It worked perfectly for me.

    Greetings,
    Tommy

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

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

    /Jonas

    ReplyDelete
  7. thanks for this work.

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

    ReplyDelete
  9. 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}
    }

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

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

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

    ReplyDelete
  13. 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}

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

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

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

    ReplyDelete
  16. How do you compile your file, exactly?

    Does (pdf)latex spit out any messages?

    ReplyDelete
  17. I just use "quick build" in my texmaker.

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

    ReplyDelete
  19. 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}

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

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

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

    ReplyDelete
  23. Thanks Thomas, much appreciated.
    Cheers,
    Adrian.

    ReplyDelete
  24. Having problems downloading the package

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

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

    ReplyDelete
  27. Hi. The package its available at:

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

    Thanks for the great work!

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

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

    ReplyDelete
  30. Yeah! That's the problem. Thanks!

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

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

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

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

    ReplyDelete
  35. 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!

    Thanks for this download by the way!

    ReplyDelete
  36. 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!

    Thanks for this download by the way!

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

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

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

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

    ReplyDelete
  41. 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. :)

    ReplyDelete
  42. 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!

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

    ReplyDelete
  44. This comment has been removed by a blog administrator.

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

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

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

    Thanks in advance

    ReplyDelete
  48. @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.

    ReplyDelete
  49. 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!

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

    Best,
    Jørgen (Norway)

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

    ReplyDelete
  52. 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?

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

    ReplyDelete
  54. 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)...

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

    ReplyDelete
  56. 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}
    %\titlehead{titlehead}
    %\dedication{dedication}

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


    \begin{document}

    \maketitle

    doc

    \end{document}

    ReplyDelete
  57. @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! :)

    ReplyDelete
  58. 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{Subsection Heading Here}
    Subsection text here.


    \subsubsection{Subsubsection Heading 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}

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

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

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

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

    ReplyDelete
  63. Thanks for the package!

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

    ReplyDelete
  65. Hi, could not make it work - I downloaded the .sty file and put it in the directory, see my code:

    \documentclass[a4paper,10pt]{report}

    \usepackage[cc]{titlepic}
    \usepackage{graphicx}


    \usepackage[USenglish]{babel}

    %\usepackage[ansinew]{inputenc}

    \usepackage[T1]{fontenc}
    \usepackage{charter}
    \usepackage[expert]{mathdesign}




    \usepackage{amsmath}
    \usepackage{amsthm}
    \usepackage{amsfonts}


    \title{Kac-Moody Algebras and Supergravity}
    \author{John Walker}
    \date{}
    \titlepic{\includegraphics{sugra.gif}}

    \begin{document}

    \maketitle

    \end{document}

    Any ideas people?

    ReplyDelete
  66. Hi Thomas, thank you so much for creating this package. I managed to place the picture on top of the title page following Holgerl's suggestions (thank you for that), but I still have troubles in placing \publishers and \lowertitleback after the date. I have tried to modify the code but it doesn't work. Can anyone help me? Cheers, Jacopo

    ReplyDelete
  67. Any suggestion to include more than one picture?

    ReplyDelete
  68. Any suggestion to include more than 1 picture at the title?

    ReplyDelete
  69. Sure, you can put more than one \includegraphics command in there, or indeed anything else you like!

    ReplyDelete