可以看看 lshort-zh-cn
里面的定义:
%
% 命令和环境的写法
%
\DeclareRobustCommand*\cmd[1]{\texttt{\char`\\#1}}
\DeclareRobustCommand\cs[1]{\texttt{\char`\\#1}}
\def\crcmd{\cmd{\char`\\}}
\DeclareRobustCommand*\env[1]{\texttt{#1}}
\DeclareRobustCommand*\pkg[1]{\textsf{#1}}
\DeclareRobustCommand*\cls[1]{\textsf{#1}}
\DeclareRobustCommand*\marg{\@ifstar\@marg\@margmeta}
\DeclareRobustCommand*\oarg{\@ifstar\@oarg\@oargmeta}
\DeclareRobustCommand*\Arg[1]{\@meta{#1}}
\def\@oarg#1{\textcolor{gray}{\texttt{[#1]}}}
\def\@oargmeta#1{\@oarg{\@meta{#1}}}
\def\@marg#1{\texttt{\{#1\}}}
\def\@margmeta#1{\@marg{\@meta{#1}}}
\def\@meta#1{$\m@th\langle$\textnormal{\textit{#1}}$\m@th\rangle$}
%
% 命令和环境的索引
%
\def\pkgindex#1{\@for\pkgname:=#1\do{\index{\pkgname @\pkg{\pkgname} 宏包}}}
\def\clsindex#1{\@for\clsname:=#1\do{\index{\clsname @\cls{\clsname} 文档类}}}
\def\cmdindex{\@ifnextchar[{\pkgcmdindex}{\ltxcmdindex}}
\def\envindex{\@ifnextchar[{\pkgenvindex}{\ltxenvindex}}
\def\ltxcmdindex#1{\@for\@ltxcmd:=#1\do{\index{\@ltxcmd @\cmd{\@ltxcmd}}}}
\def\ltxenvindex#1{\@for\@ltxenv:=#1\do{\index{\@ltxenv @\env{\@ltxenv} 环境}}}
\def\pkgcmdindex[#1]#2{\@for\@pkgcmd:=#2\do{\index{\@pkgcmd @\cmd{\@pkgcmd} (\pkg{#1})}}}
\def\pkgenvindex[#1]#2{\@for\@pkgenv:=#2\do{\index{\@pkgenv @\env{\@pkgenv} 环境 (\pkg{#1})}}}
使用的时候是:\cmd{fontsize}\marg{size}\marg{base line-skip}
效果: