
Java 소스 코드가 있고 이를 LaTex에 표시하고 싶습니다.
\lstset{language=Java}
\begin{lstlisting}
IntentFileter intentfilter = new IntentFilter();
intentfilter.addAction("com.anguanjia.action.download.START_DOWNLOAD");
intentfilter.addAction("com.anguanjia.action.download.DOWNLOAD_SUCCESS");
g = new blm(this, null);
m.registerReceiver(g, intentfilter);
\end{lstlisting}
그러나 출력은 정말 보기 흉합니다.
내가 뭔가 잘못한 걸까요, 아니면 이렇게 되어야 하는 걸까요?
답변1
이는 미루기와 미화를 향한 출발점이 될 수 있습니다.
\documentclass{article}
\usepackage{listings}
\usepackage{xcolor}
\lstset{language=Java,
basicstyle=\footnotesize\ttfamily,
commentstyle=\ttfamily\itshape\color{gray},
stringstyle=\ttfamily,
showstringspaces=false,
breaklines=true,
frameround=ffff,
frame=single,
rulecolor=\color{black},
tabsize=1,
keywordstyle=\color{red}\bfseries,
columns=fullflexible,
morekeywords={public, class}
}
\begin{document}
\begin{lstlisting}
IntentFileter intentfilter = new IntentFilter();
intentfilter.addAction("com.anguanjia.action.download.START_DOWNLOAD");
intentfilter.addAction("com.anguanjia.action.download.DOWNLOAD_SUCCESS");
g = new blm(this, null);
m.registerReceiver(g, intentfilter);
\end{lstlisting}
\end{document}
내부 지시문을 사용하여 추가로 사용자 정의할 수 있습니다 \lstset
. 자세한 내용은 listings
매뉴얼을 참조하세요. 극단적인 아름다움을 원하시면 옵션 tcolobox
과 함께 사용하셔도 됩니다 listings only
. 문서 tcblisting
에서 검색하세요 tcolorbox
.