Watermark on all pages in article class document?

164 Views Asked by At

I want to make a document in the the article class with a watermark on all the pages. Furthermore, I want to be able to control the opacity of this watermark. The following code gives 2 problems: 1) Watermark is on the first page only 2) I cannot adjust the opacity of the watermark. Is there a way to solve these issues?

\documentclass[12pt,a4paper,twoside,envcountsect]{article} 

\usepackage{fancyhdr} 
\usepackage{lastpage} 
\usepackage[titles,subfigure]{tocloft} 
\usepackage{subcaption}
\usepackage{geometry}
\geometry{top=2.5cm , bottom=2.5cm , left=2.5cm , right=2.5cm , headsep=9mm , footskip=14mm , marginparwidth=2.0cm , marginparsep=0.25cm , a4paper , pdftex}
\pagestyle{fancy}             
\fancyhead{} 
\fancyhead[LE,RO]{ \footnotesize \nouppercase \leftmark }
\fancyhead[LE,RO]{}
\lhead{\footnotesize lhead}
\chead{\footnotesize chead}
\rhead{\footnotesize rhead}
\fancyfoot{} 
\rfoot{Page \thepage \space of \pageref{LastPage}}
\lfoot{lfoot}
\renewcommand{\headrulewidth}{0.6pt} 
\renewcommand{\footrulewidth}{0.6pt} 
\renewcommand{\sectionmark}[1]{\markboth{#1}{}}

\usepackage[printwatermark]{xwatermark}
\newwatermark[
    allpages,
    opacity=0.5,
    color=red,
    angle=45,
    scale=3.14,
    xpos=0,
    ypos=0
    ]{WATERMARK} % watermark underneath
%\newwatermark*[allpages,color=red,angle=45,scale=3,xpos=3.3,ypos=3.8]{WATERMARK} % watermark on top

\usepackage[]{hyperref}
\newcounter{Chapcounter}
\newcommand\showmycounter{\addtocounter{Chapcounter}{1}\themycounter}
\newcommand{\chapter}[1] 
{    
  \addcontentsline{toc}{section}{\large\color{cyan} #1}    
}

\hypersetup{colorlinks=true}
\hypersetup{linkcolor=black}

\begin{document}

\renewcommand*{\contentsname}{\LARGE Contents}

\vspace{1cm}
\begin{center}
    \huge{Headline}
\end{center}
\vspace{1cm}

\tableofcontents\newpage

\chapter{Calculus}
\section{Subject}

\newpage
\chapter{Algebra}
\section{Subject}

\end{document} 
1

There are 1 best solutions below

3
samcarter_is_at_topanswers.xyz On BEST ANSWER
\documentclass[12pt,a4paper,twoside]{article} 

\usepackage{fancyhdr} 
\usepackage{lastpage} 
\usepackage[titles,subfigure]{tocloft} 
\usepackage{subcaption}
\usepackage{geometry}
\geometry{top=2.5cm , bottom=2.5cm , left=2.5cm , right=2.5cm , headsep=9mm , footskip=14mm , marginparwidth=2.0cm , marginparsep=0.25cm , a4paper , pdftex}
\pagestyle{fancy}             
\fancyhead{} 
\fancyhead[LE,RO]{ \footnotesize \nouppercase \leftmark }
\fancyhead[LE,RO]{}
\lhead{\footnotesize lhead}
\chead{\footnotesize chead}
\rhead{\footnotesize rhead}
\fancyfoot{} 
\rfoot{Page \thepage \space of \pageref{LastPage}}
\lfoot{lfoot}
\renewcommand{\headrulewidth}{0.6pt} 
\renewcommand{\footrulewidth}{0.6pt} 
\renewcommand{\sectionmark}[1]{\markboth{#1}{}}

\usepackage{tikz}
\AddToHook{shipout/background}{
\begin{tikzpicture}[remember picture,overlay]
  \node[font=\Huge,red,rotate=45,opacity=0.45] at (current page.center) {Watermark};
\end{tikzpicture}
}

\usepackage[]{hyperref}
\newcounter{Chapcounter}
\newcommand\showmycounter{\addtocounter{Chapcounter}{1}\themycounter}
\newcommand{\chapter}[1] 
{    
  \addcontentsline{toc}{section}{\large\color{cyan} #1}    
}

\hypersetup{colorlinks=true}
\hypersetup{linkcolor=black}

\begin{document}

\renewcommand*{\contentsname}{\LARGE Contents}

\vspace{1cm}
\begin{center}
    \huge{Headline}
\end{center}
\vspace{1cm}

\tableofcontents\newpage

\chapter{Calculus}
\section{Subject}

\newpage
\chapter{Algebra}
\section{Subject}

\end{document}