0

I am trying to put together a title page with a graphic taking up the upper portion, and a block of colour immediately below it. The code in question currently looks as follows:

\newgeometry{margin=0in}
\begin{titlingpage}

  \begin{figure}[t]
    \makebox[\linewidth]{\includegraphics[width=1.0\linewidth]{./latex-addtl/laptop-open}}
    \textcolor{MyRed}{\rule[0mm]{\linewidth}{16mm}} % this makes the block of red below the image
  \end{figure}

  \maketitle    

\end{titlingpage}
\restoregeometry

The problem is that I am getting stuck with a thin gap between the graphic and the rule. I have tried adding a negative vspace and altering the raise of the rule but neither seemed to actually do anything. I have also tried adding a % on the end of the line after the makebox command, which seemed to just make the rule disappear somewhere, presumably behind the image.

At present, what I am getting looks like this, with the slight gap before the rule:

Horizontal white line above red block is undesirable

EDIT: A full working example follows, with the gap fixed thanks to comments. It has been suggested that I remove the float, but if I do that the title moves to a new page, so I'd appreciate input on what's wrong there. The code is quite long because it's intended to be an rmarkdown template and I don't want to remove things that impact layout but that I have to leave in for the template's sake:

\documentclass[12pt,a4paper]{article}

\usepackage{titling}
\usepackage[margin=1in]{geometry}

% Image scaling stuff from original Rmarkdown template:

\usepackage{graphicx}

\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}

\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
}

% Create subtitle command for use in maketitle
\newcommand{\subtitle}[1]{
  \posttitle{
    \end{flushleft}
    \par
    \mdseries
    \begin{flushleft}
    \hspace{\titlemargin}
    \Huge#1
    \end{flushleft}
    }
}

\newlength{\titlemargin}
\setlength{\titlemargin}{1in}

\setlength{\droptitle}{-2em}
\title{My silly document}
\pretitle{\begin{flushleft}\vspace{\droptitle}\hspace{\titlemargin}
\Huge\bfseries}
\posttitle{\par\mdseries\end{flushleft}}
\subtitle{A subtitle}
\predate{\large\vspace{2em}
\hspace{\titlemargin}
}
\postdate{\par}
\date{16 July 2018}
\author{}

\usepackage{sectsty}
\usepackage{xcolor}
\usepackage[T1]{fontenc}
\usepackage[scaled]{helvet}

\renewcommand*\familydefault{\sfdefault}

\definecolor{Myred}{cmyk}{0,1,0.99,0.04}

\begin{document}

\newgeometry{margin=0in}
\begin{titlingpage}

    \begin{figure}[t]
    \lineskip=0pt
    \includegraphics[width=1.0\linewidth]{./latex-addtl/laptop-open}    
    \textcolor{Myred}{\rule[0mm]{\linewidth}{16mm}} % this makes the block of red below the image
    \end{figure}

    \maketitle

    \vfill
    \hspace{\titlemargin}\includegraphics[width=0.6\linewidth]{./latex-addtl/logotagline}
    \vspace{0.8\titlemargin}
\end{titlingpage}
\restoregeometry

\section{Executive Summary}\label{executive-summary}

Hello this is the document in question.

This is another line.

\end{document}
mbza
  • 1
  • 1
  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – samcarter_is_at_topanswers.xyz Jul 23 '18 at 14:20
  • Add \lineskip=0pt after \begin{figure}[t] to make the white space disappear. Apart from that I'm pretty sure that the titlingpage environment with the figure in it is not really what you want. But this is a question for a different post. – gernot Jul 23 '18 at 14:26
  • Why the makebox? It does not contribute anything. Are you sure the image does not contain that white line? Try setting \setlength\fboxsep{0pt} and then wrapping the image in \fbox{...}, thus will show where latex thinks the image boundaries are, thus reveling a bad crop. Also there is no need to use the figure env to get an image on your title page. – daleif Jul 23 '18 at 14:26
  • 1
    Never use figure on a titlepage. see https://en.wikibooks.org/wiki/LaTeX/Title_Creation – Johannes_B Jul 23 '18 at 14:29
  • @Johannes_B @gernot - if I don't use figure then I can't seem to stop it from putting the text created by \maketitle on a new page... Nonetheless \lineskip=0pt seems to work. I have updated the post with a MWE for interest's sake – mbza Jul 24 '18 at 09:04
  • Your titlepage setup is completey mysterious to start with. You should never use \maketitle within a titlepage or titlingpage. If the wikibook page isn't very helpful, you can also have a look at http://tex.stackexchange.com/questions/209993/how-to-customize-my-titlepage/210280#210280 – Johannes_B Jul 24 '18 at 16:28
  • Because it was a pandoc template I was hesitant to remove existing code, but I'm sure you're right. I will hopefully have some success if I clean it up. – mbza Aug 03 '18 at 16:12

1 Answers1

2

You have not provided a usable example so this is untested but I assume that you do not want a float on the title page so

\begin{titlingpage}


\includegraphics[width=\linewidth]{latex-addtl/laptop-open}

\nointerlineskip
\textcolor{MyRed}{\rule[0mm]{\linewidth}{16mm}} % this makes the block of red below the image
David Carlisle
  • 757,742
  • Thanks, I couldn't get this to work, but have added a working example that fixes the gap but still includes the float that it looks like I should remove.. – mbza Jul 24 '18 at 09:12