I am writing a tutorial, and I need to include a UNIX command which is run from the shell. How do I represent this? It looks extremely strange if I simply use the verbatim environment.
Asked
Active
Viewed 266 times
0
sadljkfhalskdjfh
- 103
1 Answers
3
If your code lines are not too long so you want to centre or offset the display block you can do
text text text
\begin{center}
\begin{minipage}{.5\textwidth}
\begin{verbatim}
code
lines
here
\end{verbatim}
\end{minipage}
\end{center}
Replacing verbatim by lstlisting or minted or similar environments if you want syntax colour highlighting or other features rather than simple monospace verbatim text.
David Carlisle
- 757,742
verbatim. – jon May 06 '16 at 01:34verbatimstyle environments if special LaTeX characters are involved like backslashes, percents, carats, pound signs, etc. Otherwise, you can pick a way to differentiate the UNIX command from your document text. Italics, for example, might work; sans serif is another possibility... – Steven B. Segletes May 06 '16 at 02:09\verb|cp file1.txt file2.txt|is what you want or .... – David Carlisle May 06 '16 at 08:43verbatimis at the very left. I would prefer it if it displayed commands a bit more to the right, without having to insert spaces, which feels wrong to me. – sadljkfhalskdjfh May 07 '16 at 01:33\begin{center}\begin{minipage}{.5\textwidth}\begin{verbatim}...or whatever width you want for the verbatim code – David Carlisle May 07 '16 at 08:26minipageenvironment.) – sadljkfhalskdjfh May 07 '16 at 11:28