0

My intent is to have several different background images on the same (one) page.
I read background package documents and found no answer (though I didn't really got an idea of what the anchors are for, maybe that's the answer I'm looking for but I really need some guidance).
For now I managed to perfectly add a single background image to any page I want with a great deal of control over that image and the only solution I came up with is to add another image to the same page with includegraphics but that solution doesn't work the way I need it to work because it limits my ability to work with text and images on the same page. If a background image is layered behind the text, an image added with includegraphics is always separated.
I tried to duplicate \backgroundsetup command and use \BgThispage twice within the same page but it returns an error.
Is there a practical way to have several different background images on one page?

% !TEX TS-program = LuaLaTeX
\documentclass[11pt,twoside,openany]{book}
\usepackage[
  paperwidth=6in,
  paperheight=9in,
  inner=15mm,
  top=15mm,
  outer=20mm,
  bottom=22mm,
  heightrounded,
  showframe,
]{geometry} 
\usepackage[pagewise]{lineno} 
\usepackage{fontspec}
\usepackage{microtype}
\usepackage[shortcuts]{extdash}
\usepackage{graphicx}
\usepackage[dvipsnames]{xcolor}
\usepackage{titlesec}

\usepackage[pages=some]{background}

\titleclass{\part}{top}
\titleformat{\part}{\filcenter\normalfont\large}{\thepart.}{20pt}{\LARGE}
\titlespacing*{\part}{0pt}{10pt}{40pt}

\titleclass{\chapter}{straight}
\titleformat{\chapter}[display]{\filcenter\normalfont\large}{\thechapter.}{6pt}{}
\titlespacing*{\chapter}{0pt}{30pt}{10pt plus 10pt}

\setmainfont{EB Garamond}

\setlength{\parskip}{0pt} 
\let\cleardoublepage\clearpage 
\pagestyle{plain}

\begin{document} 

\vspace*{0mm}
 \backgroundsetup{
scale=1,
color=black,
opacity=1,
angle=0,
position={50mm,-50mm}, 
contents={%
  \includegraphics[width=3in,height=5in,keepaspectratio]{example-image}
  }%
}
\BgThispage 

\begin{center}
\vspace{10mm}
        {\fontsize{36}{36}\bfseries {SOME TEXT ON PRETITLE PAGE}\par}
        \vspace{15mm}  
\end{center} 

\begin{picture}(0,150)
   \put(180,-150){\includegraphics[width=60mm,height=60mm,keepaspectratio]{example-image}}
  \end{picture}
\clearpage

\frontmatter
    
\begin{titlepage}
  \centering
  \vspace*{10mm} 
  {\scshape\huge TITLE\par}
\end{titlepage}

\mainmatter

\pagenumbering{arabic}

\part{PART ONE}

\chapter{CHAPTER ONE} 

  
\end{document}

4
  • why do all your examples have \let\cleardoublepage\clearpage ? You specify two sided processing with \documentclass[11pt,twoside, but then break the main tool latex uses to arrange things are on the intended side. Apr 3, 2022 at 15:21
  • There's a specific need that explains that line. If I got it right, that code prevents latex from creating a blank page after the title page and that's exactly what I need. Somehow (though I don't really know how) I got it the way that in my document that blank page doesn't get created and I still managed to get a double-sided book with side's order intact. I just don't need that blank page. So my solution was to either have it edited (I doubt that it's possible) or to remove it at all, what I successfully did. I'll probably raise this question in a separate post to address that issue.
    – tryingout
    Apr 3, 2022 at 19:38
  • no. one of your other questions had a comment by that line about titlepage, but that is not at all what it does. Its action lasts for the entire document and it disables the twoside handling (and could potentially make latex loop forever) whenever latex needs to get to a right hand (odd) page it will issue \cleardoublepage but that definition breaks that processing and can leave it on an even page so latex will be in an undefined and unstable state, It's basically broken behaviour. Apr 3, 2022 at 19:43
  • Then I definitely need to fix that. And somehow find a solution to either have that blank page after the title page edited with some text or have it removed by some other legit method. I guess I'll address it in a separate question unless you can point me to some useful info I can read myself.
    – tryingout
    Apr 3, 2022 at 19:52

1 Answer 1

1

It isn't clear what your issue is, any method that you use to add one image will let you add multiple. Most of your example appeared to be using unrelated package code so I omitted them here and just use graphicx needed to include the images.

If you have an old latex release without the built in hooks you can use one of the packages such as everyshi that provided similar functionality.

enter image description here

\documentclass{article}

\usepackage{graphicx}


\AddToHook{shipout/background}{%
 \put(10,-100){\includegraphics[width=3cm]{example-image-a}}
 \put(50,-6cm){\includegraphics[width=4cm]{example-image-b}}
 \put(4cm,-10cm){\includegraphics[width=4cm]{example-image-c}}
 \put(8cm,-15cm){\includegraphics[width=6cm]{example-image}}
}
\begin{document}

\section{Section AAA}
Some text. Some text. Some text. Some text.
Some text. Some text. Some text. Some text.

Some text. Some text. Some text. Some text.
Some text. Some text. Some text. Some text.

\section{Section BBB}
Some text. Some text. Some text. Some text.
Some text. Some text. Some text. Some text.

Some text. Some text. Some text. Some text.
Some text. Some text. Some text. Some text.
Some text. Some text. Some text. Some text.
Some text. Some text. Some text. Some text.

Some text. Some text. Some text. Some text.
Some text. Some text. Some text. Some text.

\section{Section CCC}
Some text. Some text. Some text. Some text.
Some text. Some text. Some text. Some text.

Some text. Some text. Some text. Some text.
Some text. Some text. Some text. Some text.
Some text. Some text. Some text. Some text.
Some text. Some text. Some text. Some text.

Some text. Some text. Some text. Some text.
Some text. Some text. Some text. Some text.


\end{document}
4
  • Hi! Thanks for providing your solution but that's not really what I need. I need to have multiple different images on one page (and you got it right!) but on one page only, not on every page of the book. In other words, on Page1 I need to have ImageA, Image B and ImageC (for example) and on Page2 I'd like to have ImageD and ImageE and so on. Multiple different images for each page separately.
    – tryingout
    Apr 3, 2022 at 19:33
  • @tryingout well that's OK, just use \includegraphics{image-\thepage} then it will include a different image on each page or use \ifnum\value{page}=6 \includegraphics{...}\fi then it will only have an image on page 6, or whatever you need. Apr 3, 2022 at 19:36
  • OK, I sorted it out with all the pages I need by using \addtocounter command. I should have studied the graphicx package as you recommended but instead I got stuck with background which I didn't really need. Thanks for your help! By the way, which latex release would you recommend for Mac? Currently using TexShop
    – tryingout
    Apr 3, 2022 at 20:35
  • @tryingout texshop is an editor not a tex distribution, I'm not a mac user but I believe most use mactex which is a mac packaging of texlive Apr 3, 2022 at 20:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .