[Tex/LaTex] Watermark over Images & Portait to Landscape in LaTex

landscapewatermark

I'm having problem with two separate things.

  1. The first is, that I can't put a watermark over the images. As you can see in the comments, I have tried many different ways, but none of them works correctly or do what I want. And I can't understand why (this is my first document in LaTeX).
  2. The second thing I need to do, is to change a certain page in my document, from Portrait to Landscape. But the thing is, that I want the whole page to change into Landscape. Meaning the Header and Footer too, and thus I don't want to rotate the page. I have also tried different ways but none of them works as wanted.

I have simplified my code so you can only see one page and not the whole document. Can anyone please help me?

\documentclass[10]{article}

\usepackage{graphicx} %Pictures 
\usepackage{fancyhdr} %Header-Footer

\usepackage{pdflscape} %Landscape
\usepackage{lscape} %Landscape

\usepackage[top=2.5cm, bottom=3cm, left=2cm, right=2cm]{geometry} %Page Margins


\usepackage{draftwatermark} %Works but does not set watermarks over image
%\usepackage[printwatermark]{xwatermark} %Doesn't work
\usepackage{xcolor} %Color Manipulation

%\newsavebox\mybox %Doesn't work
%\savebox\mybox{\tikz[color=red,opacity=0.3]\node{DRAFT};} %Doesn't work
%\newwatermark*[ allpages, angle=45, scale=6, xpos=-20, ypos=15]{\usebox\mybox} 
%https://tex.stackexchange.com/questions/132582/transparent-foreground-watermark

%\SetWatermarkText{\includegraphics{draft.png}} %Doesn't work
%https://tex.stackexchange.com/questions/61137/watermark-image

\graphicspath{{C:\Path...}} %path for pictures

\pagestyle{fancy}
\fancyhf{}
\fancyfoot[R]{}

\newpage
\pagestyle{fancy}
\fancyhf{}
\fancyhead[R]{Header  \\ Date}
\fancyfoot[C]{\textbf{Footer}}
\fancyfoot[R] {\textbf{•}\\ \thepage} % \textbf{•} is empty, therefore No. of page is in 2nd line

\begin{document}

%\newwatermark*[page=2-\lastdocpage,color=red!50,angle=45,scale=3,xpos=0,ypos=0]{\textsc{draft}} %Doesn't work
%https://tex.stackexchange.com/questions/118939/add-watermark-that-overlays-the-images

\SetWatermarkText{\textsc{draft}} %Works but does not set watermarks over image as wanted
\SetWatermarkScale{3} %Works but does not set watermarks over image as wanted
\SetWatermarkColor[gray]{0.75} %Works but does not set watermarks over image as wanted

\begin{landscape}
\begin{figure}[h!]
\begin{center}
\fbox{\includegraphics[scale=0.80]{11.png}}
\caption{Caption rotates with image as wanted}
\end{center}
\end{figure}
\end{landscape}

\end{document}

Best Answer

Here is a suggestion using a combination of package typearea from the KOMA-Script bundle and package geometry. Note that you can not use \newgeometry to change the margins of the resulting landscape page. Its bottom margin will be about twice as large as its top margin.

To get the correct head and foot width on the landscape page I would use scrlayer-scrpage instead fancyhdr for header and footer.

Then an additional foreground layer can be defined and added to all layer page styles (@everystyle@) or to a selected one (eg. scrheadings). I presume that the text below the watermark should be still readable, so I use a tikz node with opacity=.3.

\documentclass[10pt]{article}
\usepackage[
  headheight=24pt,footheight=24pt,% as suggested by scrlayer-scrpage
  areasetadvanced
]{typearea}% load this before geometry!!
\usepackage[top=2.5cm, bottom=3cm, hmargin=2cm]{geometry}
\AtBeginDocument{\savegeometry{default}}

\newcommand\switchtolandscape{%
  \clearpage
  \KOMAoptions{paper=landscape}\recalctypearea
  \areaset{\dimexpr\paperwidth-4cm\relax}{\dimexpr\paperheight-7cm\relax}%
}
\newcommand\switchtoportrait{%
  \clearpage
  \KOMAoptions{paper=portrait}\recalctypearea
  \loadgeometry{default}%
}

\usepackage{tikz}%loads graphicx and xcolor

\usepackage[headsepline]{scrlayer-scrpage}
\clearpairofpagestyles
\ohead{Header\\Date}
\cfoot{Footer}
\ofoot{•\\\pagemark}
\addtokomafont{pageheadfoot}{\normalfont}
\addtokomafont{pagefoot}{\bfseries}

\DeclareNewLayer[
  foreground,
  textarea,
  contents={\tikz\node
    [minimum width=\layerwidth,minimum height=\layerheight,text=red,opacity=.3]
    {\rotatebox{45}{\scalebox{8}{\textsc{Draft}}}};%
  }
]{watermark.fg}
\AddLayersToPageStyle{@everystyle@}{watermark.fg}% comment this to remove the watermark

\usepackage{blindtext}% only for dummy text

\begin{document}
\Blindtext

\switchtolandscape
\begin{figure}[htb]
  \begin{center}
    \fbox{\textcolor{yellow!20}{\rule{.9\textwidth}{.9\textheight}}}
    \caption{Caption rotates with image as wanted}
  \end{center}
\end{figure}
\switchtoportrait

\Blindtext
\end{document}

Result:

enter image description here

Related Question