4

I use \thiswatermark to put my image in the background of my paragraph like this:

\thiswatermark{
   \put(100,-350){
       \transparent{0.1}
       \includegraphics[width=0.5\textwidth, height=75pt]{image.png}
   }
}

But instead of using the static position (100,-350) I need to do it in a dynamic way by passing the current position. I know that \zsavepos{saved_pos} allows saving the current position:

(\zposx{saved_pos}, \zposy{saved_pos})=(\the\dimexpr\zposx{saved_pos}sp, \the\dimexpr\zposy{saved_pos}sp)

current position coordinates (x, y)

But how can I pass those coordinates to \put(x,y) ?

2
  • Can you show a sketch how the output should look like? Apr 25, 2018 at 18:34
  • Consider using the textpos package. Works for images as well as text. Allows you to place an object at either absolute page position, or position relative to where you write the command. I have used it. Works great. Text following the positioned element will sit above it, effectively making the positioned element as a background.
    – user139954
    Apr 25, 2018 at 20:02

2 Answers 2

2

I can't answer the more general question of getting figures where you want them. But to the question of how you transmit zpos information to \put, you would do something as follows.

\documentclass{article}
\usepackage[savepos]{zref}
\usepackage{watermark,graphicx}
\makeatletter
\newcommand\strippt{\strip@pt}
\makeatother
\begin{document}
Here I\zsavepos{B} save a position

The location is (\zposx{B}, \zposy{B}).

(\the\dimexpr\zposx{B}sp, \the\dimexpr\zposy{B}sp)

(\the\dimexpr\zposx{B}sp, \the\dimexpr\paperheight-\dimexpr\zposy{B}sp)

\edef\tmp{%
  (\strippt\dimexpr\zposx{B}sp, \strippt\dimexpr\paperheight-\dimexpr\zposy{B}sp)}

\tmp

200x200 picture: \fbox{\begin{picture}(200,200)
 \expandafter\put\tmp{Put at \tmp}
\end{picture}}
\end{document}

enter image description here

1
  • Yes this helps. I did the following:\zsavepos{saved_pos} \edef\tmp{ (\strippt\dimexpr\zposx{saved_pos}sp,\strippt\dimexpr\zposy{saved_pos}sp-\dimexpr\paperheight)} \thiswatermark{ \expandafter\put\tmp{ \transparent{0.1} \includegraphics[width=0.5\textwidth, height=75pt]{image.png} } } some text... Apr 25, 2018 at 21:57
4

Not a perfect solution, but you could use a tcolorbox with some watermark graphic.

For parindet value see: Indentation in tcolorbox package

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lmodern}
\usepackage{lipsum}

\newtcolorbox{mybox}{
    enhanced,
    breakable,
    notitle,
    watermark graphics=example-image,
    watermark opacity=.50,
    watermark zoom=1,
    blanker,
    before upper={\parindent15pt},
}

\begin{document}
\lipsum[1]

\begin{mybox}
\indent This is some text. \lipsum[2]
\end{mybox}

\lipsum[3]

\begin{mybox}
\lipsum[4-6]
\end{mybox}
\end{document}

enter image description here

7
  • Before making this topic as Resolved, why watermark opacity=.50, doesn't work?. Apr 25, 2018 at 21:26
  • What does not work? Could you explain it?
    – Ignasi
    Apr 25, 2018 at 22:06
  • Despite of using watermark opacity=.50, the image is not transparent . Apr 25, 2018 at 22:12
  • IMHO it works as expected. watermark opacity=1 applies no fading to the image and watermar opacity=0 completely hides it. watermark opcaity=0.5 offers an attenuated version. If the image is not transparent, nothing else can be done.
    – Ignasi
    Apr 26, 2018 at 6:45
  • So may be there is something else in my case which prevents this to work properly. Apr 26, 2018 at 23:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .