
Estoy en el proceso de escribir un manual sencillo. En él, explico cómo configurar los archivos y programas necesarios para ejecutar una canalización que he escrito. Me gustaría incluir comandos de línea de comando en ese archivo de manera que se destaquen y sean fáciles de leer.
Básicamente, ¿cómo puedo conseguir este efecto en mi documento LaTeX?
cd ~/foo; mkdir bar
Estaba pensando en un \parbox
color de fondo y un color de fondo, pero esperaba que hubiera una clase que simplifique este u otros trucos. No necesito resaltar el código, solo necesito una manera fácil de diferenciar los comandos de la prosa.
Respuesta1
Sugeriría usar el verbatim
entorno ya que es sencillo y debería proporcionar la distinción que busca. Aquí hay un ejemplo mínimo:
\documentclass{article}
\begin{document}
I am in the process of writing a simple manual. In it, I explain how to set up the
files and programs necessary to run a pipeline I have written. I would like to include
command line commands in that file in a way that makes them stand out and easy to read.
Basically, how can I get this effect in my LaTeX document:
\begin{verbatim}
cd ~/foo; mkdir bar
\end{verbatim}
I was thinking along the lines of a \verb|\parbox| and a background color but I was
hoping there might be a class that simplifies this or any other tricks. I don't need
code highlighting, I just need an easy way to differentiate commands from prose.
\end{document}
Quizás defina el suyo propio a través de la funcionalidad proporcionada porfancyvrb
olistings
También podría ser una opción, como se sugiere enImprimir programas con su sintaxis adecuaday/oEscribir código fuente en LaTeX como texto.
Respuesta2
Como variación del verbatim
tema, el numberedblock
paquete le permite etiquetar bloques de código con un número marginal y hacer referencia a ellos con\ref
. Dependiendo de su aplicación, esto también puede resultar útil. (verhttp://ctan.org/pkg/numberedblock)
\documentclass{article}
\usepackage{numberedblock}
\begin{document}
I am in the process of writing a simple manual. In it, I explain how to set up the
files and programs necessary to run a pipeline I have written. I would like to include
command line commands in that file in a way that makes them stand out and easy to read.
Basically, how can I get this effect in my LaTeX document:
\begin{numVblock}[\nbVlabel{nb:A}]
cd ~/foo; mkdir bar
\end{numVblock}
I was thinking along the lines of a \verb|\parbox| and a background color but I was
hoping there might be a class that simplifies this or any other tricks. I don't need
code highlighting, I just need an easy way to differentiate commands from prose.
I can number larger blocks
\begin{numVblock}[\nbVlabel{nb:B}]
program test
implicit none
integer a, x
c$$$$$$$$$$$$$$$$$$$$$$$$$
a = 0
x = 1
10 a = a + x
if (a .eq. 100) stop
goto 10
end
\end{numVblock}
\noindent and can then reference code blocks \ref{nb:A} and \ref{nb:B}.
\end{document}