निरंजन
I liked the way watermark is set for the [documentation of package background](http://texdoc.net/texmf-dist/doc/latex/background/background.pdf). I saw how it is done in its source and made this code -

#
\documentclass[border=2cm]{standalone}
\usepackage[placement=top]{background}
\SetBgContents{abcd}
\SetBgAngle{0}
\SetBgScale{3}
\SetBgHshift{65}
\SetBgVshift{-5}

\begin{document}
Hello world
\end{document}


This doesn't give me the watermark, but in \documentclass{article} it actually works. I want to set a watermark which will automatically be adjusted to the given page-size. Is there any alternative to this package?
marmot
In case this is in any way related to your previous question on frames around standalalone documents, and also if it is not, then there is good news: you can enhance the boxes from the previous tcolorbox answer to allow for watermarks. Ironically, you really basically need to add the enhanced key to get access to these features (and load the skins library). In fact, tcolorbox comes with an extended support for watermarks, which are described in section 10.3 of manual v4.31. Since there is no mention of a frame, for the time being I switched it off with colframe=white (there are other ways, of course).


\documentclass[border=3mm]{standalone}
\usepackage[skins]{tcolorbox}
\newtcolorbox{mybox}[1][]{hbox,colback=white,colframe=white,
watermark color=blue,watermark opacity=0.3,
enhanced,boxsep=3cm,#1}
\standaloneenv{mybox}
\begin{document}
\begin{mybox}[watermark text=pft]
Hello world!
\end{mybox}
\begin{mybox}[watermark text=quack]
Hello ducks!
\end{mybox}
\end{document}

![ani.gif](/image?hash=ffc1d8d7172446226ee16f6541823de9271170502753861425bfee41ffb363a3)

You can then create whatever watermark you like. Just to give an (admittedly not overly nice) example, you can typeset the watermark text along a circle.

\documentclass[border=3mm]{standalone}
\usepackage[skins]{tcolorbox}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\newtcolorbox{mybox}[1][]{hbox,colback=white,colframe=white,
watermark color=blue,watermark opacity=0.3,
enhanced,boxsep=3cm,#1}
\tcbset{circular watermark/.style={watermark tikz={%
\pgfmathsetmacro{\myr}{0.2cm+1*width("#1")/2/pi}%
\pgfmathsetmacro{\myR}{\myr+height("#1")-2pt}%
\path[decorate,decoration={text along path,text align={align=center},
raise=-0.15ex,text={|\sffamily|#1}}]
(0,-\myr pt) arc[start angle=270,end angle=-90,radius=\myr pt];
% necessary to get the bounding box right
\path (0,-\myR pt) arc[start angle=270,end angle=-90,radius=\myR pt];
}}}
\standaloneenv{mybox}
\begin{document}
\begin{mybox}[circular watermark=pft]
Hello world!
\end{mybox}
\begin{mybox}[circular watermark=meow]
Hello cats!
\end{mybox}
\begin{mybox}[circular watermark=quack]
Hello ducks!
\end{mybox}
\end{document}

![ani.gif](/image?hash=0383a0551c14206b582da561e92bf084f6eea39a80912b4e7461957b4e4d82cb)

Skillmon
There are 3 code versions in this answer:

1. using the development version of LaTeX
1. using eso-pic instead of the development version of the kernel
1. an example with an auto-scaling watermark

## Development kernel version

The following uses the new hook-mechanism provided in the development version of the LaTeX kernel (so you need to compile this with pdflatex-dev, lualatex-dev or xelatev-dev).

It also requires xfp for the placement, both xcolor and graphics are only needed for the used contents of \mywatermark.


\documentclass{standalone}

\usepackage{xcolor}
\usepackage{graphics}
\usepackage{xfp}

\newcommand*\mywatermark{\rotatebox{30}{\sffamily\color{gray}\huge watermark}}

{%
\setlength\unitlength{1pt}%
\put(\fpeval{1in+0.5*\paperwidth},\fpeval{-1in-0.5*\paperheight})
{%
\sbox0{\makebox[0pt][c]{\mywatermark}}%
\raise.5\dimexpr\dp0-\ht0\relax\box0
}%
}

\begin{document}
\parbox[t][5cm]{10cm}{Hello world}
\end{document}


![test-1.png](/image?hash=0ee9b3c6cc4e4b42f866f43eb4747f70eb5b97ea51c167384c467090864a57a0)

----

## eso-pic version

Without the development versions, you can use eso-pic with the option texcoords (just so I don't have to change the rest of the code). So the following works in current versions of LaTeX:


\documentclass{standalone}

\usepackage{xcolor}
\usepackage{graphics}
\usepackage{xfp}
\usepackage[texcoord]{eso-pic}

\newcommand*\mywatermark{\rotatebox{30}{\sffamily\color{gray}\huge watermark}}

{%
\setlength\unitlength{1pt}%
\put(\fpeval{1in+0.5*\paperwidth},\fpeval{-1in-0.5*\paperheight})
{%
\sbox0{\makebox[0pt][c]{\mywatermark}}%
\raise.5\dimexpr\dp0-\ht0\relax\box0
}%
}

\begin{document}
\parbox[t][2cm]{5cm}{Hello world}
\end{document}


(results are the same as above, so no new picture)

-----------

## Auto-scaling example

Just to show, that auto-scaling is possible, the following uses adjustbox and its max totalsize key for the that.


\documentclass{standalone}

\usepackage{xcolor}
\usepackage{graphics}
\usepackage{xfp}
\usepackage[texcoord]{eso-pic}

\newcommand*\mywatermark
{%
{max totalsize={\paperwidth}{\paperheight}}%
{\rotatebox{30}{\sffamily\color{gray}\huge watermark}}%
}

{%
\setlength\unitlength{1pt}%
\put(\fpeval{1in+0.5*\paperwidth},\fpeval{-1in-0.5*\paperheight})
{%
\sbox0{\makebox[0pt][c]{\mywatermark}}%
\raise.5\dimexpr\dp0-\ht0\relax\box0
}%
}

\begin{document}
Hello World!
\end{document}


![watermark-1.png](/image?hash=0743b5c7df6decec35a6ed2cd58087805ac84d2ed3ead5c62d28cbb463822d70)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.