我正在尝试制作一个标题页,其中的图形占据上部,而其下方则有一块颜色。目前的代码如下所示:
\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
问题是,图形和规则之间的缝隙很小,我被卡住了。我尝试添加负片vspace
并更改raise
规则的,但似乎都没有实际作用。我还尝试%
在 makebox 命令后的行尾添加,这似乎只是让规则消失在某个地方,大概是在图像后面。
目前,我得到的结果如下,规则前有轻微的间隙:
编辑:下面是一个完整的工作示例,由于注释,间隙已修复。有人建议我删除浮动,但如果我这样做,标题将移动到新页面,因此我很感激您提供那里出了什么问题。代码很长,因为它旨在用作 rmarkdown 模板,我不想删除影响布局但为了模板的缘故我不得不保留的东西:
\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}
答案1
你没有提供一个可用的示例,所以这是未经测试的,但我认为你不想在标题页上使用浮动,所以
\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