# How can I mimic the output of syntax macros (\marg, \oarg, etc.) without using the ltxdoc class?

I have come to realize that the pleasant style (argument in italics, enclosed by angle brackets) of macro descriptions in numerous package documentations is actually produced by a number of special commands, such as \marg and \oarg, provided by the ltxdoc document class.

The following screenshot is taken from documentation of the listings package.

How can I produce the same (or similar) result with normal packages (e.g. listings) in, say, the article document class?

-

Plundering existing code goes a long way :)

\documentclass{article}

\usepackage[T1]{fontenc} % for typewriter braces
\usepackage{textcomp}    % for text'' angle brackets
\usepackage{xcolor}

\providecommand\meta[1]{\textlangle{\itshape #1\/}\textrangle}

% directly taken from ltxdoc.dtx
\providecommand\marg[1]{%
{\ttfamily\char\{}\meta{#1}{\ttfamily\char\}}}
\providecommand\oarg[1]{%
{\ttfamily[}\meta{#1}{\ttfamily]}}

% directly taken from listings.dtx (lstdoc.sty)
\definecolor{darkgreen}{rgb}{0,0.5,0}
\def\rstyle{\color{darkgreen}}


Thanks, :-) This works just fine. Although I cannot completely understand the code. But I will firstly search for what I do not know by myself. Moreover, I have found an easier solution provided by @LeoLiu (but not on SE site): Use listings package, and set \lstset{basicstyle=\ttfamily,moredelim=[s][\normalfont\itshape]{<}{>}}. – Naitree May 3 '14 at 14:08