What is the way to achieve the style for \pdfbookmark command syntax as shown below? Is this pure verb?

enter image description here

Original document

share|improve this question
    
There is a mail address given in the original document, perhaps it still works ;-), but in the end it is something like \verb, most likely – Christian Hupfer 15 hours ago
    
@ChristianHupfer, not a bad idea ;). However, I saw similar style in many docs for packages. It shouldn't be that complicated. – belford 15 hours ago
    
Sorry, I had to reject your edit, because you missed my additions ;-) – Christian Hupfer 15 hours ago
    
@ChristianHupfer, no problem (the right parenthesis was still missing ;)). Last but not least, great job. Thank you. – belford 14 hours ago
up vote 5 down vote accepted

The linked document is from TUGBoat 88 (28.2), so it is very likely that the author used the ltugboat class or ltugboat package (there are both of them).

A command sequence is being typeset with \cs{foo}, the arguments can be typeset with [\meta{arg}] or \tubbraced{\meta{arg}}, depending on the type of the macro, of course.

\cs is defined as:

\DeclareRobustCommand{\cs}[1]{{\tt \char`\\#1}}

\documentclass{ltugboat}

\begin{document}
    \cs{pdfbookmark}[\meta{level}]\tubbraced{\meta{text}}\tubbraced{\meta{key}}
\end{document}

pdfbookmark

A similar syntax is provided for example by ltxdoc.cls:

\documentclass{ltxdoc}
\begin{document}

\cs{pdfbookmark}\oarg{level}\marg{text}\marg{key}
\end{document}
share|improve this answer
    
Please have a look on holtxdoc.sty as well... – Christian Hupfer 14 hours ago

This copes with any number of arguments:

\documentclass{article}
\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\syntax}{mO{}}
 {
  \group_begin:
  \tl_clear:N \l__belford_syntax_args_tl
  \normalfont\ttfamily
  \token_to_str:N #1
  \keys_set:nn { belford/syntax } { #2 }
  \tl_use:N \l__belford_syntax_args_tl
  \group_end:
 }
\NewDocumentCommand{\meta}{m}
 {
  \group_begin:
  \normalfont$\langle$\textit{#1}$\rangle$
  \group_end:
 }

\tl_new:N \l__belford_syntax_args_tl
\keys_define:nn { belford/syntax }
 {
  m .code:n = \__belford_syntax_addarg:nnn { \symbol{`\{} } { \symbol{`\}} } { #1 },
  o .code:n = \__belford_syntax_addarg:nnn { [ } { ] } { #1 },
  p .code:n = \__belford_syntax_addparg:nn #1,
 }
\cs_new_protected:Nn \__belford_syntax_addarg:nnn
 {
  \tl_put_right:Nn \l__belford_syntax_args_tl { #1 \meta{#3} #2 }
 }
\cs_new_protected:Nn \__belford_syntax_addparg:nn
 {
  \tl_put_right:Nn \l__belford_syntax_args_tl { ( \meta{#1} , \meta{#2} ) }
 }
\ExplSyntaxOff

\NewDocumentCommand{\pkg}{m}{\textsf{#1}}

\begin{document}

For this \pkg{hyperref} provides
\syntax{\pdfbookmark}[o=level,m=text,m=key]

We also have
\begin{itemize}
\item \syntax{\makebox}[o=width,o=char,m=text]
\item \syntax{\makebox}[p={x}{y},o=char,m=text]
\end{itemize}

\end{document}

enter image description here

For actual examples you can directly use \verb.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.