Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am typesetting a set of instructions which includes several (Unix) command line arguments. I have been using the listings package to include these arguments, but the colouring is less than ideal. Weird words like "test" are bolded. Is there something more like Pygments, which can highlight flags and filenames and the like?

As an example something like

program-name -some-option-flag -some-other-option-flag -i /location/of/input/file -o /location/of/output/file
share|improve this question
1  
Would you please provide an example of what you're doing? –  egreg Nov 9 '11 at 17:32
    
@Dave: You can use the package minted which uses pygments. –  Marco Daniel Nov 9 '11 at 17:49
1  
It is possible to specify the language used in a listing, and even define your own language or formatting. As suggested, provide an MWE to allow others to work with something. –  Werner Nov 9 '11 at 18:43
    
Thanks for providing the command line that you are tying to typeset, but it would be even more helpful to have a complete MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. That way we can see exactly what the problem is. –  Peter Grill Nov 9 '11 at 23:53
add comment

closed as unclear what you're asking by Jubobs, Speravir, ChrisS, Jesse, cmhughes Jan 16 at 5:22

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

Without a full MWE it not clear exactly what issue you are having. But, you can define you own keywords that you want highlighted. Below I have defined cd, man, ls,and uptime to be emphasized in blue, and the keyword filename to be emphasized in red. So when these appear in the listing the specified formatting is applied.

enter image description here

\documentclass{article}
\usepackage{listings}%
\usepackage{xcolor}

\lstset{%
    backgroundcolor=\color{yellow!20},%
    basicstyle=\small\ttfamily,%
    numbers=left, numberstyle=\tiny, stepnumber=2, numbersep=5pt,%
    }%

\lstset{emph={%  
    cd, man, ls,uptime%
    },emphstyle={\color{blue}\bfseries\underbar},%
    morekeywords={filename},
    keywordstyle={\color{red}\ttfamily}
}%


\begin{document}
\begin{lstlisting}
man cd
ls -lF test/
rm filename
uptime
\end{lstlisting}
\end{document}
share|improve this answer
add comment

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