Featured Post

We've moved to tex.my!

It’s been great writing on Blogger.com, but we’ve decided to move to a new platform, thanks to some valuable help from a great, great friend...

Friday, August 24, 2012

Putting Dates in Watermarks

It’s been rather a long time sine I last posted anything as I’ve been working on my thesis and article… sorry!

Theses and articles typically go through many versions, ding-dong to-and-fro between supervisors and co-authors. Some people keep track of the version number (or date-last-modified) by giving each draft a different file name. Personally, though, I tend to get inconsistent with the file naming, especially when it's 2:30am. So I figured it might work better for me if the date-last-modified was printed in the PDF of the thesis/article draft itself.

One could always put the date in the header or footer, but there might already be some content in those regions. Besides, it's probably not a good idea to mess with the formattings for a journal article. Instead, I put \today in a watermark, so the date would get updated I compile my draft:

\usepackage{draftwatermark}
\usepackage{datetime}
\ddmmyydate
\SetWatermarkLightness{.9}
\SetWatermarkText{Draft\string@\today}
\SetWatermarkScale{.6}

The colour, lightness, font and other attributes of the watermark are configurable. I also used the datetime package to configure the date formatting. Here’s how the output looks like (a page from my thesis draft):


8 comments:

  1. Thanks! question: How to create watermark with two lines, say the date is under the word "draft"?

    ReplyDelete
    Replies
    1. You could try something like

      \SetWatermarkText{\parbox{6em}{\centering Draft\\\today}}

      Delete
    2. o.k. following your suggestion I tried

      \SetWatermarkText{\parbox{6em}{\textcolor{cyan}{\centering DRAFT\\\today}}}

      and it works perfect. Thanks again :)

      Delete
    3. You're welcome. You can also do

      \SetWatermarkColor{cyan}

      instead of using a \textcolor in the watermark text. Makes the code a little more readable. :)

      Delete
  2. You will have incorrect spacing with

    {\textcolor{cyan}{\centering DRAFT\\\today}}}

    Changing to

    \SetWatermarkText{\parbox{6em}{\centering\textcolor{cyan}{DRAFT\\\today}}}

    will resolve it.

    ReplyDelete
    Replies
    1. Indeed, this makes the spacing better. Thank you.

      Delete
  3. How can I change '7. August 2015' into '7/08/2015'?

    ReplyDelete
    Replies
    1. Have a look at the datetime (now obsolete) or datetime2 (this one's newer) packages.
      e.g. you might use
      \usepackage{datetime}
      \ddmmyydate

      If using datetime2, you'll need to call \DTMsetstyle instead:

      \usepackage{datetime2}
      \DTMsetstyle{ddmmyyyy}

      Delete