# \envitem in ltxdockit package prints curly braces in a different font

I've written a small LaTeX package and am preparing its documentation using ltxdockit package. I found a strange behavior about font.

Consider the following MWE.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{ltxdockit}
\begin{document}
\begin{ltxsyntax}
\envitem{envname}[opt]{arg}

this is an example.
\end{ltxsyntax}
\end{document}


After compiling this source with pdflatex, the result looks like this:

I noticed that the curly braces enclosing the beginning envname are rendered in \rmfamily, not in \ttfamily, which is weird to me.

I looked into ltxdockit.sty and found a macro \ltd@envitem, which \envitem is "\leted" inside ltxsyntax environment.

\def\ltd@envitem#1{%
\ltd@itembreak
\item[\textbackslash begin]\{{\ltxsyntaxfont\ltxsyntaxlabelfont#1}\}%
\ltd@pdfbookmark{#1}{#1}%
\begingroup
\ltd@syntaxsetup
\ltxsyntaxfont
\def\@tempa{%
\ltd@itemsave
\itemsep\z@
\item[\textbackslash end]\{{\ltxsyntaxfont\ltxsyntaxlabelfont#1}\}%
\ltd@itemrest}%
\ltd@parseargs}


However, I cannot see differences between line 3 and line 11 above except for the begin and end and don't know why curly braces' in these parts look different with respect to font family.

How can I change the font of the first curly braces to \ttfamily? Although the package author says, "users should not at­tempt its use un­less they are ca­pa­ble of deal­ing with prob­lems un­aided", I'd appreciate it if you give me some suggestions.

The difference between the begin and end is that \{ picks up the current font which is typically roman at the start but monospace by the end.

Clearly that's not intended, here I change both begin and end lines to move the braces inside the scope of the font change.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{ltxdockit}
\makeatletter
\def\ltd@envitem#1{%
\ltd@itembreak
\item[\textbackslash begin]{\ltxsyntaxfont\{{\ltxsyntaxlabelfont#1}\}}%
\ltd@pdfbookmark{#1}{#1}%
\begingroup
\ltd@syntaxsetup
\ltxsyntaxfont
\def\@tempa{%
\ltd@itemsave
\itemsep\z@
\item[\textbackslash end]{\ltxsyntaxfont\{{\ltxsyntaxlabelfont#1}\}}%
\ltd@itemrest}%
\ltd@parseargs}

\makeatother
\begin{document}
\begin{ltxsyntax}
\envitem{envname}[opt]{arg}

this is an example.
\end{ltxsyntax}
\end{document}

• Oops, I gave the same trial before posting the question, but forgot \makeatletter. All things go well thanks! May 19 '16 at 9:57