코드박스를 어떻게 표시하나요?

코드박스를 어떻게 표시하나요?

간단한 매뉴얼을 작성하는 중입니다. 여기에서는 내가 작성한 파이프라인을 실행하는 데 필요한 파일과 프로그램을 설정하는 방법을 설명합니다. 눈에 띄고 읽기 쉬운 방식으로 해당 파일에 명령줄 명령을 포함하고 싶습니다.

기본적으로 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에서 제안한 것처럼 옵션이 될 수도 있습니다.적절한 구문으로 프로그램을 인쇄하세요.및/또는LaTeX에서 소스 코드를 텍스트로 작성.

답변2

테마 의 변형으로 verbatimnumberedblock패키지를 사용하면 코드 블록에 한계 숫자로 레이블을 지정하고 \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}

여기에 이미지 설명을 입력하세요

관련 정보