Search code examples
pdflatexquarto

Full page width image in PDF made in quarto


I'm trying to get an image to span the full width of the first page of a PDF document I'm making in quarto, but everything I've tried leaves at least a small gap on one or both sides of the image. The original image size is 8.38cm by 20.97cm, I don't mind if I lose part of the image, I just don't want any gaps.

I don't have much experience with latex so I'm at a loss. This is the best result I've got, but still leaves a sliver of white either side:

\begin{figure}[H]
  \makebox[\textwidth][c]{\includegraphics[width=23cm]{../images/titlestrip.png}}
\end{figure}

Here's what else I've tried (amongst other things):

\begin{adjustwidth}{-1in}{-1in}
\AddToShipoutPicture*{%
 \AtPageUpperLeft{\raisebox{-2.5\height}{\includegraphics[width=23cm]{../images//titlestrip.png}}}}
\end{adjustwidth}
\begin{adjustwidth}{-1.25in}{-1.25in}
\begin{textblock*}{24cm}[0.5,0.5](10.5cm,17cm)
    \includegraphics[width=22cm]{../images/titlestrip.png}
\end{textblock*}
\end{adjustwidth}
\begin{flushright}
\begin{figure}[H]
    \includegraphics[width=\paperwidth]{../images/titlestrip.png}
\end{figure}
\end{flushright}
\noindent\makebox[\textwidth][c]{
  \begin{minipage}{2\textwidth}
    \begin{figure}[H]
    \includegraphics[width=21cm]{../images/titlestrip.png}
  \end{figure}
  \end{minipage}
}
\begin{figure}[H]
  \centering
  \begin{adjustwidth}{-1in}{-1in}
    \includegraphics[height=8.47cm]{../images/titlestrip.png}
  \end{adjustwidth}
\end{figure}
\begin{figure}[H]
  \makebox[\textwidth][c]{\includegraphics[width=23cm]{../images/titlestrip.png}}%
  \caption{Caption}
  \label{fig:key}
\end{figure}
\newlength{\offsetpage}
\setlength{\offsetpage}{1.0cm}
\newenvironment{widepage}{\begin{adjustwidth}{-1in}{-1in}%
    \addtolength{\textwidth}{2in}}%
{\end{adjustwidth}}

\begin{figure}[H]
  \begin{widepage}
  \makebox[\textwidth][c]{\includegraphics[width=23cm]{../images/titlestrip.png}}%
  \caption{Caption}
  \label{fig:key}
  \end{widepage}
\end{figure}

In this image, the red block is the image position I currently have, the green either side is the extra space I'd like it to cover. The green square is another image in the correct position.


Solution

  • Maybe try using the background package? Here is what worked for me:

    \documentclass{article}
    \usepackage{graphicx} % Required for inserting images
    \usepackage[pages=some]{background}
    
    \title{Bunch of text}
    
    \begin{document}
    
    \maketitle
    
    \backgroundsetup{
      scale=1.0,
      angle=0,
      opacity=0.95,
      contents={
        \includegraphics{red.png}}}
    
    \BgThispage
    
    \end{document}
    

    and this is the output:

    Screenshot of the pdf output