I'd like to
- put two minted source code blocks in two beamer columns
- with arrows pointing between the two (tikzmark-based)
- and use adjustbox to scale the code blocks down to columnwidth
This works ok without adjustbox (based on Is it possible to use tikzmark inside minted? and Drawing overlay graphics over minted code, mostly). See the first frame in the sample below.
However, when surrounding the minted blocks with adjustbox/varwidth environments for scaling, the tikzmarks appear to be off and store wrong positions (which make intuitive sense). See second frame in the example below. Putting the second tikzpicture at different places in the frame makes a difference, but all options I tried produced in correct results.
(Side remark: of course these code examples are stupid; just to make the effect pronounced).
Illustration: The first version works, but does not scale the code blocks.
With an adjustbox, the red arrow is all over the place:
\documentclass[ignorenonframetext,nooutline]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\usepackage{minted}
\usepackage{adjustbox}
\usetheme[hideothersubsections]{Goettingen}
\begin{document}
\begin{frame}[fragile]{Minted columns without adjustbox}
\begin{columns}
\tiny
\begin{column}{0.5\columnwidth}
\begin{minted}[frame=lines,linenos=true,autogobble,escapeinside=??]{c}
int main (void)
{
zmq_send (sender, "Some long text to have a wide line", 5, 0); ?\tikzmark{start}?
return 0;
}
\end{minted}
\end{column}
\begin{column}{0.5\columnwidth}
\begin{minted}[frame=lines,linenos=true,autogobble,escapeinside=??]{c}
int main (void)
{
// some comment
// some more comment
?\tikzmark{eend}? zmq_receive (s, buffer, 100, 0);
}
\end{minted}
\end{column}
\begin{tikzpicture}[remember picture]
\draw [overlay, ->, line width=5pt, red] (pic cs:start) -- (pic cs:eend);
\end{tikzpicture}
\end{columns}
\end{frame}
% ------------------------
\begin{frame}[fragile,label={sec:org93808b5}]{With adjust box}
\begin{columns}
\begin{column}{0.5\columnwidth}
\begin{block}{Sender}
\begin{adjustbox}{width=0.35\columnwidth}
\begin{varwidth}{\columnwidth}
\begin{minted}[frame=lines,linenos=true,mathescape=true,escapeinside=??]{c}
int main (void)
{
zmq_send (sender, "Some long text to have a wide line", 5, 0); ?\tikzmark{start1}?
return 0;
}
\end{minted}
\end{varwidth}
\end{adjustbox}
\end{block}
\end{column}
\begin{column}{0.5\columnwidth}
\begin{block}{Receiver}
\begin{adjustbox}{width=0.4\columnwidth}
\begin{varwidth}{\columnwidth}
\begin{minted}[frame=lines,linenos=true,mathescape=true,escapeinside=??]{c}
int main (void)
{
// some comment
// some more comment
?\tikzmark{end2}? zmq_receive (s, buffer, 100, 0);
}
\end{minted}
\end{varwidth}
\end{adjustbox}
\end{block}
\end{column}
\begin{tikzpicture}[remember picture]
\draw[overlay, ->, line width=5pt, red] (pic cs:start1) -- (pic cs:end1);
\end{tikzpicture}
\end{columns}
\end{frame}
\end{document}