Context: I'm trying to use Asymptote to draw explanatory arrows and comments atop a semitransparent lstlisting environment. In the course of doing so I've encountered a bizarre interaction between Asymptote and the package transparency that I've reduced to a minimal working example. I'm using LuaLaTeX but can reproduce in pdfLaTeX too.
For reasons not understood to me, an Asymptote asy environment will sometimes, though not always, almost completely disable transparency inside and outside and both fore and aft of the \begin{asy} ... \end{asy} block. Here's the MCVE example.
\documentclass{article}
\usepackage{asymptote}
\usepackage{transparent}
\begin{document}
\section{Before Asymptote}
{\transparent{0.1}Ghost X}
\section{In Asymptote}
\begin{asy}
if(false){ //TOGGLE THIS
label("x");
}else{
draw((0cm,0)--(1cm,0));
}
\end{asy}
\section{After Asymptote}
{\transparent{0.1}Ghost X}
\end{document}
There is an if statement with a toggle inside, currently false. When it is set to false, I get ghostly text before and after the asy drawing:
However, if I set the toggle to true, I don't:
Note how both the text before and after is no longer transparent.
Variants I've tested:
- The contents of the label are irrelevant.
- Wrapping
asyin afigureorminipagedoes not contain the disease. - Nor does adding
\pdfpageattr{/Group <</S /Transparency /I true /CS /DeviceRGB>>}in the preamble or any other incantations as suggested here. - Both TeXStudio's embedded viewer and KDE's Okular show this, so it's not a peculiarity of the PDF viewer.
- I've also just tried
texpreamble("\usepackage{transparent}");andlabel("{\transparent{0.1}x}");and got the same results for both toggles, and $x$ was not transparent. - When you set the toggle to
trueand do bothlabel("x");anddraw((0cm,0)--(1cm,0), opacity(0.1));in theif-side of the branch, you get the same result (transparency disabled fore and aft), but the drawn line is transparent.
Why do only some Asymptote figures trigger spooky-action-at-a-distance and blow up everything else like this? And how can I work around it?



asyblock help at all? – cfr Jan 24 '16 at 23:22figureandminipage, If wrapping withminipagedoesn't sandbox it, it's basically impossible for{}to sandbox it. – Iwillnotexist Idonotexist Jan 24 '16 at 23:36