KTUG 한국 텍 사용자 그룹

Menu

KTUG :: 마당자유글 › LuaTeX 에서 listings로 프로그래밍 코드 조판

ruseel | 2013.11.28 18:04:14 | 메뉴 건너뛰기 쓰기

책 "실용주의 프로그래머"를 감명깊게 읽었습니다. 출판사는 Pragmatic Bookshelf 이고 "실용주의 프로그래머"를 저자 

두 분이 낸 이후로 출판사를 설립해서 다른 저자들의 책도 많이 출판하고 있습니다. eBook을 사면 PDF에 고객이름을 

넣어 조판해주기도 하고요. 


이 출판사의 프로그래밍 Code Listing이 아주 아름답습니다. 



개발자로 일하는지라 늘 한 번 이렇게 조판해보고 싶었는데 

최근 이런 글을 보고 다시 시도해 보았습니다. 


http://stackoverflow.c o m/questions/3272479/source-code-listing-something-like-the-pragmatic-programmer-books-with-latex



luatex-ko, listings 패키지를 사용합니다.  listings 패키지에서 utf-8 입력을 지원하지 않아서 

아래를 조판하면 


\begin{listings}

  1 

  2 가 

\end{listings}


이렇게 표시됩니다.

  1가 

  2


어떻게 해야 하나 한~~참을 찾다가

listings매뉴얼에서 escaping을 하면 된다는 말을 보고 [1]


\lstset{

         escapeinside={\%*}{*)}

}

을 주고 


\begin{listings}

1

2%*가*) 

\end{listings}


처럼 바꾸니 원하는 대로 조판이 잘 됩니다.



간단한 script로 소스코드에 영어가 아닌 부분이 있으면 

%*,  *)으로 감싸주는 전처리를 했습니다. 


 

작업했던 pdf를 부족하나마 올려보았습니다. 




[1] listings manul p.15 - If you do have a listing contained within a CJK environment, and want to

have CJK characters inside the listing, you can place them within a comment

that escapes to LATEX{ see section 4.14 for how to do that. (If the listing is not

inside a CJK environment, you can simply put a small CJK environment within

the escaped-to-LATEXportion of the comment.)



첨부 [1]

댓글 [1]

목록

KTUG 한국 텍 사용자 그룹