26

I have a problem using opacity in TikZ. Whenever I use it somewhere in a picture, I get weird side-effects: colors in (some) other parts of the documents are changed apparently randomly and it makes the text look semi-bold and somewhat blurry.

I only see this effect in Acrobat. Other pdf viewers I tried display the document correctly.

Caramdir
  • 89,023
  • 26
  • 255
  • 291
DaveM
  • 361
  • Have you checked with other pdf readers (eg. evince instead of acrobat)? Usually they are the problem (see http://tex.stackexchange.com/questions/141/why-are-some-pages-in-my-pdf-coming-out-bold and http://tex.stackexchange.com/questions/1915/tikz-strange-color-change). Otherwise, could you please post or link to an example. – Caramdir Jan 19 '11 at 06:29
  • Now I'm feeling pretty stupid :-( I should have tried another reader earlier and saved myself some aggravation. Acrobat is the culprit - it doesn't seem well-suited to Linux (has a tendency to crash my OS) but it seems to be the only browser that handles DLJS stuff when I use the acrotex package. Thanks very much! – DaveM Jan 19 '11 at 06:54
  • @DaveM: So is this solved, then? If so, in the spirit of housekeeping, I'll close as "no longer relevant". – Andrew Stacey Jan 19 '11 at 09:52
  • 1
    @Andrew: This this question now has a real solution, I'd rather close similar questions as duplicates of this (maybe after some rewriting of this question to make it more general). – Caramdir Jan 19 '11 at 17:03
  • @Caramdir: It wasn't clear from DaveM's comment about whether or not "Don't use acrobat" was the answer or if prettygully's fix was correct. If someone can verify that fix, then I would support editing the question so that that answer is correct! (For example, there's no mention of acrobat in the question.) – Andrew Stacey Jan 19 '11 at 18:04
  • @Andrew: Yes, with the fix acrobat renders correctly (at least Acrobat 9 on Ubuntu 10.10 does so with the one file I tested...) – Caramdir Jan 19 '11 at 20:09
  • @Caramdir: In that case, the question should be edited to make it clear that this is actually a question about acrobat. As I don't use and don't have acrobat, I'm not the best person to do so. – Andrew Stacey Jan 20 '11 at 07:43
  • @Andrew: I rewrote the question to be more general. – Caramdir Jan 20 '11 at 18:58
  • @Caramdir: Great, that looks much clearer. Thanks. – Andrew Stacey Jan 20 '11 at 21:52
  • 1
    Quite surprising that people with sufficient discrimination to choose TeX and LaTeX are prepared to tolerate the bloatware that is Acrobat... (:-) – Brent.Longborough Jan 22 '11 at 22:07
  • Apologies for my noobient bad housekeeping. Yes, the issue is resolved by using evince or xpdf; the problem is with the Adobe reader. I've looked around the site and haven't noticed anything about closing a question; how should I do this in future? – DaveM Jan 23 '11 at 03:34
  • Regarding the comment about bloatware and Acrobat: I frequently use the acrotex package for creating math quizzes. Acrotex uses document level javascript to create buttons, mark solutions, etc. As far as I know, it is only Adobe products that can handle this. – DaveM Jan 23 '11 at 03:38
  • Possible duplicate: http://tex.stackexchange.com/q/16061/5763 – Martin Schröder Dec 15 '11 at 23:24

3 Answers3

29

Try inserting:

\pdfpageattr{/Group <</S /Transparency /I true /CS /DeviceRGB>>} 

into your preamble. I had a problem with some colours being way too bright in acrobat reader (but not in other pdf viewers) when using opacity < 1 and this fixed it for me.

prettygully
  • 1,629
6

I had this exact same problem. The solution posted by prettygully only works with pdfTeX / pdfLaTeX. If you use XeTeX / XeLaTeX you can put this modified version in your preamble instead:

\usepackage{everypage}
\AddEverypageHook{%
  \makeatletter%
  \special{pdf: put @thispage <</Group << /S /Transparency /I true /CS /DeviceRGB>> >>}%
  \makeatother%
}%

This was inspired by is-there-a-way-to-rotate-all-pages-in-xelatex and inkscape-pdf-includegraphics-xelatex-changed-colors.

llude
  • 161
  • 1
  • 3
4

If you are using pdflatex, inserting

\pdfpageattr{/Group <</S /Transparency /I true /CS /DeviceRGB>>}

in the preamble indeed works.

However, if you use latex > dvips > ps2pdf, this workaround will not work, since the pdf page attributes are ignored by latex. The issue is also described in the ghostscript manual:

ps2pdf currently has only very limited support for PDF 1.4. It writes out the blend mode, constant alpha, and text knockout graphics state parameters, and it handles images with soft masks, but it does not handle transparency groups, or soft masks in the graphics state.

Interestingly, the solution is as simple as using ps2pdf13. This way, you create a PDF v1.3 compliant pdf file which seems to work as expected. So far, we did not notice any side effects.

dhaumann
  • 186