I am using Tikz to create nice margin notes, like Gonzalo's answer to create a framed environment for a margin note I added a shadow to these notes with `drop shadow =' followed by a color. It works just fine.
However, these notes sometimes contain a TikZ picture, or a plot obtained with pgfplots
.
But theses figures then have a shadow. Is there any solution to disable the shadow for the inner Tikz picture ?
Here is an example of code with a pgfplots
inside a margin note with unwanted shadow :
\documentclass{article}
\usepackage[lmargin=5cm,textwidth=15cm,marginparwidth=4cm]{geometry}
\usepackage[dvipsnames]{xcolor}
\usepackage{ragged2e}
\usepackage{xparse}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{tikzpagenodes}
\usetikzlibrary{calc}
\usepackage{lipsum}
\usetikzlibrary{shadows}
\usepackage{pgfplots}
\newcounter{mycaution}
\newcommand\pointeranchor{}
\newcommand\boxanchor{}
\newlength\boxvshift
\newlength\uppertrianglecorner
\newcommand\tikzmark[1]{%
\tikz[remember picture,overlay]\node[inner xsep=0pt,outer sep=0pt] (#1) {};}
\NewDocumentCommand{\caution}{O{c}O{BrickRed}O{Caution!}m}{%
\stepcounter{mycaution}%
\tikzmark{\themycaution}%
\renewcommand\pointeranchor{mybox\themycaution.east}%
\renewcommand\boxanchor{east}%
\setlength\boxvshift{0pt}%
\setlength\uppertrianglecorner{3pt}%
\begin{tikzpicture}[remember picture,overlay]
\node[draw=#2,anchor=\boxanchor,xshift=-\marginparsep,yshift=\boxvshift,drop shadow=#2!80!black!50!white,fill=white]
(mybox\themycaution)
at ([yshift=3pt]current page text area.west|-\themycaution)
{\parbox{\marginparwidth}{\vskip10pt\RaggedRight\small#4}};
\node[fill=white,font=\color{#2}\sffamily,anchor=west,xshift=7pt]
at (mybox\themycaution.north west) {\ #3\ };
\end{tikzpicture}%
}
\newcommand\Test{Nulla malesuada porttitor diam. Donec felis erat, congue non, volutpat at, tincidunt tristique, libero. Vivamus viverra fermentum felis. Donec nonummy pellentesque ante. Phasellus adipiscing
semper elit.}
\begin{document}
\lipsum*[4]\caution[t]{\begin{tikzpicture}[]
\begin{axis}[xmin=-1,xmax=2,ymin=0.4,ymax=1.5,width=\marginparwidth,axis lines=middle,xtick=1,xticklabels=$a$,ytick=\empty]
\addplot[red,mark=none,domain=-1:1]{1};
\addplot[red,mark=none,domain=1:2]{x-0.5};
\end{axis}
\end{tikzpicture}}\lipsum[3]\par
\end{document}
pgfplots
or thetikzpicture
before puting it in the margin note.pgfplots
inheriting it?tikzpagenodes
(I don't have it), there is no shadow for the plots.