KTUGFaq

KTUG FAQ

·Î±×ÀÎ:
ºñ¹Ð¹øÈ£:
°¡ÀÔ
Emacs Makes All Computing Simple
FrontPage › TeX»ê¼ú¿¬»ê

¸ñÂ÷

1 TeX »ê¼ú¿¬»ê
1.1 µ¡¼À°ú »¬¼À
1.2 °ö¼À
1.3 ³ª´°¼À
1.4 ¿¹Á¦
2 LaTeX »ê¼ú¿¬»ê
2.1 \newcounter, \setcounter
2.2 calc ÆÐÅ°Áö
2.2.1 ¿¬»êÀÚ
2.2.2 ½Ç¼öÇ¥½Ã¸í·É
3 ½Ç¼ö¿¬»ê Èä³»³»±â : realcalc.tex

TeXÀº ³»ºÎÀûÀ¸·Î °íÁ¤¼Ò¼ýÁ¡ ¿¬»êÀ» ÇàÇÑ´Ù. »ç¿ëÀÚ ¼öÁØ¿¡¼­´Â Á¤¼ö(integer)¿¡ ´ëÇÑ »ê¼ú¿¬»êÀ» ÇÒ ¼ö ÀÖ´Ù.

1 TeX »ê¼ú¿¬»ê

¸ðµç ¿¬»êÀº counter¿Í dimension¿¡ ´ëÇؼ­ ÇàÇØÁø´Ù.
  • counter¶õ \count register¿¡ µî·ÏµÈ ¹ÙÀÌÆ®¸¦ °¡¸®Å²´Ù. TeXÀº 256(255)°³ÀÇ count register¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù. PlainTeX¿¡¼­ Á¤ÀÇµÈ \newcount ¸í·ÉÀº ÇöÀç »ç¿ëµÇÁö ¾Ê´Â count register¸¦ ÀÚµ¿ÇÒ´çÇÏ¿© \countdef ¸í·ÉÀ» ºÎ¸£´Â ¸ÅÅ©·ÎÀÌ´Ù. counter¿¡ ´ëÇؼ­´Â Á¤¼ö ¿¬»êÀ» ÇÑ´Ù.
  • dimensionÀº °íÁ¤ ±æÀÌ°ªÀÌ´Ù. dimension¿¡ ´ëÇؼ­´Â ½Ç¼ö ¿¬»êÀ» ÇÑ´Ù.

1.1 µ¡¼À°ú »¬¼À

\advance _variable_ by _number_
by´Â »ý·«ÇÒ ¼ö ÀÖ´Ù.
\newcount\mycnt\mycnt=1
\newdimen\mydim\mydim=10pt
\advance\mycnt by1\advance\mydim by10.1pt
\the\mycnt\quad\the\mydim
\newcount\mycnt\mycnt=1
\newdimen\mydim\mydim=10pt
\advance\mycnt by1\advance\mydim by10.1pt
\the\mycnt\quad\the\mydim

1.2 °ö¼À

\multiply _variable_ by _number_
¿ª½Ã by´Â »ý·«ÇÒ ¼ö ÀÖ´Ù.

°ö¼ÀÀÇ °á°ú´Â Àý´ë°ª $$2^{30}$$ À» ³ÑÀ» ¼ö ¾ø´Ù.
\newcount\mycnt\mycnt=1
\newdimen\mydim\mydim=10.24pt
\multiply\mycnt by4\multiply\mydim by2
\the\mycnt\quad\the\mydim
\newcount\mycnt\mycnt=1
\newdimen\mydim\mydim=10.24pt
\multiply\mycnt by4\multiply\mydim by2
\the\mycnt\quad\the\mydim

dimen¿¡ °öÇÏ´Â ¼ö´Â counterÀÌ´Ù.

1.3 ³ª´°¼À

\divide _variable_ by _number_
by´Â »ý·«°¡´É.

\newcount\mycnt\mycnt=5
\newdimen\mydim\mydim=10.24pt
\divide\mycnt by3\divide\mydim by3
\the\mycnt\quad\the\mydim
\newcount\mycnt\mycnt=5
\newdimen\mydim\mydim=10.24pt
\divide\mycnt by3\divide\mydim by3
\the\mycnt\quad\the\mydim

counter ³ª´°¼À¿¡¼­´Â, ³ª´« °á°úÀÇ ³ª¸ÓÁö´Â ¹ö¸°´Ù. Áï, ³ª´« °á°úµµ Á¤¼ö·Î Ãë±ÞµÈ´Ù.

ÀÌ ¼ºÁúÀ» ÀÌ¿ëÇÏ¿©, ƯÁ¤ÇÑ Á¤¼öÀÇ ¸¶Áö¸· ÇÑ ÀÚ¸®, ¿¹ÄÁ´ë 13ÀÇ ³¡ÀÚ¸® 3À» ±¸ÇÏ´Â ·çƾÀ» ±¸¼ºÇغ¸ÀÚ.
\count@\TmpInt
\ifnum\count@<\z@ \count@-\count@ \fi\count2\count@
\divide\count2 10 \multiply\count2 10 \advance\count@-\count2
¿©±â¼­´Â \TmpInt¸¦ ¹Þ¾Æµé¿©¼­ \count2¿¡ ÀúÀåÇÏ¿´´Ù. ±×·± ´ÙÀ½, 10À¸·Î ³ª´©°í ´Ù½Ã 10À» °öÇÏ¿© ¾ò¾îÁø ¼ö(10)·Î ¿ø·¡ÀÇ ¼ýÀÚ¸¦ »©ÁØ °ÍÀÌ´Ù. ±×·¯¸é ¸¶Áö¸· 1ÀÇ ÀÚ¸® 3ÀÌ ³²´Â´Ù. ÀÌ ·çƾÀº HLaTeX¿¡¼­ ÀÚµ¿Á¶»ç¸¦ ó¸®Çϱâ À§ÇØ Ã¤ÅÃÇÑ °ÍÀ̱⵵ ÇÏ´Ù.

1.4 ¿¹Á¦

À§ÀÇ »ê¼ú¿¬»êÀ» ÀÌ¿ëÇؼ­ µÎ ¼öÀÇ ÃÖ´ë°ø¾à¼ö¸¦ ±¸ÇÏ´Â ¸ÅÅ©·ÎÀÔ´Ï´Ù. ÃÖ´ë°ø¾à¼ö ±¸ÇÏ´Â ¾Ë°í¸®ÁòÀº ±× À¯¸íÇÑ À¯Å¬¸®µå ¾Ë°í¸®ÁòÀ» ÀÌ¿ëÇß½À´Ï´Ù.
\newcount\m \newcount\n \newcount\t

\def\euclid#1#2{\m=#1 \n=#2
  \ifnum\n>\m \t=\m \m=\n \n=\t \fi
  \ifnum\n=0 \number\m
  \else\t=\m \divide\m\n \multiply\m\n \advance\t-\m \euclid\n\t \fi}

´ÙÀ½°ú °°ÀÌ ÀÌ¿ëÇÕ´Ï´Ù.

\newcount\m \newcount\n \newcount\t

\def\euclid#1#2{\m=#1 \n=#2
  \ifnum\n>\m \t=\m \m=\n \n=\t \fi
  \ifnum\n=0 \number\m
  \else\t=\m \divide\m\n \multiply\m\n \advance\t-\m \euclid\n\t \fi}
    
The greatest common divisor of $119$~and~$544$ is $\euclid{119}{544}.$

The greatest common divisor of $2166$~and~$6099$ is $\euclid{2166}{6099}.$
À§ ¿¹´Â ¾Æ·¡·Î ºÎÅÍ ¾òÀº °ÍÀÔ´Ñ´Ù.

The greatest common divisor of $119$~and~$544$ is $\euclid{119}{544}.$
The greatest common divisor of $2166$~and~$6099$ is $\euclid{2166}{6099}.$

2 LaTeX »ê¼ú¿¬»ê

2.1 \newcounter, \setcounter

\newcounter´Â »õ·Î¿î Ä«¿îÅÍ º¯¼ö¸¦ Á¤ÀÇÇÑ´Ù. PlainTeXÀÇ \newcount¿Í °ÅÀÇ µ¿ÀÏÇÏÁö¸¸ LaTeX ƯÀ¯ÀÇ Çü½ÄÀ¸·Î ¾²ÀδÙ. Áï, ÀϹÝÀûÀ¸·Î \csname¿¡ ÇØ´çÇÏ´Â \ ¹®ÀÚ ¾øÀÌ Ä«¿îÅÍ º¯¼ö¸¸ ÁöÁ¤ÇÔÀ¸·Î½á, ÀÌÈÄ¿¡ ¿©·¯ °¡Áö »ç¿ë¹ýÀ» º¸´Ù Æí¸®ÇÏ°Ô ±¸ÇöÇÏ·Á ÇÏ¿´´Ù.
\documentclass{article}
\usepackage{hfont}
\usepackage{ifthen}

\begin{document}
%% newcounter
\newcounter{ddd}        % LaTeX ¼±¾ðÇü½Ä. Ä«¿îÅÍ º¯¼ö ddd¸¦ Á¤ÀÇÇÔ
\newcount\dddd  % PlainTeX Çü½Ä. Ä«¿îÅÍ º¯¼ö \dddd¸¦ Á¤ÀÇÇÔ

%% setcounter
\setcounter{ddd}{0}     % LaTeX Çü½Ä
\dddd=0                 % PlainTeX Çü½Ä

%% Ä«¿îÅÍ Çϳª Áõ°¡½ÃÅ°±â
\stepcounter{ddd} %     ÇöÀçÀÇ Ä«¿îÅÍ¿¡ 1À» ´õÇÑ´Ù.(LaTeX)
\advance\dddd by 1%     ÇöÀçÀÇ Ä«¿îÅÍ¿¡ 1À» ´õÇÑ´Ù.(PlainTeX)

\addtocounter{ddd}{3}%  ÇöÀçÀÇ Ä«¿îÅÍ¿¡ 3À» ´õÇÑ´Ù.(LaTeX)
\advance\dddd by 3%     ÇöÀçÀÇ Ä«¿îÅÍ¿¡ 3À» ´õÇÑ´Ù.(PlainTeX)

%% Ç¥ÇöÇü½Ä(LaTeX)
\arabic{ddd}
\Alph{ddd}
\alph{ddd}
\Roman{ddd}
\roman{ddd}

%% ¼ýÀÚ ÂüÁ¶
\theddd         % LaTeX¿¡¼­ ÇöÀç ÀúÀåµÈ dddÀÇ Ä«¿îÅ͸¦ ºÎ¸£´Â ¹æ¹ý
\number\dddd    % PlainTeX¿¡¼­ ÇöÀç ÀúÀåµÈ ddddÀÇ Ä«¿îÅ͸¦ ºÎ¸£´Â ¹æ¹ý. \the\ddddµµ °°À½.

%% ´ÙÀ½ ¹®ÀåÀº ¾ðÁ¦³ª Right¸¸ ½ÇÇàµÈ´Ù.
\ifthenelse{\equal{\value{ddd}}{\theddd}}
        {Right}{Wrong}

%% \dddd¸¦ Çϳª Áõ°¡½ÃÅ°ÀÚ.(ddd=4, \the\dddd=5)
\advance\dddd by 1

%% ´ç¿¬È÷ µÎ °ªÀº ´Ù¸¦ °ÍÀÌ´Ù.
\ifthenelse{\equal{\value{ddd}}{\the\dddd}}
        {Right}{Wrong. \theddd\ is not equal to \the\dddd}

\end{document}

2.2 calc ÆÐÅ°Áö

TeXÀÇ »ê¼ú¿¬»ê ¸í·ÉµéÀÎ \advance, \multiply µîÀº ¸»´Ü»ç¿ëÀÚ(end-user)°¡ ¾²±â¿¡´Â ³Ê¹« ºÒÆíÇÏ´Ù. LaTeX¿¡¼­´Â calc ÆÐÅ°Áö¸¦ ÅëÇÏ¿© »ê¼ú¿¬»êÀ» ¼öÇàÇϵµ·Ï ÇÏ°í ÀÖ´Ù. ÀÌ »ê¼ú¿¬»êÀº Counter(Number)¿Í Dimension µî¿¡ Àû¿ëµÈ´Ù.
<!> DimensionÀ̶õ ±æÀÌ´ÜÀ§°¡ ºÙ´Â ±æÀ̺¯¼ö¸¦ °¡¸®Å²´Ù.
  • \newcounter, \setcounter¿¡ ÀÇÇÏ¿© ¼³Á¤µÇ´Â counter(Á¤¼ö)
  • \newlength, \setlength¿¡ ÀÇÇÏ¿© ¼³Á¤µÇ´Â dimension(½Ç¼ö)
  • \widthof, \heightof, \depthof¿¡ ÀÇÇÏ¿© ±¸ÇØÁö´Â text boxÀÇ Å©±â(½Ç¼ö)
  • 2.2.1 ¿¬»êÀÚ

    1. $$+$$
    2. $$-$$
    3. $$*$$
    4. $$/$$

    2.2.2 ½Ç¼öÇ¥½Ã¸í·É

    1. \real
    2. \ratio
      <!> counter¿Í °°Àº Á¤¼ö ¿¬»ê¿¡¼­ °á°úÀÇ ¼Ò¼ö ºÎºÐÀº ¹ö¸°´Ù. ¿¹¸¦ µé¸é \setcounter{x}{3*\real{1.6}}ÀÇ °á°ú´Â Ä«¿îÅÍ x¿¡ 4¸¦ ÇÒ´çÇÒ °ÍÀÌ´Ù.

    3 ½Ç¼ö¿¬»ê Èä³»³»±â : realcalc.tex


    LaTeXÀº dimension¿¡ ´ëÇÏ¿© ½Ç¼ö¿¬»êÀÌ calc ÆÐÅ°Áö¸¦ ÅëÇÏ¿© °¡´ÉÇÏÁö¸¸, TeX/LaTeX¿¡¼­ ÀϹÝÀûÀÎ ½Ç¼ö ¿¬»êÀº »ç½Ç»ó ¸Å¿ì ¾î·Æ´Ù.

    ¿©±â¿¡ ¼Ò°³ÇÏ´Â realcalc.texÀº Frank Bochholz¾¾°¡ ¸¸µç PlainTeX º£À̽ºÀÇ ÆÐÅ°Áö·Î¼­, ½Ç¼ö ¿¬»êÀÌ °¡´ÉÇÑ °Íó·³ ¸¸µé¾îµÎ¾ú´Ù. ´Ù·ê ¼ö ÀÖ´Â ¼öÀÇ ¹üÀ§´Â -2147483647.999999999¿¡¼­ 2147483647.999999999±îÁöÀÌ°í, ³ª´°¼ÀÀÌ ±¸ÇöµÇ¾î ÀÖÁö ¾ÊÁö¸¸, ½Ç¼ö¿¬»êÀÌ ²À ÇÊ¿äÇÒ ¶§ ¾µ ¼ö ÀÖÀ» °ÍÀÌ´Ù.(³ª´°¼ÀÀº ¼Ò¼ö°ö¼ÀÀ¸·Î ¹Ù²Ù¾î¼­ »ç¿ëÇØ¾ß ÇÒ °ÍÀÌ´Ù.) ´ÙÀ½Àº LaTeX¿¡¼­ÀÇ »ç¿ë·ÊÀÌ´Ù.

    \documentclass{article}
    \input realcalc
    
    \def\a{2.550}
    \def\b{3.660}
    \parindent=0pt
    
    \begin{document}
    
    \verb|\a|=\a \quad \verb|\b|=\b
    
    \begin{tabular}{cc}
    add &
    \Radd\c\a\b
    \Rtrunc\c2\c
    \Rtrunc\a2\a
    \Rtrunc\b2\b
    \c \verb|=| \a \verb|+| \b
    \\
    
    subst &
    \Rsub\d\a\b
    \Rtrunc\d2\d
    \d
    \\
    
    multiply &
    \Rmul\e\a\b
    \Rtrunc\e2\e
    \e
    \end{tabular}
    
    \end{document}
    


    Contributors : Karnes


    ^
    Valid XHTML 1.0! Valid CSS! powered by MoniWiki
    last modified 2007-02-07 22:56:21
    Processing time 0.0480 sec