# Looking for macros to typeset syntax in more conventional way

I want to create a note about PSTricks and I need macros to typeset syntax in more conventional way that is adopted by most computer scientists. For example, I need a pair of > and < but they must be slimmer than the usual ones. Here I used \guillemotright and \guillemotleft as I could not find the better ones.

Here is my MWE, could you help me to accomplish my objective? Best practice is also welcome!

\documentclass[]{article}
\usepackage[T1]{fontenc}
\usepackage{xcolor}

\def\guillemetright{\guillemotright}% from now on we must hide the wrong terms.
\def\guillemetleft{\guillemotleft}% from now on we must hide the wrong terms.

\def\gr{\guillemetright}%I need a single > but not as big as the usual >.
\def\gl{\guillemetleft}%I need a single < but not as big as the usual <.

\newcommand\com[1]{\textbf{\textbackslash #1}}
\newcommand\opt[1][\textit{kv-options}]{\textcolor{blue}{[\gl\ensuremath{#1}\gr]}}
\newcommand\man[1]{\textcolor{red}{\{\gl\ensuremath{#1}\gr\}}}

\begin{document}

\section{Projection}
\fbox{\com{pstProjection}\opt\man{A}\man{B}\man{P_1,\ldots,P_n}\opt[P_1',\ldots,P_n']}

\noindent will project orthogonally the point $P_i$ on the line $\overline{AB}$.
\end{document}


Note: \man (mandatory) in red, \opt (optional) in blue, \com (command) in black.

-
If you are doing this often, then you might want to look at something like the listings package to automate the highlighting of different portions. –  Peter Grill Mar 15 '12 at 15:45
@PeterGrill: If you have time, please give me an example. I haven't elaborated the listing thoroughly. I will compare and might use your suggestion. –  please stop stalking Mar 15 '12 at 15:47

You're looking for \langle and \rangle:

\newcommand\meta[1]{$\langle#1\rangle$}
\newcommand\opt[1][\textit{kv-options}]{\textcolor{blue}{[\meta{#1}]}}
\newcommand\man[1]{\textcolor{red}{\{\meta{#1}\}}}


With it you get, from

\com{pstProjection}\opt\man{A}\man{B}\man{P_1,\ldots,P_n}\opt[P_1',\ldots,P_n']


the following result

The alternative version using

\newcommand{\meta}[1]{\guilsinglleft$#1$\guilsinglright}


doesn't seem as good

-
Is there a single guillemot explained here in LaTeX ? –  please stop stalking Mar 15 '12 at 10:18
Yes, there is. But the result is not good, IMO. I'll add it for comparison. –  egreg Mar 15 '12 at 10:20
The main brackets look clearer when using single guillemots I think. Thank you. –  please stop stalking Mar 15 '12 at 10:29
@DamienWalters: you can always make them \bigl[ ... \bigr], this should help. –  mbork Mar 15 '12 at 12:24
@DamienWalters -- please don't call them "guillemots". (yes, i know, adobe got it wrong; acknowledged, according to wikipedia, in the 3rd edition of the postscript language reference manual, p.783, character set endnote 3.) guillemots are small black sea birds. the correct term is "guillemets". –  barbara beeton Mar 15 '12 at 13:58