1

I'm trying to define a box in a page (the title page indeed) that should appear as 'transparent' over the page background (that's a .jpg picture).

The code I'm using is the following:

\documentclass[dvipsnames,a5paper,twoside,openright,italian,12pt]{memoir}   
\usepackage{defines}    
\author{The author}
\date{2016}
\title{The title}
\editor{The editor}
\begin{document}
\frontmatter 
\mytitle
\tableofcontents
\include{Preface}
\mainmatter
\include{Chapter01}
\include{Chapter02}   
\end{document}

Inside 'defines.sty' I defined the structure and commands:

\usepackage[utf8]{inputenc} 
\usepackage[italian]{babel}
\usepackage[T1]{fontenc} 
\usepackage{verse}
\usepackage{background}
\usepackage[object=vectorian]{pgfornament}
\usepackage{svg}
\usepackage{wallpaper}
\usepackage[osf]{libertine}

\usetikzlibrary{calc}

\backgroundsetup{
    contents={
        \if@mainmatter 
            \eachpageornament \thepage
        \else
            \ifnum\value {page}=1 
            \else 
                \eachpageornament \thepage
            \fi
        \fi
    },
    position=current page.north east,
    angle=0,%
    scale=1,%
    opacity=0.5%
}

\newcommand{\editor}[1]{\def\@editor{#1}}

\newcommand{\theeditor}{%
    \@editor
}

\newcommand{\eachpageornament}{
    \begin{tikzpicture}[remember picture, overlay, color=LimeGreen]
    \node[anchor=north west](CNW) at (current page.north west){
        \pgfornament[width=2cm]{61}};
    \node[anchor=north east](CNE) at (current page.north east){
        \pgfornament[width=2cm,symmetry=v]{61}};
    \node[anchor=south west](CSW) at (current page.south west){
        \pgfornament[width=2cm,symmetry=h]{61}};
    \node[anchor=south east](CSE) at (current page.south east){
        \pgfornament[width=2cm,symmetry=c]{61}};
    \pgfornamenthline{CNW}{CNE}{north}{87}
    \pgfornamenthline{CSW}{CSE}{south}{87}
    \pgfornamentvline{CNW}{CSW}{west}{87}
    \pgfornamentvline{CNE}{CSE}{east}{87}
    \end{tikzpicture}
}

\newcommand{\plogo}{\includegraphics[width = 30mm]{logo.png}}

\newcommand{\psignature}{
    \begin{flushright}
        \def\svgwidth{40mm}
        \input{signature.pdf_tex}
    \end{flushright}
}

\newcommand{\mytitle}{
    \thispagestyle{empty}
    \ThisCenterWallPaper{1.12}{sfondo}

    \begin{tikzpicture}[remember picture, overlay]
    \node [rectangle, rounded corners, fill=LimeGreen, opacity=0.75, anchor=south west, minimum width=6cm, minimum height=8cm] (box) at (-0.5,-10) (box){};
    \node[anchor=west, xshift=-2.0cm, yshift=-1cm, text width=4cm] at (box.north){\large \textit{\theeditor}}; 
    \node[anchor=west, xshift=-2.0cm, yshift=-3.5cm, text width=4cm] at (box.north){\huge \thetitle};
    \node[anchor=west, xshift=-2.0cm, yshift=-6cm, text width=4cm] at (box.north){\large \theauthor};
    \end{tikzpicture}

    \newpage
}

\pagestyle{plain}

\setcounter{tocdepth}{2}
\renewcommand{\poemtoc}{section}%
\renewcommand{\poemtitlefont}{\normalfont\large\itshape\centering}

This node instance should define a green rounded box with 75% opacity:

\node [rectangle, rounded corners, fill=LimeGreen, opacity=0.75, anchor=south west, minimum width=6cm, minimum height=8cm] (box) at (-0.5,-10) (box){};

But as long as I can see the box is filled with solid green...

The original template were I took the suggestion can be found at the following link: book sample

Of course it's working... but as far as I can see there are no differences with mine that would change the behavour of the box.

weirdgyn
  • 163

1 Answers1

2

The package transparent, automatically loaded by the package svg conflicts with TikZ opacity key.

You may:

  1. Unload the svg package so that TikZ opacity will work as expected
  2. Unload the transparent package, which is the real source of the conflict by issuing \expandafter\def\csname ver@transparent.sty\endcsname{}¹ before loading svg (this may cause the svg package to misbehave)
  3. use the \transparent macro instead of Tikz opacity key, like this:

     {\transparent{0.5}\node [rectangle, rounded corners, fill=LimeGreen, anchor=south west, minimum width=6cm, minimum height=8cm] (box) at (-0.5,-10) (box){};}
    

The grouping outside \transparent prevents the macro to be applied to the whole tikzpicture

¹see also svg package interfers with opacity

d-cmst
  • 23,095
  • I tried that .. but it's not working... no errors but it just renders the same way it did previously. I can try using a bitmap instead the .svg file but it's not a quality solution. – weirdgyn Aug 18 '16 at 20:50
  • @weirdgyn it does not work with the \transparent macro (solution 3)? It works here, I can see the correct opacity. – d-cmst Aug 18 '16 at 20:54
  • @weirdgyn I just discovered that you may need two consecutive compilation so that \transparent{0.5} works. Try compiling twice. – d-cmst Aug 18 '16 at 20:59
  • yeah.... quite strange anyway.... :-) – weirdgyn Aug 18 '16 at 21:05
  • the same problem apply also on the background (decorations) of all pages (besides title of course). How can I apply \transparent to \backgroundsetup directive? – weirdgyn Aug 18 '16 at 21:12
  • add another instance of \transparent into the \eachpageornament tikzpicture. This time you don't need grouping – d-cmst Aug 18 '16 at 21:23
  • 1
    svg now provides an option notransparent (or usetransparent=false) to disable the loading of the transparent package. – schtandard Apr 18 '18 at 17:32