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> \
  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.

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.







program <mandatory arg> [optional arg]  :a | b: out ... .. .

echo 'hello world'


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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