1

Hold your horses!. If you are hurrying to flag this as a duplicate of this question or this question none of those have an answer to what is asked here. Thanks for the attention though.

I have an .eps image (the idea is to keep this image and don't change it's format to a .png for example), that I am setting as background for a project with the background package:

\documentclass{article}
\usepackage{tikz}
\usepackage{background}
\backgroundsetup{
angle=0,
scale=1,
opacity=0.2,
contents={\tikz[remember picture,overlay,shift=(current page.center)] \node[inner sep=0pt] at (8,-10){\includegraphics[scale=1]{Cube.eps}};}}
\begin{document}
\null
\end{document}

The original image is (have it here with black background): Original

And the result setting the opacity in both the background setup and tikz node options is the following:

Result

I created the image with InkScape and I actually set the "color layers" as unmasked by the opacity command in order to make the color gradient. Obviously this is not the desired result, what is expected is something like:

Expected

Is this posible?.

  • there are other questions that we can close this with but check the transparency group section on TikZ manual. Without the image it's hard to say why the output is like that but since this is a pretty straightforward image why don't you just redraw it with TikZ? – percusse Feb 26 '15 at 0:44
  • @percusse would it help at all if I provide the image file?. Actually, If you have the file now, you may notice that it would take time to redo the image. – Hans Feb 26 '15 at 0:52
  • The problem is with the file, not backgroundsetup. The gradations in that region are achieved by placing several strips together, which overlap and appear darker. – erik Feb 26 '15 at 1:29
  • @erik Thanks for participating, the problem is that tikz is opacifying my image layer by layer (let's say) not as a complete set. And, yes sir, the strips are overlapping together in the original image, but then once again, tikz is opacifying them one by one and not as a whole set. – Hans Feb 26 '15 at 1:32
  • Please post complete, compilable code. A mere fragment is annoyingly unhelpful. – cfr Feb 26 '15 at 1:54
2

You may convert your EPS picture to PDF via inkscape : open Cube.eps then "save as..." Cube.pdf.

enter image description here

\documentclass{article}
\usepackage{tikz}
\usepackage{background}

\backgroundsetup{
  angle=0,
  scale=1,
  opacity=.5,
  contents={
    \begin{tikzpicture}[remember picture,overlay,shift=(current page.center)]
      \node[inner sep=0pt]{\includegraphics[scale=1]{Cube}};
    \end{tikzpicture}
  }
}
\begin{document}
\null
\end{document}
  • Paul, thank you so much, this works, but the idea is not to change the image format (not to .png, .jpg, .svg, .pdf or anything). (Anyway, this completely works and if no one knows how to deal with it I will accept your answer, but take into account that the deal now is to make tikz to recognize the picture as a whole set and opacify it all together). – Hans Feb 26 '15 at 1:53
  • @Hans Why? Why is that the idea? Note that you have a range of choices here: (1) correct the image, (2) process the uncorrected image in a way which does the correction (e.g. convert in Inkscape), (3) fake the transparency, (4) put up with the current situation, (5) ??? – cfr Feb 26 '15 at 2:23
  • @cfr Honestly, I am thinking in an answer that don't make you mad, but think on a chaotical situation, you do not have inkscape by example and you cannot installed right now, then you just go to <a href="tex.stackexchange.com"> tex stackexchange</a> and look for the solution. So in that situation: not able to correct the image (someone else sent you that), cannot converted to other format, cannot fake transparency (you have colored pages), all you have is this forum. – Hans Feb 26 '15 at 2:37
  • @Hans I'm not mad (in either sense, as far as I know, though I hear it is impossible to tell regarding one of them). If none of (1)-(4) are options, the only one left is (5) recreate the image. The image has that feature with the overlapping. If not even conversion is an option, you really don't have much choice. – cfr Feb 26 '15 at 2:56
1

If you really don't want to change it, you can fake it.

\documentclass{article}
\usepackage{graphicx,background,tikz,kantlipsum}
\backgroundsetup{
  angle=0,
  scale=1,
  opacity=1,
  position={current page.center},
  hshift=80mm,
  vshift=-100mm,
  contents={%
    \includegraphics{Cube}
    \tikz[remember picture, overlay]{\path [fill=white, fill opacity=.8] (current page.south west) rectangle (current page.north east);}
  },
}

\begin{document}

  \kant[1-10]

\end{document}

fake transparency

Note that if you are compiling with, say, pdfTeX, then the image is being converted regardless because .eps cannot be used otherwise.

EDIT

Here's a way of having a coloured background with the above trickery. Use \papercolor[] to set the colour desired. If the optional argument is omitted, defaults to white.

coloured trickery

\documentclass{article}
\usepackage{graphicx,background,tikz,kantlipsum}
\backgroundsetup{
  angle=0,
  scale=1,
  opacity=1,
  position={current page.center},
  hshift=80mm,
  vshift=-100mm,
  contents={%
    \begin{tikzpicture}[remember picture, overlay]
      \path [fill=my paper color] (current page.south west) rectangle (current page.north east);
      \node {\thepage\includegraphics{Cube}};
      \path [fill=my paper color, fill opacity=.8] (current page.south west) rectangle (current page.north east);
    \end{tikzpicture}
  },
}
\newcommand*\papercolor[1][white]{\colorlet{my paper color}{#1}}
\papercolor

\begin{document}

  \kant[1-4]
  \papercolor[black!10]
  \kant[5-8]
  \papercolor[blue!25]
  \kant[9-11]
  \papercolor
  \kant[12]

\end{document}
  • Thanks @cfr, I thought about it but I dropped the idea, because this can happen (By the way, I'm trying a black background just as an example). – Hans Feb 26 '15 at 2:29
  • I do have colored pages, by the way. – Hans Feb 26 '15 at 2:36
  • @Hans Of course, you have to change the fill colour to match the colour of the background. white is just an example. If the background is black, you need to use black. – cfr Feb 26 '15 at 2:58
  • Oh, ok. Is there a command to recognize the page color? so I can like fill=\pagecolor or something? – Hans Feb 26 '15 at 3:03
  • @Hans I'm not sure. How are the pages getting coloured? – cfr Feb 26 '15 at 3:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.