2

I am trying to create a cover page containing an image and the title of the report, but the image and the title appear on different pages. How can I solve this problem?

\documentclass[30pt]{report}
\usepackage[a4paper,top=3cm,bottom=3cm,left=3cm,right=3cm]{geometry}
\usepackage{graphicx}
\begin{document}
  \begin{figure}[h] 
    \centering \includegraphics[width=5cm]{najah.png} 
  \end{figure} 
  \title{ATLAS Detector} 
  \author{Fatima Shahrouj\\ Departement of physics, An-Najah National University NNU, Nablus, Palestine.} 
  \maketitle
\end{document}
4
  • 2
    Share your code, please? – Andreas Storvik Strauman Mar 24 '18 at 18:57
  • \documentclass[30pt]{report} \usepackage[a4paper,top=3cm,bottom=3cm,left=3cm,right=3cm]{geometry} \usepackage{graphicx} \begin{document} \begin{figure}[h] \centering \includegraphics[width=5cm]{najah.png} \end{figure} \title{ATLAS Detector} \author{Fatima Shahrouj\\ Departement of physics, An-Najah National University NNU, Nablus, Palestine.} \maketitle – Fatima SH Mar 24 '18 at 19:01
  • 1
    Please add the code to your question? – Andreas Storvik Strauman Mar 24 '18 at 19:12
  • 4
    Hi, welcome. Note one thing: It is not mandatory to use a figure environment to insert images, \includegraphics works perfectly fine outside it as well (as demonstrated in Andreas' answer). figure is a floating container, its purpose is to let LaTeX move images and their captions, in order to avoid bad page breaks. – Torbjørn T. Mar 24 '18 at 19:16
2

So \maketitle prints what you provided as \title and \author (amongst a few other things), but you're adding a figure before that. To add a figure to the \maketitle, as suggested here, you can use the titling package. It provides \pretitle to do stuff before the title and \posttitle for after. The \pretitle is already defined containing a \begin{center} so then, to get an image below the title we use \posttitle{\includegrapics[...]{...}\end{center}}. Your code will then become

\documentclass[30pt]{report}
\usepackage[a4paper,top=3cm,bottom=3cm,left=3cm,right=3cm]{geometry}
\usepackage{graphicx}
\usepackage{titling}

\begin{document}
  \posttitle{
  \\[\bigskipamount]\includegraphics[width=5cm]{najah.png}
  \end{center}
  }
  \title{ATLAS Detector}
  \author{Fatima Shahrouj\newline Departement of physics, An-Najah National University NNU, Nablus, Palestine.}
\maketitle

\end{document}
8
  • yes, that works, thank you. But there is a problem with the position of the image and the writing!! – Fatima SH Mar 25 '18 at 11:28
  • Fixed it. Just inserted it into a figure and centered it. – Andreas Storvik Strauman Mar 25 '18 at 11:31
  • Never use a figure environment in a title! – Johannes_B Mar 25 '18 at 11:32
  • Oh. I didn't know this. Sorry. Fixing it. But why though? – Andreas Storvik Strauman Mar 25 '18 at 11:34
  • 1
    A figure environment is supposed to be moved around by LaTeX, which isn't wanted on a title page. You want the picture where you want it and nowhere else. en.wikibooks.org/wiki/LaTeX/Title_Creation – Johannes_B Mar 25 '18 at 11:43

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