Creating a boxed output with macro style

I'm trying to get a specific output and for now it's not as I wish.

Desired output:

It's for a TugBoat article. For now I have this solution :

    \documentclass{ltugboat}
\usepackage{fancyvrb}

\begin{document}
Some text
\begin{Verbatim}[frame=single]
\actsymb[<ll>][<ul>]{<symbol>}{<lr>}[<ur>]
\end{Verbatim}
\end{document}


Actual output:

2 Answers

fancyvrb allows you to escape to regular LaTeX macros inside the verbatim content. This is described nicely in the manual.

\documentclass{ltugboat}
\usepackage{fancyvrb}

\newcommand\param[1]{\textrm{$\langle$\textit{#1}$\rangle$}}

\begin{document}
Some text
\begin{Verbatim}[frame=single,commandchars=+]
\actsymb[+param(ll)][+param(ul)]{+param(symbol)}{+param(lr)}[+param(ur)]
\end{Verbatim}
\end{document}


• Tks, it's perfect! – David Beauchemin Jul 19 '17 at 0:00
• The ltugboat class provides \meta for your hand made \param. – egreg Jul 19 '17 at 12:09

Using verbatimbox with a little \catcode magic sprinkled on top. In doing it this way, the verbatim input needs no escape characters, but is instead put in directly as (in this case) \actsymb[<ll>][<ul>]{<symbol>}{<lr>}[<ur>].

\documentclass{article}
\usepackage{verbatimbox}
\catcode>=\active %
\catcode<=\active %
\def\openesc{\itshape\rmfamily$\langle$}
\def\closeesc{\/$\rangle$\upshape\ttfamily}
\def\vbdelim{%
\catcode<=\active %
\catcode>=\active %
\def<{\openesc}%
\def>{\closeesc}%
}
\catcode>=12 %
\catcode<=12 %
\begin{document}
\begin{verbbox}[\vbdelim]
\actsymb[<ll>][<ul>]{<symbol>}{<lr>}[<ur>]
\end{verbbox}
\fbox{\theverbbox}
\end{document}