12

I want to add a logo picture on the title page. However, it appears that I could not make it before the title. Is it possible to do so, please? If so, how and how to make it centered and above the title?

\documentclass[a4paper, 11pt, oneside]{book}

\usepackage{graphicx}

\includegraphics[]{logo}
%opening
\title{abc}
\author{abc}

\begin{document}
\end{document}
14

The issue here is, that you try to add a picture befor the \begin{document}. Your commands only set the content of \title but don't typeset it. You might use the following:

\documentclass[a4paper, 11pt, oneside]{book}

\usepackage{graphicx}

%opening
\title{abc}
\author{abc}

\begin{document}
\vbox{
    \centering
    \includegraphics[width=0.2\textwidth]{example-image}
    \maketitle %this typesets the contents of \title, \author and \date
}
\clearpage
\end{document}

Please note that I put the \maketitle and the \includegraphics in a \vbox{} to prevent it from pagebreaking in between the picture and the title.

EDIT: I've adapted the code to not use \maketitle in a titlepage-environment.

  • I don't think you are supposed to use \maketitle inside titlepage. – cfr Mar 13 '17 at 0:09
  • Note that something here is not centred. You can see that the date is not centred relative to the image, for example, although the title and author probably are. – cfr Mar 13 '17 at 0:11
  • @cfr looks very centered to me. Also the code doesn't have to be in a titlepage-environment. I didn't know that you don't put \maketitle in such an environment (heard it for the first time today). What's the reason to not do it? – Skillmon Mar 13 '17 at 7:03
  • @Skillmon I vote your answer, certainly. – Sebastiano Mar 13 '17 at 8:08
  • @cfr encountered something funny: When you use really long author names the name isn't centered indeed (well it is centered but there is no linebreaking resulting in an overflowing hbox and therefor doesn't look centered). But this also happens if you just use \maketitle without my \vbox and \includegraphics and it happens with both the standard book class and scrbook. – Skillmon Mar 13 '17 at 8:12
8

The titlepage environment is not meant for use with \maketitle. However, the titling package offers a half-way house which allows you to use \maketitle within the titlepage environment, along with any other commands you wish.

At least, so it says on the tin. In reality, you can't put other things before \maketitle.

However, the package also gives us a series of hooks and we can use one of those to include the image. For example,

  \renewcommand\maketitlehooka{%
    \begin{center}
      \fbox{\includegraphics[width=0.5\textwidth]{cath-gadael-chartref}}
    \end{center}%
  }

So we could then say

\maketitle

to produce the title page.

cat leaving home

\documentclass[a4paper, 11pt, oneside]{book}
\usepackage{graphicx}
\usepackage{titling}

\title{abc}
\author{abc}
\renewcommand\maketitlehooka{%
  \begin{center}
    \fbox{\includegraphics[width=0.5\textwidth]{cath-gadael-chartref}}
  \end{center}%
}

\begin{document}
\maketitle
\end{document}

If you wished to add material after the date, or between the various elements of the standard title, you could define the appropriate hooks (b, c or d) or, for material afterwards, nest the \maketitle inside a titlingpage environment.

  • Very beautiful. I vote your question. – Sebastiano Mar 13 '17 at 8:47
5

enter image description here

\documentclass[a4paper, 11pt, oneside]{memoir}
\usepackage{lipsum, graphicx}
\author{LaTeXFan}
\title{\protect \includegraphics{example-image-a.png}\\[1cm] A very nice image}
\date{\today}


\begin{document}
 \frontmatter
 \maketitle
 \mainmatter
 \lipsum[4]
\end{document}
  • 1
    While your code is nice, it doesn't solve the authors issue to put the picture BEFORE the title. – Skillmon Mar 10 '17 at 9:08
  • @Skillmon You have right. Excuseeeeeeeee meeeeeeee. I have understand now. – Sebastiano Mar 10 '17 at 9:43
  • 1
    You don't have to excuse. Mistakes like this one happen. If you can adept your answer to cover this everything is fine. – Skillmon Mar 10 '17 at 9:46
  • Don't you get an error from your example? Argument of \reserved@a has an extra }. ...cs{example-image}\\[1cm] A very nice image} – user36296 Mar 11 '17 at 18:39
  • 1
    While it would be working now you made a mistake during correction and have duplicated \begin{document} and so on. – Skillmon Mar 12 '17 at 21:46
3

I would simply include the image in the \title as showed in other answer or a title page, but another approach (closer to that you are trying) could be redefine \maketitle to accept also a \logo command in the preamble.

Below it showed an example making this with a very simple definition of \maketitle (no \tanks, etc.) See the content of book.cls if you want start with the original definition. That code would be better placed in your own custom class (but then without \makeatletter and \makeatother) in order to clean the preamble and reuse in another documents.

mwe

\documentclass{book}
\usepackage{graphicx}

% redefinition of \maketitle with a logo ==============  
\makeatletter
\newcommand{\logo}[1]{\gdef\@logo{#1}}%
\def\maketitle{
\newpage
\pagestyle{empty}
\begin{center}
\setlength\baselineskip{8ex}
\setlength\parskip{4em plus 1fil minus 3em}
\includegraphics[width=\textwidth,
height=.6\textwidth,keepaspectratio]{\@logo}\par
{\Huge\sffamily\bfseries \@title}\par
{\Large\scshape \@author}\par
\@date
\end{center}
\newpage}
\makeatother
%  end of redefinition  ===============================  

\logo{example-image}
\title{The Nice Title \\ of the MWE}
\author{The Author}
\date{\today}

\begin{document}
\maketitle
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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