# Displaying Linux commands in LaTeX [duplicate]

Possible Duplicate:
Syntax Coloring in LaTeX
Unix Command Highlighting latex

I am after some advice on how to display Linux terminal commands into LaTeX, so that they are indented and look different from normal text.

I have tried to insert the following into LaTeX

  $\emph {wget http://etc...................}  this outputs the wget onto a single line and then the part starting http onto another line. I want it all to appear on one line. Can someone body please give me some advice. - ## marked as duplicate by Martin Schröder, Kurt, Scott H., lockstep, QrrbrbirlbelNov 26 '12 at 4:45 This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. Could you give us more of your code? I'm getting the output as you seem to want it. Also, for command line text I'd used \ttfamily. Finally, you've got a stand alone $ which should either be \$ or not there at all. – A.Ellett Nov 25 '12 at 16:00 See the answer of of tex.stackexchange.com/questions/46953/… – TeXtnik Nov 25 '12 at 16:03 At a simple level remember LaTeX's standard command \verb and the environement verbatim. For more sophisticated formatting see also tex.stackexchange.com/q/867/15925 – Andrew Swann Nov 25 '12 at 16:39 Welcome to TeX.sx! Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you. – Andrew Swann Nov 25 '12 at 16:44 ## 4 Answers You can use the features provided by the listings package. \documentclass{article} \usepackage{listings} \begin{document} \noindent See the following command : \begin{lstlisting}[language=bash]$ wget http://tex.stackexchange.com
\end{lstlisting}

\end{document}


-
This is exactly what I want, thanks for the help. –  mitchnufc Nov 25 '12 at 16:17

You can also use the minted package:

\documentclass{article}
\usepackage{minted}

\begin{document}
\noindent See the following command :
\begin{minted}{bash}
$wget http://tex.stackexchange.com \end{minted} \end{document}  You need Pygments and the --shell-escape flag when you compile. - You can use pythontex. It uses the Python library Pygments to provide some syntax highlighting. If you don't need syntax highlighting, fancyvrb is nice for typesetting verbatim text with custom indentation, frames, line numbers, etc. Internally, pythontex uses much of fancyvrb, combined with syntax highlighting from Pygments. \documentclass{article} \usepackage{pythontex} \setpygmentspygopt{bash}{style=default} %Set syntax highlighting style \setpygmentsfv{xleftmargin=4ex} %Pass fancyvrb options, in this case, left margin \begin{document} \noindent Block use: \begin{pygments}{bash}$ wget http://tex.stackexchange.com
\end{pygments}
And after the block.

Inline use:  \pygment{bash}{wget http://tex.stackexchange.com}.  And after inline

\end{document}

-

You can use the listings packages:

\usepackage{listings}


And type your code like this:

\begin{lstlisting}
print('print me')
\end{lstlisting}