1

Some time ago at the link Transparent foreground watermark, I learned from Gonzalo Medina's answer how to make transparent water maker with the package xwatermark. And it was awesome.

On the other hand, I learned about the usage of \usepackage[T1]{fontenc} to enable some features with accented characters, which is indeed very useful for me, a Portuguese LaTeX user.

First I thought [T1] fonts was useless and it only make the font looks ugly (big pixels), but than I found the others usages at Why should I use \usepackage[T1]{fontenc}?. I could finally copy and paste characters from the PDF, which is indeed useful. The solution for the "ugliness" came from the package lmodern in Is it still useful to load the lmodern package?.

And this point I was quite happy with the features but never had to use them together. Until last week when I used the transparent xwatermark, which is made using TikZ, in combination with [T1]{fontenc} and lmodern and then I realized the "ugliness" came back.

At first glance I thought it could be some issue from the packages xwatermark or TikZ. But it doesn't seem to be the case. The tikzpicture environment and the \newwatermark command of Example 2 in the MWE below led me to this hypothesis. The \newwatermark in Example 1 shows the "ugliness" issue. Maybe it is something related to the \newsavebox but I didn't find anything that could have helped me.

I would like to know why this happens and also if there is some solution to good looking water marks alongside the features from the package fontenc.

A MWE with both approaches is given below.

\documentclass{article}

% -------------------------
%\usepackage[latin1]{inputenc} % Problem is independent from latin1 or utf8
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} % Enables Copy and Paste of special characters
\usepackage{lmodern} % Makes [T1] letters pretty again
% -------------------------

% ========== 
\usepackage{lipsum}
\usepackage{tikz} % No PSTRICKS solutions please
\usepackage[printwatermark]{xwatermark}
% ========== 

% ========== Example 1 
% Source: https://tex.stackexchange.com/questions/132582/transparent-foreground-watermark
% It has opacity. The text behind is readable but loses quality when used with [T1]]{fontenc} and {lmodern}
% ----------
\newsavebox\myboxb\savebox\myboxb{\tikz[color=blue!80,opacity=0.4]\node{\huge{Example 1}};}
\newwatermark*[allpages, angle=45, scale=7, xpos=-20, ypos=+060]{\usebox\myboxb}

% ========== Example 2
% It has no opacity. The text behind is not always readable and it never loses quality regardless of [T1]]{fontenc} and {lmodern}
% ----------
\newwatermark*[allpages, color=blue!80, angle=45, scale=7, xpos=-10, ypos=-30]{\huge{Example 2}}
% ========== 

\begin{document}
\section{Título -- Title}

Characters to test copy and paste: áéíóú, ãõ, âêô, à, äöü.

\lipsum[1]

\begin{tikzpicture}
    \draw[dashed] (0,0) node[below]{$x$ -- There is no problem between TikZ and [T1]fontenc} -- (0,1)node[above]{\huge{Example Ti\textit{k}Z} works fine};
    \node at (3,0.5) {\Huge{Direct Node}};
\end{tikzpicture}

\lipsum[2]

\end{document}

The first figure show the whole PDF and the second shows the zoom into the letters.

enter image description here

enter image description here

1 Answer 1

2

You are saving the box with the text in the preamble. At this time the fonts are not yet setup.

Better move this behind \begin{document}:

\newsavebox\myboxb\savebox\myboxb{\tikz[color=blue!80,opacity=0.4]\node{\huge{Example 1}};}

You should also install with the package manager of your tex system the cm-super package. Then you will get type1 fonts also without lmodern.

4
  • Thank you very much Mrs. Fischer. It worked. I would never imagine the definition of \newsavebox should be after \begin{document}.
    – FHZ
    Commented Nov 4, 2019 at 15:41
  • I installed the package cm-super. With this package I got good looking fonts whether I placed the command \newsavebox i.e., after or behind the \begin{document}. Placing it before \begin{document} seems much better to keep my text code organized. Thanks once again.
    – FHZ
    Commented Nov 4, 2019 at 17:30
  • if you put the newsavebox in the preamble your example 1 will use a different font. With lmodern this is not noticable as lmodern and cm are quite similar, but try with \usepackage[default]{roboto} instead of lmodern. Commented Nov 4, 2019 at 17:34
  • Ok. I tested and it happened what you said. The combinations are very clear now.
    – FHZ
    Commented Nov 4, 2019 at 17:59

You must log in to answer this question.

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