반응형
LaTeX의 코드를 * nice *로 보이게하기
나는 현재 프로젝트 보고서를 작성하고 있으며 내가 사용한 약간 직관적이지 않은 직관적이지 않은 코드를 설명하기 위해 예제 코드의 짧은 발췌 부분을 많이 넣어야합니다.
LaTeX로 코드를 가져 오는 방법 :
- 좋아 보인다
- 줄이 너무 길면 페이지 측면에서 벗어나지 않습니다 (목록 lstlisting 또는 그대로)
- 텍스트의 나머지 부분과 인라인 인 것이 바람직합니다.
편집 (사람들이 스스로를 알아 내려고 시도 할 필요가 없도록 설정을 추가 할 것이라고 생각했습니다 (위키 북에서 가져 와서 아래로 링크).
좋은 설정 :
\usepackage{color}
\usepackage{listings}
\lstset{ %
language=C++, % choose the language of the code
basicstyle=\footnotesize, % the size of the fonts that are used for the code
numbers=left, % where to put the line-numbers
numberstyle=\footnotesize, % the size of the fonts that are used for the line-numbers
stepnumber=1, % the step between two line-numbers. If it is 1 each line will be numbered
numbersep=5pt, % how far the line-numbers are from the code
backgroundcolor=\color{white}, % choose the background color. You must add \usepackage{color}
showspaces=false, % show spaces adding particular underscores
showstringspaces=false, % underline spaces within strings
showtabs=false, % show tabs within strings adding particular underscores
frame=single, % adds a frame around the code
tabsize=2, % sets default tabsize to 2 spaces
captionpos=b, % sets the caption-position to bottom
breaklines=true, % sets automatic line breaking
breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace
escapeinside={\%*}{*)} % if you want to add a comment within your code
}
\begin{lstlisting}
!!code!!
\end{lstlisting}
이러한 설정의 예 :
리스팅 패키지 (의견과 코드에 대한 예를 들어, 다른 크기) 아주 좋은 매우 유연합니다.
그것은 밝혀 lstlisting
좋게 형식 코드 수 있지만 조정이 많이 필요합니다.
Wikibooks has a good example for the parameters you can tweak.
For simple document, I sometimes use verbatim, but listing is nice for big chunk of code.
참고URL : https://stackoverflow.com/questions/586572/make-code-in-latex-look-nice
반응형
'Programing' 카테고리의 다른 글
Emacs Ruby 자동 완성 거의 작동 (0) | 2020.06.29 |
---|---|
3 개의 스택으로 큐를 구현하는 방법은 무엇입니까? (0) | 2020.06.29 |
Chrome에서 로컬 링크를 열 수 있습니까? (0) | 2020.06.29 |
java.lang.Number가 Comparable을 구현하지 않는 이유는 무엇입니까? (0) | 2020.06.29 |
Java 프로젝트 (ant, cvs, hudson)의 빌드 및 버전 번호 매기기 (0) | 2020.06.29 |