I have a very similar problem mentioned here. But I like to put a tikz logo with transparency in the heading of the document using fancyhdr.
If I compile the example below by enabling any of the two options I get what I want. My question are:
- Why do I need such a "workaround"?
- If I need a workaround can I put it somehow in the tikz picture, or in the command that inserts the logo?
Thank You!
\documentclass[a4paper,12pt]{article}
\usepackage{fancyhdr}
\usepackage{tikz}
\setlength\headheight{ 1.5 cm}
\pagestyle{fancy}
\fancyhf{}
\rhead{\insertlogo}
\newcommand{\insertlogo}{%
\begin{tikzpicture}[y = 0.1cm, x = 0.1cm]%
\fill[fill=green, rounded corners=1] (1,2) rectangle +(20,7);
\fill[fill=red, rounded corners=1, opacity=0.3] (-1,2) rectangle +(24,7);
\end{tikzpicture}%
}%
\begin{document}
A
% Option 1: the logo is inserted also in the text -> it is OK
%\insertlogo
% Option 2: the document has two or more pages -> it is OK again
%\newpage
\end{document}
EDIT:
@percusse: Thank You for your solution. It works nice but to tell you the whole story. I like to make the colors of the logo configurable depending on the second argument (b - black and white, c - color, s - shaded) of the "insertlogo" command further more I like to make it scale-able (first argument), I provided only a minimum working example but in this case I like to extend it. Can I use your solution in this case?
Thanks again!
\newcommand{\insertlogo}[2]{%
% check if black and white selected
\definecolor{logowhite}{RGB}{255,255,255}
\definecolor{logoblack}{RGB}{ 0, 0, 0}
\newif\ifblackandwhite
\newif\ifshaded
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\if b#2
% define colors for black and white
\definecolor{logogrey} {RGB}{255,255,255}
\definecolor{logoyellow} {RGB}{ 0, 0, 0}
\blackandwhitetrue
\else
\if s#2
\shadedtrue
\fi
% define colors
\definecolor{logogrey} {RGB}{178,180,182}
\definecolor{logoyellow} {RGB}{210,210, 40}
\fi
% draw scale box
\scalebox{#1}{%
\begin{tikzpicture}[y = 1cm, x = 1cm]%
\ifshaded
%clip bounding box in case of shading because it needs more space
\clip[rounded corners=15](1.0,-2.7) rectangle +(23.0,6.5);
\fi
\ifblackandwhite
% draw outer border
\draw[draw=black, line width=0.1, rounded corners=15] (1.0,-2.7) rectangle +(23.0,6.5);
\fi
% draw outer backround
\fill[fill=logogrey, rounded corners=15] (1.0,-2.7) rectangle +(23.0,6.5);
\ifshaded
% draw inner backround
\fill[fill=logoyellow, opacity=0.3, rounded corners=15] (1.0,-1.4) -- +(0,5.2) -- +(23.0,5.2) -- +(23.0,0) -- cycle;
\else
% draw inner backround
\fill[fill=logoyellow, rounded corners=15] (1.0,-1.4) -- +(0,5.2) -- +(23.0,5.2) -- +(23.0,0) -- cycle;
\fi
% draw text
\draw (15.1,1.0) node {\Huge\color{white}AAA};
\end{tikzpicture}%
}%
}%
Note: I use scalebox because i have text on the logo and it should be scaled too. If you have a better idea I'm open to anything. I'm not a TeXpert. :)
\insertheaderlogo(with the box) and\insertlogo(no box , direct TikZ picture with arguments). And please avoid dimensionless numbers if you don't want funny surprises :) – percusse Sep 12 '13 at 10:25