I'm using the background package. Is there any option to remove the background from the ToC and from the first page of each chapter?
Besides, is it possible to override the background on some pages and then getting back to the globally set one?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityI'm using the background package. Is there any option to remove the background from the ToC and from the first page of each chapter?
Besides, is it possible to override the background on some pages and then getting back to the globally set one?
The background
package offers commands \BgThispage
and \NoBgThispage
which were intended to allow activation/deactivation of the background material on selected pages; however, I've discovered that they are not behaving exactly as they were meant to, so I'll have to review the code.
In the meantime I can offer a possibility through two commands \DeactivateBG
, \ActivateBG
; the first one sets the contents to be empty; the second one, sets the contents to the desired background material. Use \DecativateBG
immediately after \chapter
and \ActivateBG
in any place on the second page of each chapter:
\documentclass[openany]{book}
\usepackage[a6paper]{geometry}
\usepackage{background}
\usepackage{etoolbox}
\usepackage{lipsum}
\newcommand\DeactivateBG{\backgroundsetup{contents={}}}
\newcommand\ActivateBG{\backgroundsetup{contents={Draft}}}
\begin{document}
\DeactivateBG
\tableofcontents
\chapter{Test Chapter One}
\DeactivateBG
\lipsum[4]
\ActivateBG
\lipsum[3-4]
\chapter{Test Chapter Two}
\DeactivateBG
\lipsum[4]
\ActivateBG
\lipsum[3-4]
\chapter{Test Chapter Three}
\DeactivateBG
\lipsum[4]
\ActivateBG
\lipsum[3-4]
\end{document}
To answer your second question, you can have as many backgrounds as you want; the idea is to define a command for each different kind and switch between them by issuing the commands somewhere in the page where the change should happen; a little example:
\documentclass[openany]{book}
\usepackage[a6paper]{geometry}
\usepackage{background}
\usepackage{lipsum}
\newcommand\MainBG{%
\backgroundsetup{
contents={Main},
angle=0,
color=cyan
}%
}
\newcommand\SecondaryBG{%
\backgroundsetup{
contents={Secondary},
angle=-60,
color=orange,
}%
}
\newcommand\TertiaryBG{%
\backgroundsetup{
contents={Tertiary},
angle=60,
color=green!70!black,
}%
}
\begin{document}
\MainBG
\lipsum[1-4]
\SecondaryBG
\lipsum[1-2]
\MainBG
\lipsum[1]
\TertiaryBG
\lipsum[1-3]
\MainBG
\lipsum[1-2]
\end{document}
The class option openany
and the settings for geometry
were used just for the example.