0

I am not able to make this command be deterministic. The weird behaviour I get with PDFLaTeX is explained in the comments of the following MWE. I checked for conflicts with package afterpage, also maybe via multicol, in my original document and after reading the warning in background's documentation, but it didn't help. What can I do?

\documentclass[oneside,a4paper]{book}%
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage[pages=all]{background}
\backgroundsetup{opacity=0.7,contents={\Huge MY BACKGROUND}}

\begin{document}

\thispagestyle{plain}%
% \BgThispage{}\BgThispage{}\BgThispage{} %Shorthand to enhance opacity just here.

TITLE-PAGE

\clearpage\thispagestyle{empty} \NoBgThispage{}

\thispagestyle{empty} A first BgLess page.

\clearpage\thispagestyle{empty}

%\NoBgThispage{} %THIS COMMAND WILL MAKE ALL THE FOLLOWING PAGES MISS THE BACKGROUND.

\textbf{No BG here, please, but yes afterwards. Shouldn't it be as easy as in the previous page?}

\clearpage\thispagestyle{empty} %\BgThispage% Even this command will be bypassed.

\clearpage %\NoBgThispage{} %Again, this will affect every remaining page. TOC page.

\clearpage%

\lipsum[1-10]

\vfill{}Why is BG missing here?

\end{document}

Andrestand
  • 1,085
  • 1
    well the implementation is faulty. If you issue \NoBgThispage twice you loose the background. – Ulrike Fischer May 17 '23 at 21:47
  • I misunderstood your comment. I guess you mean the command itself is just a workaround to omit the background and it can only be used once in the whole document. Right? :( – Andrestand May 18 '23 at 14:09

1 Answers1

0

After @Ulrike Fischer's comment and this answer: https://tex.stackexchange.com/a/210105/36389 a possible workaround for both enhancing opacity in specific pages and also omitting the background in others is to consider changing the background setup after \begin{document}. In this case, I defined 3 commands to hold different common setups along the document:

\documentclass[oneside,a4paper]{book}%
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage[pages=all]{background}
\newcommand{\TitlePageBgOpacity}{0.95}
\newcommand{\NormalPageBgOpacity}{0.5}
\newcommand{\NoBgPageBgOpacity}{0}

\backgroundsetup{contents={\Huge MY BACKGROUND}}

\begin{document}

\thispagestyle{plain}%
% \backgroundsetup{opacity=\TitlePageBgOpacity}

TITLE-PAGE

\clearpage\thispagestyle{empty} \backgroundsetup{opacity=\NoBgPageBgOpacity} \thispagestyle{empty} A first BgLess page.

\clearpage\thispagestyle{empty} %\backgroundsetup{opacity=\NoBgPageBgOpacity}

\textbf{No BG here, please, but yes afterwards. Shouldn't it be as easy as in the previous page?}

\clearpage\thispagestyle{empty} \backgroundsetup{opacity=\NormalPageBgOpacity}

\clearpage \backgroundsetup{opacity=\NoBgPageBgOpacity} TOC page.

\clearpage% \backgroundsetup{opacity=\NormalPageBgOpacity} \lipsum[1-10]

\vfill{}Why is BG missing here?

\end{document}

Andrestand
  • 1,085