Create a window around a shape that includes a tab environment

I would like to create a frame or window around my LaTeX shape, which consists of code formatted in a tab environment. My code looks something like this:

\begin{figure}
\begin{tabbing}
\texttt{void method(I, T, E)} \{ \\
\ \ \texttt{some code}<\emph{some pseudo code}>();\\
...
\end{tabbing}
\caption{The caption for the figure}
\end{figure}

I tried to use various box and frame commands, both inside and without a shape, but LaTeX usually answers “Something is wrong - maybe the missing element” or “Not in external pair mode”.

How to create a field around the contents of my figure?

Thank!

+3
source share
1 answer

One way is to use the packagemdframed . It is quite customizable, I defined a style to illustrate its use:

enter image description here

\documentclass{article}
\usepackage{xcolor}
\usepackage{mdframed}

\mdfdefinestyle{mystyle}{
    backgroundcolor=yellow!20
}

\begin{document}
\begin{figure}
\begin{mdframed}[style=mystyle]
\begin{tabbing}
\texttt{void method(I, T, E)} \{ \\
\ \ \texttt{some code}<\emph{some pseudo code}>();\\
...
\end{tabbing}
\caption{The caption for the figure}
\end{mdframed}
\end{figure}
\end{document}
+3
source

Source: https://habr.com/ru/post/1796295/


All Articles