2

I want to create a command, accepting an argument, which sets the content of the argument as a TikZ picture. Problem: The argument is a minted/FancyVrb environment.

MWE:

%!TEX OPTIONS = --shell-escape
\documentclass{article}
\usepackage{tikz}
\usepackage{minted}
\newcommand{\tikzverb}[1]{\tikz{\node (text) [draw=blue, thick] {#1}; \fill [opacity=0.5] (text.north east) circle (5pt);}}
\begin{document}
\tikzverb{
\begin{minted}{text}
test
\end{minted}
}
\end{document}

Some background: This MWE is boiled down and simplified from a command from my slides, which I set via LaTeX Beamer. I configured minted for source code highlighting, so I'd rather use this package instead of other verbatim environments. In the slides, the command should display bash shell output.
During assembling of this MWE, I found out that using a savebox does not solve the issue, which was usually one of the solutions in other questions like this. A combination of savebox and lstlisting environments works (see also this), but that'd mean another package which needs to be configured separately. I rather stick to minted, if I can (because it's great).

  • 2
    tcolorbox supports minted and making a background box. – TeXnician Aug 19 '17 at 13:57
  • Didn't know tcolorbox. Although it's another abstraction layer on top, let's see how far I come! Thanks! – AndiH Aug 19 '17 at 14:53
2

This does not directly answer my posed question, but the underlying problem (creating a fake bash shell). As suggested by @TeXnician, I use tcolorbox (which indeed is another package with all kind of new commands; but it's quite awesome).

I'm happy with the result: enter image description here

Any further suggestions to improve upon my code?

% \usepackage[minted]{tcolorbox}
% \tcbuselibrary{skins}
\definecolor{topbar}{RGB}{220,220,220}
\definecolor{main}{RGB}{30,30,30}
\definecolor{quit}{RGB}{248,73,73}
\definecolor{min}{RGB}{252,182,37}
\definecolor{max}{RGB}{41,198,52}
\colorlet{offwhite}{white!96!black}
\newtcblisting{fauxshell}{%
  listing engine=minted, 
  minted language=text, 
  title={\strut}, 
  listing only, 
  enhanced, 
  colbacktitle=topbar, 
  boxrule=0cm,
  left=2mm,
  width=\textwidth,
  frame hidden, 
  colback=main, 
  coltext=offwhite, 
  overlay={
    \fill [fill=quit] ([xshift=3mm]title.west) circle (1mm);
    \fill [fill=min] ([xshift=6mm]title.west) circle (1mm);
    \fill [fill=max] ([xshift=9mm]title.west) circle (1mm);
  }%
}
\begin{fauxshell}
$ echo `date`
Mon Aug 21 09:21:35 CEST 2017
\end{fauxshell}

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.