KTUGFaq

KTUG FAQ

·Î±×ÀÎ:
ºñ¹Ð¹øÈ£:
°¡ÀÔ
Don't be overly suspicious where it's not warranted.
FrontPage › SourceCodeListing

Source Code Listing ¹æ¹ý

¸ñÂ÷

1 Source Code Listing ¹æ¹ý
1.1 ÀϹÝÀûÀÎ ¾È³»
1.2 °£´ÜÇÏ°Ô ÁÙ¹øÈ£¸¸ ³Ö±â
1.3 verbatim-like ¼Ò½ºÄÚµå ¸®½ºÆÃ
1.3.1 verbatim ȯ°æ
1.3.2 verbatim ÆÐÅ°Áö ÀÌ¿ë
1.3.3 sverb ÆÐÅ°Áö
1.3.4 fancyvrb ÆÐÅ°Áö¸¦ ÀÌ¿ëÇÑ ¼Ò½ºÄÚµå ¸®½ºÆÃ
1.3.5 alltt ÆÐÅ°Áö¸¦ ÀÌ¿ëÇÏ´Â ¹ý
1.3.6 Moreverb Package ¸¦ »ç¿ëÇÏ´Â ¹ý
1.4 verbfileÀ» ÀÌ¿ëÇؼ­ ¿ÜºÎ fileÀ» ÀÐ¾î µéÀ̱â
1.4.1 sverb ÆÐÅ°ÁöÀÇ \verbinput
1.4.2 verbatim ÆÐÅ°ÁöÀÇ ¿ÜºÎ ÆÄÀÏ Ã³¸®
1.4.3 moreverb ÆÐÅ°ÁöÀÇ \verbatimtabinput
1.4.4 verbfile ÆÐÅ°Áö
1.4.4.1 listingÀ» ÀÌ¿ëÇϸé ÆÄÀÏ¿¡ line number¸¦ Ãß°¡ÇØÁØ´Ù.
1.4.4.2 verbfileÀ» ÀÌ¿ëÇÏ¸é ´«¿¡º¸ÀÌ´Â ±×´ë·Î ÆÄÀÏÀ» Ãâ·ÂÇÑ´Ù.
1.5 Programming Language¿¡ ƯȭµÈ ¸®½ºÆÃ
1.5.1 TeX ÀÇ c_pascal À» »ç¿ëÇÏ´Â ¹ý
1.5.2 Algorithmic Package¸¦ »ç¿ëÇÏ´Â ¹ý
1.5.3 Program Package ¸¦ »ç¿ëÇÏ´Â ¹ý
1.5.4 Listings Package ¸¦ »ç¿ëÇÏ´Â ¹ý
1.6 Float °ú °áÇÕÇÏ¿© ¿¹»Ú°Ô ¸¸µé±â
1.6.1 floatstyleÀ» ÀÌ¿ëÇÏ´Â ¹æ¹ý
1.6.2 algorithm ÆÐÅ°Áö
1.7 ÆÁ: ÇÑÀå ÀÌ»óÀÇ ¼Ò½º Listing + TOC-like ÷°¡Çϱâ
1.7.1 Ä«¿îÅÍ ¸¸µé±â
1.7.2 TOC like ±â´É Ãß°¡
1.7.3 environment ¸¸µé±â
1.7.4 ½ÇÁ¦ »ç¿ë
1.8 ±âŸ
1.8.1 ¼Ò½ºÄڵ忡 ¶óÀιøÈ£ Ãß°¡ À¯Æ¿¸®Æ¼(python)
1.8.2 framed ÆÐÅ°Áö ÀÌ¿ë
1.8.3 ¼Ò½ºÄڵ带 LaTeX ÄÚµå·Î º¯È¯ÇÏ´Â À¯Æ¿¸®Æ¼
1.8.4 C++2LaTeX S/W
1.9 LGrind Package¸¦ »ç¿ëÇÏ´Â ¹ý
1.9.1 LGrind »ç¿ë¹ý
1.9.2 ¿¹Á¦ ÄÚµå
1.9.3 ¹ö±×
1.9.4 ÀÚµ¿È­
1.10 Highlight
1.11 ¿¹Á¦ ¼Ò½º

1.2 °£´ÜÇÏ°Ô ÁÙ¹øÈ£¸¸ ³Ö±â

KTUGOperate:20535
\usepackage{fancyvrb}

\begin{Verbatim}[fontfamily=cmtt,frame=single,baselinestretch=1,fontsize=
\footnotesize,numbers=left]
...
\end{Verbatim}

ȤÀº

\usepackage{moreverb}
...
\begin{listing}{1}
[page 1 0 0 0 0 0 0 0 0 0]
fnt: cmr10 at 50pt
set: 'Hello, World!'
\end{listing}
...
À§ÀÇ \begin{listing}{num} ¿¡¼­ num Àº ½ÃÀÛ¹øÈ£¸¦ ³ªÅ¸³»°í \begin{listing}{num} ÀÌÀü¿¡ \let\listinglabelsize\footnotesize ¿Í °°ÀÌ ¼ýÀÚÅ©±â¸¦ Á¶ÀýÇÒ ¼ö ÀÖ´Ù.

1.3 verbatim-like ¼Ò½ºÄÚµå ¸®½ºÆÃ

1.3.1 verbatim ȯ°æ

verbatim ȯ°æÀ» ÀÌ¿ëÇÕ´Ï´Ù.
\begin{verbatim}
for (int i = 0; i < 10; i++) {
  ...
} 
\end{verbatim}

1.3.2 verbatim ÆÐÅ°Áö ÀÌ¿ë

\usepackage{verbatim}
\verbatiminput{alltttest.tex}

verbatim ÆÐÅ°Áö¸¦ ÀÌ¿ëÇÏ´Â ÀÌÀ¯´Â ´ÙÀ½°ú °°½À´Ï´Ù.
  • verbatim environment¸¦ »ç¿ëÇϴ°æ¿ì memory overflow°¡ ÀϾ ¼ö ÀÖ´Ù°í ÇÕ´Ï´Ù. ÀÌ ¹®Á¦¸¦ ÇØ°áÇÕ´Ï´Ù.
  • comment ȯ°æÀ» ÀÌ¿ëÇؼ­ TeX ¹®¼­¿¡ commentingÀ» ÇØÁÙ ¼ö°¡ ÀÖ½À´Ï´Ù.
  • \verbatiminputÀ» Á¦°øÇÕ´Ï´Ù.

1.3.3 sverb ÆÐÅ°Áö

1.3.4 fancyvrb ÆÐÅ°Áö¸¦ ÀÌ¿ëÇÑ ¼Ò½ºÄÚµå ¸®½ºÆÃ


  • ÁÙ³ª´©±â ³íÀÇ - KTUGOperate:15019
  • Environment ¿¡¼­ Verbatim -KTUGOperate:15016
  • listings ÆÐÅ°ÁöÀÇ ÇѱÛÁÖ¼® ó¸® ¹ö±× - KTUGOperate:11425

listings ÆÐÅ°Áö´Â ÁÖ¼®¹®ÀÇ ÇѱÛÀ» ÀÌ»óÇÏ°Ô Ç¥½ÃÇÕ´Ï´Ù. ±×·¯³ª fancyvrb ÆÐÅ°Áö´Â ÁÖ¼®ÀÇ ÇѱÛÀ» Ç¥½ÃÇϴµ¥ ¹®Á¦°¡ ¾ø½À´Ï´Ù. °Ô´Ù°¡ ±Û²ÃÀ» ÁöÁ¤ÇÏ°í Çà¹øÈ£¸¦ ºÙÀÏ ¼ö µµ ÀÖ½À´Ï´Ù.

\documentclass{article}
\usepackage{hangul}
\usepackage{fancyvrb}

\title{fancyvrb ÆÐÅ°Áö Å×½ºÆ®}

\begin{document}
ÀÌ°ÍÀº Å×½ºÆ®ÀÔ´Ï´Ù.
\begin{Verbatim}
[fontfamily=cmtt,frame=single,baselinestretch=1,fontsize=\footnotesize,numbers=left]
int main(int argc, char *argv[])
{
        //ÇÑ±Û ÁÖ¼®1
        /*
                ÇѱÛÁÖ¼®2
        */
        printf("Çï·Î¿ì ¿ùµå\n\n\n");
        printf("Hello, world\n");
        return 0;
}
\end{Verbatim}

\end{document}

°è¼Ó °°Àº ¿É¼ÇÀ» ¾²±â ½È´Ù¸é \DefineVerbatimEnvironment ¸¦ ¾µ ¼ö ÀÖ½À´Ï´Ù.

\DefineVerbatimEnvironment
    {source}{Verbatim}
    {frame=single, baselinestretch=1,
     fontsize=\footnotesize, numbers=left}

\begin{source}
void hello {
    printf("hello world");
}
\end{source}

1.3.5 alltt ÆÐÅ°Áö¸¦ ÀÌ¿ëÇÏ´Â ¹ý

\documentclass{article}
\usepackage{alltt}

\begin{document}
\begin{alltt}
void main(void)\{
    printf("Hello, world");
    printf("Hello,world");
    /*
      \emph{°­Á¶µµ »ç¿ë°¡´ÉÇÔ}
    */
\}
\end{alltt}
\end{document}
°¡²û TeX ¼Ò½º¿Í ÇÔ²² ÇÁ·Î±×·¥ ¼Ò½º¸¦ »ç¿ëÇÏ°í ½ÍÀ» °æ¿ì°¡ ÀÖ´Ù. À̶§¿¡´Â alltt package¸¦ »ç¿ëÇÑ´Ù.
  • ÇÁ·Î±×·¥ÁßÀÇ { ¸¦ »ç¿ëÇϱâ À§Çؼ­´Â \{¶ó°í ½áÁØ´Ù.
  • \emph{} °°ÀÌ TeX ¸í·É¾î¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù.

1.3.6 Moreverb Package ¸¦ »ç¿ëÇÏ´Â ¹ý

from KTUGOperate:3173 (by Progress)

moreverb ÆÐÅ°Áö´Â ¸®½ºÆà ȯ°æÀ» Á¦°øÇÕ´Ï´Ù. ÇÁ·Î±×·¥ °°Àº ±¸¹®ÀÇ ¿ÞÂÊ¿¡ ÁÙÀ» ´Þ¾ÆÁÖ´Â °ÍÀÌÁö¿ä.

\begin{listing}[1]{1}
\begin{equation*}
\begin{CD}
A \cap B @>j>\mbox{\small projection}>B \\
@V i V \mbox{\small injection} V @VVgV \\
A @<f<k< A\cup B
\end{CD}
\end{equation*}
\end{listing}

¿©±â¼­ \begin{listing}[1]{1}¸¦ ÁÖÀÇÇÕ´Ï´Ù.

[1]¿¡ µé¾îÀÖ´Â 1Àº ¸®½ºÆà ¹øÈ£°¡ ¸Å°ÜÁú line ¼ýÀÚ¸¦ ÀǹÌÇÕ´Ï´Ù. 1·Î ÇßÀ¸´Ï 1ÁÙ¸¶´Ù ¹øÈ£°¡ ºÙÁö¿ä. ¸¸¾à [2]·Î ÇßÀ¸¸é µÎ ¹ø° ÁÙ¸¶´Ù ¹øÈ£°¡ ºÙ½À´Ï´Ù.

{1}¿¡ µé¾îÀÖ´Â 1Àº line ¼ýÀÚ(ÁÙ¹øÈ£)ÀÇ ½ÃÀÛÀ» ¸»ÇÕ´Ï´Ù. ¸¸¾à {3}À¸·Î Çϸé ù ÁÙline ¹øÈ£°¡ 3ºÎÅÍ ½ÃÀÛÇÕ´Ï´Ù.

¿¹¸¦ µé¸é ´ÙÀ½°ú °°½À´Ï´Ù.
\begin{listing}[2]{3}
\begin{equation*}
\begin{CD}
A \cap B @>j>\mbox{\small projection}>B \\
@V i V \mbox{\small injection} V @VVgV \\
A @<f<k< A\cup B
\end{CD}
\end{equation*}
\end{listing}

ºñ½ÁÇÏ°Ô \begin{listing} ~~ \end{listing}µµ À¯È¿ÇÕ´Ï´Ù.

1.4 verbfileÀ» ÀÌ¿ëÇؼ­ ¿ÜºÎ fileÀ» ÀÐ¾î µéÀ̱â

  • Uploads:verbfile.sty¿©±â¿¡¼­ verbfile.sty ÆÄÀÏÀ» ´Ù¿î·Îµå ÇÑ´Ù.

1.4.1 sverb ÆÐÅ°ÁöÀÇ \verbinput


1.4.2 verbatim ÆÐÅ°ÁöÀÇ ¿ÜºÎ ÆÄÀÏ Ã³¸®


1.4.3 moreverb ÆÐÅ°ÁöÀÇ \verbatimtabinput

\verbatimtabinputtab_size{input_file} Àº ÅÇ»çÀÌÁ Á¶ÀýÇϸ鼭 ¿ÜºÎ ÆÄÀÏÀ» ºÒ·¯µéÀδÙ. \listinginput{input_file} Àº ¿ÜºÎ ÆÄÀÏÀ» ºÒ·¯µéÀ̸鼭 ¶óÀÎ ¹øÈ£¸¦ ºÙ¿©ÁØ´Ù.

1.4.4 verbfile ÆÐÅ°Áö

1.4.4.1 listingÀ» ÀÌ¿ëÇϸé ÆÄÀÏ¿¡ line number¸¦ Ãß°¡ÇØÁØ´Ù.

\usepackage{verbfile}
\listing{code/hello.c}

1.4.4.2 verbfileÀ» ÀÌ¿ëÇÏ¸é ´«¿¡º¸ÀÌ´Â ±×´ë·Î ÆÄÀÏÀ» Ãâ·ÂÇÑ´Ù.

\usepackage{verbfile}
\verbfile{code/hello.c}

1.5 Programming Language¿¡ ƯȭµÈ ¸®½ºÆÃ

1.5.1 TeX ÀÇ c_pascal À» »ç¿ëÇÏ´Â ¹ý

c_pascalÀº LaTeXÀÇ ÆÐÅ°Áö·Î Á¦°øµÇÁö ¾Ê°í TeX ÀÇ def ÇüÅ·ΠÁ¦°øµÈ´Ù.
  1. TEXMF\generic\c_pascal ¿¡¼­ cap_c.tex (CÀÇ °æ¿ì), cap_pascal(PASCAL)À» º¹»çÇÑ´Ù.
  2. \BeginC --- \EndC ¾È¿¡ ¼Ò½ºÄڵ带 ³Ö´Â´Ù.
  3. \InputC{filename} ¸¦ ÀÌ¿ëÇÑ´Ù.
  4. \font\tenrm=cmtt10 ¸¦ Ãß°¡ÇÑ´Ù.

\documentclass{article}
\font\tenrm=cmtt10

\input cap_c
\begin{document}

{\Large InputC example}\\
\InputC{./hello.c}
\\

{\Large BeginC/EndC example}\\
\BeginC
// this is a short demo program
/* both kinds of comment are recognised */

// some compiler directives
#pragma hdrfile "hello.sym" #include <stdio.h> #include
<sys/stat.h> #pragma hdrstop

// words not recognised as keywords are considered
// to be identifiers and are typeset in italic
void main() {
  int n;
  hello(0x1C);
  silly_funct();
} \EndC
\end{document}
½ÇÇà°á°ú c_pascal.jpg

1.5.2 Algorithmic Package¸¦ »ç¿ëÇÏ´Â ¹ý

Algorithm ½ÇÇà°á°ú algorithmic.jpg

1.5.3 Program Package ¸¦ »ç¿ëÇÏ´Â ¹ý

\documentclass{article}
\usepackage{program}
\begin{document}

\begin{programbox}
\mbox{A fast exponential procedure:}
\BEGIN
 \FOR i := 1 \TO 10 \STEP 1 \DO
   |expt|(2,i);
   |newline|
 \OD
 \WHERE \rcomment{A comment here}
 \PROC |expt|(x,n) \BODY
   z := 1;
   \DO \IF n = 0 \THEN \EXIT \FI;
     \DO \IF |odd|(n) \THEN \EXIT \FI;
       n := n/2; x := x*x;
     \OD;
     n := n-1;
     z := z*x
   \OD;
   |print|(z) \ENDPROC
\END
\end{programbox}

\end{document}

½ÇÇà°á°ú prog.jpg

1.5.4 Listings Package ¸¦ »ç¿ëÇÏ´Â ¹ý

KTUGOperate:8421 (by hoze)

\documentclass{article}
\usepackage{listings}

\begin{document}
\lstset{numbers=left, numberstyle=\tiny, stepnumber=1, numbersep=5pt}
\begin{lstlisting}
fileviewer(Dir) :-
    new(F, frame('File Viewer')),
    send(F, append(new(B, browser))),
    send(new(D, dialog), below(B)),
    send(D, append(button(view,
                  message(@prolog, view,
                      B?selection?key)))),
    send(D, append(button(quit,
                  message(F, destroy)))),
    send(B, members(directory(Dir)?files)),
    send(F, open).

view(F) :-
    send(new(V, view(F)), open),
    send(V, load(F)).
\end{lstlisting}
\end{document}

/!\ Listings ÆÐÅ°Áö¿¡¼­ ¼Ò½º Äڵ忡 ÇѱÛÀÌ µé¾î ÀÖÀ» °æ¿ì À̸¦ Àß Ç¥ÇöÇØÁÖÁö ¸øÇÑ´Ù. ÇÑ ÁÙ ¾È¿¡¼­¸¸ Ç¥ÇöÇÏ·Á¸é ÇÑ±Û ºÎºÐÀ» escape ¹üÀ§ ¾È¿¡ µÒÀ¸·Î½á ¹®Á¦¸¦ ÀϺΠÇÇÇØ°¥ ¼ö ÀÖ´Ù. escape ¹üÀ§ÀÇ ½ÃÀÛ°ú ³¡À» ³ªÅ¸³»´Â ¹®ÀÚ´Â listingÇÏ·Á°í ÇÏ´Â ¾ð¾î¿¡¼­ À¯º¸¹®ÀÚ·Î »ç¿ëµÇÁö ¾Ê´Â ±ÛÀÚ Áß¿¡¼­ °ñ¶ó¾ß ÇÒ °ÍÀÌ´Ù. ¿¹¸¦ µé¸é tilde ¹®ÀÚ¸¦ escape·Î »ç¿ëÇϱâ·Î ÇÑ´Ù¸é
\begin{lstlisting}[escapeinside=~~]
#include <stdio.h>

int main(int argc, char *argv[])
{
	//~Çï·Î¿ì ¿ùµå¸¦ Ãâ·Â~
        /*~¿©·¯ ÁÙ ÁÖ¼®ÀÇ °æ¿ì¿¡´Â Çະ·Î~
           ~escape ¹üÀ§¸¦ ¼³Á¤ÇØÁØ´Ù.~ */
	printf("Hello, world\n");
        printf("~¾È³çÇϼ¼¿ä~\n");
	return 0;
}
\end{lstlisting}
¾Æ½¬¿î ´ë·Î ÇÑ±Û ¹®Á¦´Â ÀÌ·¸°Ô ÇÏ¿© ±×·°Àú·° ó¸®ÇÒ ¼ö ÀÖ´Â °ÍÀ¸·Î º¸ÀÓ.

1.6 Float °ú °áÇÕÇÏ¿© ¿¹»Ú°Ô ¸¸µé±â

1.6.1 floatstyleÀ» ÀÌ¿ëÇÏ´Â ¹æ¹ý

\floatstyle{ruled}
\newfloat{Program}{thp}{lop}[section]

\listof{Program}{Program Listing}

\begin{Program}
\listing{png2jpgs.py}
\caption{The Program}
\end{Program}
The LaTeX Companion p.148 Âü°í.

1.6.2 algorithm ÆÐÅ°Áö

Âü°í Algorithm

1.7 ÆÁ: ÇÑÀå ÀÌ»óÀÇ ¼Ò½º Listing + TOC-like ÷°¡Çϱâ

À§¿¡¼­º» float À» ÀÌ¿ëÇϸé, ÀÚµ¿À¸·Î listof ¿¡ ³»¿ëÀ» ¸¸µé¾î ÁÖ°í, °£´ÜÇÑ Àå½ÄÀ» ÇØÁØ´Ù. ±×·¯³ª ÇÑÀå ÀÌ»óÀÇ ¼Ò½º¸¦ ¸®½ºÆÃÇϱâ À§Çؼ­´Â Á÷Á¢ ºñ½ÁÇÑ È¯°æÀ» ¸¸µé¾î ÁÖ¾î¾ß ÇÑ´Ù.

1.7.1 Ä«¿îÅÍ ¸¸µé±â

\newcounter{example}[section] % section ¿¡ ÀÚµ¿À¸·Î Ä«¿îÅ͸¦ 0·Î ¸¸µé¾î ÁØ´Ù.
\setcounter{example}{1}

1.7.2 TOC like ±â´É Ãß°¡

\makeatletter
\newcommand{\listofexamples}{\@starttoc{xmp}}
\newcommand{\ecaption}[1]{\addcontentsline{xmp}{example}{#1}
  \begin{centering}
    \bf Example \thesection .\theexample : #1 \\[1cm]
  \end{centering}
}
\newcommand{\l@example}[2]{\par\noindent#1 \dotfill {\itshape #2}}
\makeatother

1.7.3 environment ¸¸µé±â

\newenvironment{slist}{\noindent\rule{\textwidth}{1pt}\begin{list}{}{}\item[]}
{\end{list}\noindent\rule{\textwidth}{1pt} \stepcounter{example}}

1.7.4 ½ÇÁ¦ »ç¿ë

\begin{slist}
\verbatiminput{biorhythm.rb}
\end{slist}
\ecaption{¾È³çÇϼ¼¿ä?}

´õ ÁÁÀº ¹æ¹ýÀÌ ÀÖÀ¸¸é Ãß°¡ÇØ Áֽñ⠹ٶø´Ï´Ù. --smcho

1.8 ±âŸ

1.8.1 ¼Ò½ºÄڵ忡 ¶óÀιøÈ£ Ãß°¡ À¯Æ¿¸®Æ¼(python)

Äڵ忡 ¶óÀιøÈ£¸¦ Ãß°¡ÇÏ´Â °ÍÀº ´ÙÀ½°ú °°Àº Utility¸¦ ÀÌ¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import string
import os.path

ADDED_SPLIT = "_lineadd"

class AddLine:
    def __init__(self, fileName_):
        self._fileName = fileName_
        # ÆÄÀÏÀÇ À̸§¿¡¼­ È®ÀåÀÚ¸¸À» ºÐ¸®ÇØ ³½´Ù
        [name,ext] = os.path.splitext(fileName_)
        self._fileNameNew = name + ADDED_SPLIT + ext
        print self._fileNameNew
    def append(self):
        try:
            fp = open(self._fileName)
            fp2 = open(self._fileNameNew,"w")
            lines = fp.readlines();
            # ÀÏ´Ü line stripÀ» ÇÑ´Ù. 
            count = 1
            for line in lines:
                #line = string.rstrip(line)
                newline = "%4d: %s" % (count, line)
                count += 1
                fp2.write(newline)

        except IOError:
            print "ERROR opening file"

if __name__ == "__main__":
    line = AddLine("add_line.py")
    line.append()


1.8.2 framed ÆÐÅ°Áö ÀÌ¿ë

framed ÆÐÅ°Áö¸¦ ÀÌ¿ëÇÏ¸é ¼Ò½º ÁÖÀ§¿¡ ½±°Ô ¼±À» µÎ¸¦ ¼ö°¡ ÀÖ´Ù. ¼Ò½ºÄڵ尡 1ÀåÀÌ ³Ñ¾î°¡µµ ¹®Á¦¾øÀÌ µ¿ÀÛÇÑ´Ù.

\begin{framed}
\verbatiminput{framed.sty}
\end{framed}

1.8.3 ¼Ò½ºÄڵ带 LaTeX ÄÚµå·Î º¯È¯ÇÏ´Â À¯Æ¿¸®Æ¼

1.9 LGrind Package¸¦ »ç¿ëÇÏ´Â ¹ý

[http]http://www.ctan.org/tex-archive/support/lgrind/?action=/tex-archive/support/ À§ÀÇ ÁÖ¼Ò¿¡¼­ ¼Ò½ºÄڵ带 ´Ù¿î·Îµå ¹ÞÀ» ¼ö ÀÖÀ¸³ª ±×³É ÄÄÆÄÀÏÀº µÇÁö ¾Ê´Â´Ù. À§ÀÇ ¼Ò½ºÄڵ带 Win32 ȯ°æ¿¡¼­ ÄÄÆÄÀϸµ ÇÑ °ÍÀº ¿©±â¿¡¼­ ´Ù¿î·Îµå ¹ÞÀ¸¸é µÈ´Ù. Uploads:lgrind.zip

1.9.1 LGrind »ç¿ë¹ý

lgrind -i -lc -d lgrindef lgutil.c  > res.tex
ÆĽºÄ® ÄÚµùÀÇ °æ¿ì -lpascal µîÀ¸·Î º¯°æÇÒ ¼ö ÀÖ´Ù. ÀÚ¼¼ÇÑ »çÇ×Àº lgrind.pdf ÂüÁ¶.

1.9.2 ¿¹Á¦ ÄÚµå

\usepackage[leftno,lineno5]{lgrind}
\usepackage{color}

\LGnuminterval=1 % numbering interval
\def\LGfsize{\small} % font size
\def\BGfont{\ttfamily\color{cyan}} % default
%\def\CMfont{\ttpfamily\bfseries\color{blue}}
\def\KWfont{\ttfamily\color{blue}} % keyword
\def\NOfont{\bfseries\color{red}} % Number
\def\STfont{\ttfamily\color{green}} % String
\def\TTfont{\ttfamily\upshape}
\def\VRfont{\ttfamily\color{black}\small} % variable

...

\lgrindfile{code/chap1/cradle.tex}

csource.jpg

1.9.3 ¹ö±×

»ý¼ºµÈ tex ÆÄÀÏÀÇ Á¦ÀÏ ¸¶Áö¸·¿¡ °ø¶õÀ» Çϳª µÎ¾î¾ß ÇÑ´Ù. ±×·¸Áö ¾ÊÀ¸¸ç \LGnuminterval=1 ·Î ¸¸µé¾î, ¸ðµç ¶óÀο¡ ¹øÈ£¸¦ ºÙÀÌ´Â °æ¿ì¿¡ ¹®Á¦°¡ »ý±ä´Ù.

1.9.4 ÀÚµ¿È­

´ÙÀ½°ú °°Àº ¹èÄ¡ ÆÄÀÏÀ» ¸¸µé¾î¼­ path ¿¡ ÀúÀåÇÑ´Ù.
lgrind -i -l%1 -d d:\prog\bin\lgrindef %2  > %3
rem ÀÚµ¿À¸·Î »ý¼ºµÈ ÆÄÀÏÀÇ Á¦ÀÏ ¸¶Áö¸·¿¡ °ø¶õÀ» Ãß°¡ÇÏ´Â ±â´ÉÀ» Ãß°¡ÇÏ¿©¾ß ÇÑ´Ù.
python d:\prog\bin\addblankline.py %3

ÀÚµ¿À¸·Î Á¦ÀÏ ¸¶Áö¸·¿¡ °ø¶õÀ» ³Ö´Â python ÇÁ·Î±×·¥Àº ´ÙÀ½°ú °°´Ù.
#!/usr/bin/python
import sys

def process(val_):
    try:
        f = open(val_,"r+")
    except IOError:
        print "Error! no such file"
        sys.exit()
    f.seek(0,2)
    f.write('\n')
    f.close()

if __name__ == '__main__':
    try:
        val = sys.argv[1]
    except IndexError:
        print "Error! no argumnet"
        sys.exit()
    process(val)

»ç¿ë¹ýÀº ´ÙÀ½°ú °°´Ù.
lg pascal cradle.dpr cradle.tex

1.10 Highlight

´Ù¾çÇÑ Å׸¶¿Í ½ºÅ¸ÀÏÀ» Á¦°øÇÏ´Â ¼Ò½º ÄÚµå ¸®½ºÆÃÀÇ ÃÖÀûÀÇ Åø. smcho ´ÔÀÇ ³ë·ÂÀ¸·Î ÀúÀÚ¿Í Á¢ÃËÇÑ ³¡¿¡ ÇѱÛ(EUC-KR, UTF-8) ÁÖ¼®¹®ÀÇ Ã³¸®°¡ °¡´ÉÇØÁø º£Å¸ ¹öÀüÀÌ ³ª¿Ô´Ù.

1.11 ¿¹Á¦ ¼Ò½º

ÀÌÁ¦±îÁö ³ª¿Â µµ±¸µéÀ» Á¾ÇÕÇÏ¿© ´ÙÀ½°ú °°Àº °£´ÜÇÑ ¿¹¸¦ ¸¸µé¾ú´Ù. ÀÌ´Â python ¼Ò½º¸¦ hightlight ¸¦ ÀÌ¿ëÇÏ¿© LaTeX À¸·Î ¸¸µç´ÙÀ½ À̸¦ listofsource µîÀÇ È¯°æÀ» ÀÌ¿ëÇÏ¿© ó¸®ÇÑ °ÍÀÌ´Ù. PDFHyperLink ¸¦ ÀÌ¿ëÇؼ­ pdf »ó¿¡¼­ ´Ù¸¥ ¼Ò½º³ª ÇÁ·Î±×·¥À» ½ÇÇà½ÃÅ°´Â °Íµµ °¡´ÉÇÏ´Ù. ´Ü ÀÌ°æ¿ì¿¡ python interpreter °¡ ±ò·Á ÀÖ¾î¾ß ÇÑ´Ù.


Contributors: smcho



^
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2007-02-18 04:44:39
Processing time 0.1151 sec