TransWikia.com

TikZ: Contents of scope not visible in tikzpicture when using option overlay

TeX - LaTeX Asked by d8xa on March 12, 2021

I’m trying to draw an arrow with opacity=.35, but the shapes are overlapping, which makes the opacity stack.

I tried the solution of How can I draw a semi-transparent arrow in TikZ without internal overlap?.
But it doesn’t work for me, because I’m using tikzpicture with the option overlay.

MWE:

documentclass[varwidth, border=50]{standalone}
usepackage{tikz}
usetikzlibrary{arrows.meta}
begin{document}

tikzset{->/.style={ultra thick, -{.Latex}, blue}}

begin{tikzpicture}[overlay]
    draw[->, opacity=.35] (0,.5) -- (1,0.5);
    begin{scope}[opacity=.35]
        draw[->] (0,0) -- (1,0);
    end{scope}
    begin{scope}[transparency group, opacity=0.5]
        draw[->, red] (0,-0.5) -- (1,-0.5);
    end{scope}
end{tikzpicture}

end{document}

The third arrow doesn’t show up.
In fact, none of the scope’s content shows, when using overlay and transparency group together. When I remove either of those options, the scope contents are visible again.

Why is the scope not visible, and how can I make it visible?

Edit: Apparently the problem is known, and the manual suggests as a workaround to place the contents in a transparencygroup within a tikzpicture within a node. Like this:

node[left] at (1.15,-0.5) {
        begin{tikzpicture}
            pgfsetfillopacity{0.35}
            pgftransparencygroup
            draw[->, red] (0,-0.5) -- (1,-0.5);
            endpgftransparencygroup
        end{tikzpicture}
    };

The major drawback to this workaround is, that it requires manually adjusting the placement, which kinda defeats the purpose of using TikZ.
Does anyone know a better way?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP