1

I'd like to design a titlepage including 2 logos below the \author definition of command \maketitle. I have found this post, which describes how to make a whole page like this, but I just want the same style as the default \maketitle as top header of the first page. Not the whole page.

Ideally I could choose if I have the logos side by side (horizontal placement) or vertically placed but both always centered.

How can this be accomplished?

example pic

\documentclass[a4paper,ngerman]{article}
\usepackage[ngerman]{babel} 
\usepackage[utf8]{inputenc} 
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{abstract}
\usepackage{lastpage}
\usepackage{amsmath}
\usepackage{color} % colors used for Matlab-codel listings
\definecolor{mygreen}{RGB}{28,172,0} % color values Red, Green, Blue
\definecolor{mylilas}{RGB}{170,55,241}
\usepackage{listings}
\usepackage{comment}
\usepackage{url}
\usepackage{bm}
\usepackage[top=1in, bottom=1.25in, left=1.25in, right=1.25in]{geometry}
\usepackage[T1]{fontenc}
\pagestyle{fancy}

\newcommand{\exercisedate}{date}

\setlength{\headheight}{18pt}
\fancyhead[L]{left }
\fancyhead[C]{}
\fancyhead[R]{\exercisedate}
\fancyfoot[C]{\thepage\ von \pageref{LastPage}}
\fancyfoot[L]{}

\begin{document}
\author{author}
%\publishers{}
\date{\exercisedate}
\title{title}
\clearpage\maketitle
\thispagestyle{fancy}

\begin{abstract}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
\end{abstract}

\section*{section}
\subsection{subsection}
\subsubsection{subsubsection}
\end{document}
avermaet
  • 501

1 Answers1

1

You can use something like the following. It creates two macros, \logoA and \logoB with which you can define the used logos and the optional argument which should be passed to \includegraphics. By setting the length \cus@logo@sep you can specify whether the two logos are used on one line or on two, if it is positive or 0pt the logos are used on one line with this skip as separation, if it is negative they are used below each other and this skip as vertical separation (absolute value).

It works by patching \@maketitle, which is used internally by \maketitle, and inserts the logos in the same centred tabular environment the authors are used in, with a big skip between the logos and the authors.

\documentclass[]{article}

\usepackage[]{graphicx}

\usepackage{etoolbox}
\makeatletter
\patchcmd\@maketitle{\@author}{\@author\cus@logos}{}
  {\GenericError{}{Error: Patching \string\@maketitle failed}{}{}}
\newcommand*\logoA
  {%
    \cus@logo{A}%
  }
\newcommand*\logoB
  {%
    \cus@logo{B}%
  }
\@ifdefinable\cus@logo % needs `\def` syntax so instead of `\newcommand`
  {\def\cus@logo#1#2#{\cus@logo@{#1}{#2}}}
\newcommand*\cus@logo@[3]
  {%
    \csdef{cus@logo@#1}{#2{#3}}%
  }
\newcommand*\cus@logo@A{}
\newcommand*\cus@logo@B{}
\newcommand*\cus@logos
  {%
    \ifx\cus@logo@A\@empty
      \ifx\cus@logo@B\@empty
      \else
        \\\noalign{\bigskip}%
      \fi
    \else
      \\\noalign{\bigskip}%
      \expandafter\includegraphics\cus@logo@A
    \fi
    \ifx\cus@logo@B\@empty
    \else
      \ifx\cus@logo@A\@empty
      \else
        \ifdim\cus@logo@sep<\z@
          \\[-\cus@logo@sep]%
        \else
          \hskip\cus@logo@sep
        \fi
      \fi
      \expandafter\includegraphics\cus@logo@B
    \fi
  }%
\newlength\cus@logo@sep
%% if this length is positive, use both logos next to each other with this as
%% separation, if this lengths is negative use both logos below each other with
%% this length's absolute value as vertical skip
\setlength\cus@logo@sep{-1sp}
\makeatother

\author{Me Myself}
\title{My Title}
\date{\today}
\logoA[width=3cm]{example-image-duck}
\logoB[width=3cm,page=10]{example-image-duck}

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

enter image description here

Skillmon
  • 60,462
  • When I add my logos, they're both .png, I get the error cannot determine size of graphic in img/logo.png. I know this is not due to your code (which is great) but do you know what I can do to solve this? It also says no bounding box. – avermaet Sep 21 '19 at 11:42
  • @avermaet stupid answer: fix your files :) PNG is no good format for inclusion in LaTeX anyways, as it has to be converted by the engine and takes a while. You could try whether you can preconvert your PNGs to PDF using sam2p or ImageMagick's convert (if you're on a Linux or Mac) and use those files instead. – Skillmon Sep 21 '19 at 11:46
  • Thanks, I'll do that. Usually I also prefer .eps or .pdf for images I generate from my code, but this one was given to me and I just thought .png would also work even though its not a vector graphic. – avermaet Sep 21 '19 at 11:50