3

I would like to use Henri Menke's answer from another question with beamer. Unfortunately the tikzpicture is not visible. As pointed out here this is because the tikzpicture is behind beamer's background. So it would become visible when making the background transparent \setbeamercolor{background canvas}{bg=}. But this slide is supposed to have the same beamer background like all other slides, too.

How can I position the tikzpicture behind the minted text but on top of the beamer background?

\documentclass{beamer}

\usepackage{minted}
\newminted{latex}{linenos, frame=lines, autogobble, breaklines}

\usepackage{tikz}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture,baseline=(#1.base)] \node (#1) {\vphantom{I}};}

\usepackage{eso-pic}

\newcommand{\colorPreamble}{blue!10}
\newcommand{\colorDocument}{green!10}

\begin{document}

\begin{frame}[fragile]
    \twocolumn
    \begin{latexcode*}{escapeinside=||}
        |\tikzmark{n}|\documentclass{article}

        [...]
        |\tikzmark{c}|
        \begin{document}
            [...]
        |\tikzmark{s}|\end{document}
    \end{latexcode*}
    \AddToShipoutPictureBG*{%
        \begin{tikzpicture}[remember picture, overlay]
            \path[overlay, fill=\colorPreamble] (n.north) rectangle ([xshift=\linewidth] c.south);
            \path[overlay, fill=\colorDocument] (c.south) rectangle ([xshift=\linewidth] s.south);
        \end{tikzpicture}
    }
    \twocolumn
\end{frame}

\end{document}
3

I cannot test with minted, but I think you can simply add the tikz picture to beamers own background mechanism instead of using eso-pic.

\documentclass{beamer}

\usepackage{tikz}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture,baseline=(#1.base)] \node (#1) {\vphantom{I}};}

\newcommand{\colorPreamble}{blue!10}
\newcommand{\colorDocument}{green!10}

\begin{document}

{
    \addtobeamertemplate{background canvas}{}{%
        \begin{tikzpicture}[remember picture, overlay]
        \path[overlay, fill=\colorPreamble] (n.north) rectangle ([xshift=\linewidth] c.south);
      \path[overlay, fill=\colorDocument] (c.south) rectangle ([xshift=\linewidth] s.south);
    \end{tikzpicture}
    }
    \begin{frame}[fragile]
            \tikzmark{n}
            [...]

            \tikzmark{c}
            [...]

            \tikzmark{s}
    \end{frame}
}

\begin{frame}
content...
\end{frame}
\end{document}

enter image description here

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.