
簡単なマニュアルを作成中です。このマニュアルでは、作成したパイプラインを実行するために必要なファイルとプログラムの設定方法について説明します。目立つように、読みやすい方法で、コマンド ライン コマンドをこのファイルに含めるようにしたいと思います。
基本的に、LaTeX ドキュメントでこの効果を得るにはどうすればよいですか。
cd ~/foo; mkdir bar
私は と背景色について考えていました\parbox
が、これを簡素化するクラスやその他のトリックがあるのではないかと期待していました。コードの強調表示は必要ありません。コマンドと文章を区別する簡単な方法だけが必要です。
答え1
環境を使用することをお勧めします。verbatim
これはわかりやすく、必要な区別を実現できるはずです。以下に簡単な例を示します。
\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}
おそらく、提供されている機能を使って独自の定義をするでしょうfancyvrb
またはlistings
提案されているように、これも選択肢の1つとなる可能性がある。適切な構文でプログラムを印刷するおよび/またはLaTeXでソースコードをテキストとして記述する。
答え2
このテーマのバリエーションとしてverbatim
、numberedblock
パッケージではコードブロックに余白の番号をラベル付けし、 で参照することができ\ref
ます。アプリケーションによっては、これも役に立つかもしれません。(http://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}