# LaTeX listing of command line syntax

I have a LaTeX document using the listings package for some bash scripts. I'd like to create a different styling for text that is meant to show the syntax of a command. For instance, I have the following command in a bash-styles listing:

java -jar /usr/share/java/picard/MarkDuplicates.jar INPUT=<alignment_file.bam> \
VALIDATION_STRINGENCY=LENIENT OUTPUT=alignment_file.dup \
METRICS_FILE=alignment_file.matric ASSUME_SORTED=true REMOVE_DUPLICATES=true


However, I'd like to style this differently to a command that is actually entered into a terminal, since it is not a real command but just showing the syntax to be used. Is there a default styling for such a thing. Perhaps following:

Note the following conventions in the definition of the command parameters:

Angle brackets ( < > ) indicate a mandatory parameter.
Square brackets ( [ ] ) indicate an optional parameter. If you omit the parameter, InfoSphere CDC uses a default value.
A vertical bar ( | ) separating one or more parameters indicate that only one of the parameters in the list can be used. When one or more vertical bars appear in a list of parameters that is enclosed by square brackets [ ], the choices are limited to the parameters in the list, but you have the option to not specify any of the parameters.
Ellipsis ( ... ) means that a parameter or option can be repeated more than once.
Unless otherwise noted, the commands apply to all operating systems.

-
You don't have to sign with your name since it automatically appears in the lower right corner of your post. –  hpesoj626 Nov 15 '12 at 9:47
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. –  Jubobs Jan 19 at 12:18

Here is a possible solution. Some comments are appropriate:

• The options in the scope of the | have to be delimited some way, in this example I have used the colon : as a delimiter. It does not show on the output because the option [is] in the definition (i stands for invisible).

• I'm not sure that the ellipsis works as you are expecting (currently it is just highlighted in magenta).

If you want to combine this kind of hihglighting with the bash highlighting already provided by lstlistings, I have added some code as an example.

\documentclass[11pt]{article}

\usepackage{listings}
\usepackage{xcolor}

\lstdefinelanguage{args}{
sensitive=false,
alsoletter={.},
moredelim=[s][\color{red}]{<}{>},
moredelim=[s][\color{blue}]{[}{]},
moredelim=[is][\color{orange}]{:}{:},
keywords=[10]{...},
keywordstyle=[10]{\color{magenta}},
}

\lstnewenvironment{arguments}
{\lstset{language=args}}
{}

\lstnewenvironment{bash}
{\lstset{numbers=left,language=bash,keywordstyle={\color{blue}}}}
{}

\begin{document}
\ttfamily\small

\begin{arguments}
program <mandatory arg> [optional arg]  :a | b: out ... .. .
\end{arguments}

\begin{bash}
echo 'hello world'
\end{bash}

\end{document}

-