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

1 Answers1

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}