8

Is it possible to have a draft watermark only in a \section?

EDIT:

I have in a document more then one \section, and I need the draftwatermark just in some \section. Unfortunately the section with and without the draftwatermark share the page. For example I want the draftwatermark under the text of just one of these sections A,B,C

\documentclass{article}

\usepackage{kantlipsum} % supply mock text

\begin{document}

\section{A}

\kant[2]

\section{B}

\kant[2-4]

\section{C}

\kant[2]

\end{document}
2
  • Welcome to TeX.SX! Would you like to be more precise? Do you want the water on all the pages in the section?
    – egreg
    Commented Oct 10, 2012 at 12:44
  • Thanks! I really love this site! Yes I need the water on all the page of a session. Not on all the page of the document.
    – thewoz
    Commented Oct 11, 2012 at 14:16

4 Answers 4

6

One option would be to use the background package; to have the watermark appear on some pages, you can say something like

\documentclass{article}
\usepackage{background}
\usepackage{lipsum}

\begin{document}

\SetBgContents{}
\section{Test Section Without Draftwatermark}
\lipsum[1-12]
\section{Test Section With Draftwatermark}
\SetBgContents{Draft}
\lipsum[1-12]
\section{Test Section Without Draftwatermark}
\SetBgContents{}
\lipsum[1-12]

\end{document}

The background material (which can be almost anything you want (image, text) with control over the attributes (placement, color, scale, opacity, etc.) and, by default, "Draft" written diagonally, in red and in a large size) will appear on all the pages between \SetBgContents{Draft} and the following \SetBgContenst{}.

To have the watermark to appear only on selected pages, you can use the pages=some package option and then use \BgThispage on the page(s) you want the watermark to appear:

\documentclass{article}
\usepackage[pages=some]{background}
\usepackage{lipsum}

\begin{document}

\section{Test Section Without Draftwatermark}
\lipsum[1-12]
\section{Test Section With Draftwatermark}
\BgThispage
\lipsum[1-12]
\section{Test Section Without Draftwatermark}
\lipsum[1-12]

\end{document}

If the most recent version of the package is not available in your system, the line

\usepackage[pages=some]{background}

has to be replaced with

\usepackage[some]{background}

Here's an example that manually places the "Draft" mark only for section two:

\documentclass{article}
\usepackage{background}
\usepackage{lipsum}

\begin{document}

\SetBgContents{}
\section{Test Section Without Draftwatermark}
\lipsum[1-6]
\section{Test Section With Draftwatermark}
\backgroundsetup{contents=Draft,scale=4,position={2,-3.5},opacity=1}
\lipsum[1-6]
\section{Test Section Without Draftwatermark}
\backgroundsetup{contents=Draft,scale=4,position={2,-1.4},opacity=1}
\lipsum[1-3]
\SetBgContents{}
\lipsum[1-2]

\end{document}

enter image description here

3
  • 1
    thanks for the answer, but doesn't work if a session with the background and one whiteout are in the same page. I just able to have or all the pages whit the Draftwatermark or just some. but not just in one section.
    – thewoz
    Commented Oct 11, 2012 at 14:18
  • @thewoz well, you can always use \BgThispage or \NoBgThispage to add or suppress the background material for seclected pages, or use \clearpage before and after the section with the mark. Commented Oct 11, 2012 at 15:45
  • @thewoz please see the last example code in my updated answer; process the document three times to see the mark just for section two. Is it something like this what you need? Commented Oct 11, 2012 at 16:48
4

An upload to xwatermark has been made. You would need version 1.5.2c of the package to get this to work.

\documentclass{article}
\usepackage{xwatermark}[2012/10/14]
\usepackage{xcolor}
\usepackage{lipsum}

\newwatermark[allpages]{DRAFT}

\begin{document}
\section{Test section without draftwatermark}
\xwmwatermarkoff
\lipsum[1-6]
\section{Test section with draftwatermark}
\xwmwatermarkon
\lipsum[1-6]
\section{Test section without draftwatermark}
\xwmwatermarkoff
\lipsum[1-20]
\section{Test section with draftwatermark}
\xwmwatermarkon
\lipsum[1-2]
\end{document}
1
  • Yeah I try the xwatermark package.. but I need to put the Draftwatermark only within certain sessions.
    – thewoz
    Commented Oct 11, 2012 at 14:21
3

You can define a switch for draftwatermark:

\documentclass{article}
\usepackage{draftwatermark}
\makeatletter
\let\originalsc@watermark\sc@watermark
\newcommand{\draftwatermarkon}{%
  \let\sc@watermark\originalsc@watermark
}
\newcommand{\draftwatermarkoff}{%
  \let\sc@watermark\@empty
}
\makeatother

\usepackage{kantlipsum} % supply mock text

\begin{document}
\draftwatermarkoff % it's on by default

\section{A}

\kant[2-4]

\newpage
\draftwatermarkon

\section{B}

\kant[2-4]

\newpage
\draftwatermarkoff

\section{C}
\kant[2-4]

\end{document}

I wouldn't switch on and off in the middle of a page.

7
  • I of course, but unfortunately I need to switch on and off in the middle of a page. Because my section share the page and I can put the two section in two distinct pages. Is possible do that?
    – thewoz
    Commented Oct 11, 2012 at 15:22
  • @thewoz Yes. Just remove the \newpage commands. However, in the page where the `\draftwatermarkoff appears the watermark won't be present; just move it forward if you need it also in the final page of the draft section. But, since the document is a draft, what's the objection to have the draft section start in a new page?
    – egreg
    Commented Oct 11, 2012 at 15:25
  • The problems is that I have a layout like the example that I have now put in my original question. And I can not change.
    – thewoz
    Commented Oct 11, 2012 at 15:37
  • 1
    @thewoz The problem is: where do you want the watermark? If the draft section starts on page 2 and ends on page 4, where should the watermark be? If you hope to put it automatically only under the text of the draft section, forget it.
    – egreg
    Commented Oct 11, 2012 at 15:39
  • I think that I have to forget it, because that is exactly the problem and what I want. In my example I need the watermark just under the section B that is in two different pages. Or may be just in section A and not in section B that share a page.
    – thewoz
    Commented Oct 11, 2012 at 15:48
0

Have you tried the draftmark package? Draftmark allows putting a watermark on selected pages. While that's not as nice as selecting a \section, it should work in most cases.

1
  • Yes I now.. but unfortunately I need the Draftwatermark in some \section
    – thewoz
    Commented Oct 11, 2012 at 14:22

You must log in to answer this question.

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