3

I have now modified the document to what I think is a MWE and also realized where it all goes wrong, but I still don't know why. Therefore I will update the post.

I am trying to make a watermark on the front page to be centered but have the problem that it ends up in the left side of the document. What is wrong with the coding? I have just used a precoded script and tried to insert my changes into that. The coding is

\documentclass{article}
\usepackage[firstpage]{draftwatermark}
\usepackage{tikz}
\SetWatermarkText{\tikz{\node[opacity=0.4]{\includegraphics{test_picture}};}}
\SetWatermarkAngle{0}
\SetWatermarkScale{1}
\SetWatermarkColor[rgb]{0,1,0}

\begin{document}
Test
\end{document}

Here it all works fine and the watermark is in the middle, but as I add this part

\usepackage{vmargin}
\setmarginsrb{2.5 cm}{1 cm}{2.5 cm}{2.5 cm}{1 cm}{1.5 cm}{1 cm}{1.5 cm}

It does not and the picture shrinks and ends up on the left. So my question is: what does this coding do, is it important for the rest of the document (I'm writing a report) and what can be done so that the watermark will end up in the right size and position?

Thank you! Mikael

  • 1
    Hi mikael, could you provide a MWE please? – Eric Feb 8 '16 at 13:32
  • 1
    I'm sorry, new to this, what is an MWE? – MIKAEL B Feb 8 '16 at 14:32
  • 1
    it's a full example wich can be compiled. compare here – Eric Feb 8 '16 at 15:20
  • 1
    Aha.. So you want me to get rid of the things that is not necessary for the actual problem? The problem is that I am not sure what is what since I have used a template for the writing and just copy pasted the \setwatermark-thingy.. Sorry! – MIKAEL B Feb 8 '16 at 20:19
  • 1
    I have now created a MWE, I think. – MIKAEL B Feb 11 '16 at 14:43
0

As you correctly identified, the error is introduced by vmargin. I had never heard of this package until now, and reading the description, it seems to have been superseded by geometry.

I'm not sure how vmargin works, because for some reason, it was changing the paper size. I tried to implement similar settings in geometry to produce a similar output, but geometry doesn't adjust the paper size when adjusting various heights and margins.

\documentclass{article}
\usepackage[firstpage]{draftwatermark}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage[
  hmargin=2.5cm,
  vmargin={1cm,2.5cm},
  headheight=1cm,
  headsep=1.5cm,
  footskip=1.5cm,
]{geometry}

\SetWatermarkText{\tikz{\node[opacity=0.2]{\includegraphics{example-image-a}};}}
\SetWatermarkAngle{0}
\SetWatermarkScale{1}
\SetWatermarkColor[rgb]{0,1,0}

\begin{document}
Test
\end{document}

Here's the output:

output

  • Wow, thanks for the quick answer. I have now tried your geometry package and it works great! Just curious about the different commands, what do they all adjust? I'm thinking about these: hmargin=2.5cm, vmargin={1cm,2.5cm}, headheight=1cm, headsep=1.5cm, footskip=1.5cm, Furthermore I wonder if it is possible to move the watermark vertically somehow? Not horizontally which was the problem before. Thank you again! – MIKAEL B Feb 11 '16 at 15:25
  • 1
    You can read all about how geometry works by looking at the package documentation (just follow the link). That will describe what hmargin, vmargin, etc. do. To move it vertically up, you can use \node[text height=3cm]. Play around with the distance (you can even use negative numbers!). – JP-Ellis Feb 11 '16 at 15:42
  • 1
    Oh, sorry that wasn't clear. Just add the text height=3cm option to the existing node, next to opacity=0.2 (and you should separate both options with a comma). – JP-Ellis Feb 11 '16 at 16:10
  • 1
    Haha, if an answer is helpful, make sure to give it an upvote with the arrows next to the answer, and you can (and should) mark the definitive answer with the tick. This gives the person who posted the question and yourself some reputation points :) – JP-Ellis Feb 11 '16 at 16:28
  • 1
    No worries :) You can read the start guide for TeX.SX which should get you started. You get reps by providing good content, either in the form of good and well-posed questions or answers which others then upvote. You also get some reps by accepting an answers :) As you get more reps, you get more privileges because TeX.SX is entirely run by volunteers. – JP-Ellis Feb 12 '16 at 0:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.