[[TableOfContents]] == TeXÀÇ Á¶°Ç¹® == TeXÀÇ if Á¶°Ç¹®Àº ÁÖ·Î ¹®ÀÚ¿Í ControlSequences¸¦ °Ë»çÇϱâ À§ÇÏ¿© »ç¿ëµÈ´Ù. ±¸¹®¹ýÀº ´ÙÀ½°ú °°´Ù. {{{#!vim tex \if... \fi \if... \else... \fi }}}=== `\if` === TeXÀº `\if` ´ÙÀ½¿¡ ³ª¿À´Â ¸ÅÅ©·ÎµéÀ» Àü°³Çϴµ¥, ¾ðÁ¦±îÁö Çϳĸé Àü°³ÇÒ ¼ö ¾ø´Â ÅäÅ«À» Á¤È®È÷ µÎ °³ ¾òÀ» ¶§±îÁö ÇÑ´Ù. ±×¸®°í³ª¼­ ±× ¾ò¾îÁø µÎ °³ÀÇ ÅäÅ«À» ºñ±³ÇÑ´Ù. µû¶ó¼­ `\if`¸¦ ÀÌ¿ëÇؼ­ ºñ±³ÇÒ ´ë»óÀÌ Àü°³ °¡´ÉÇÑ ¸ÅÅ©·Î³ª ¾×Ƽºê ¹®ÀÚÀÌ¸é ±×°Íµé ¾Õ¿¡ `\noexpand`¸¦ ºÙ¿©¼­ Àü°³¸¦ ¸·°í ºñ±³¸¦ ÇؾßÇÑ´Ù. ¿¹¸¦µé¾îº¸ÀÚ. {{{#!vim tex \def\A{abc} \def\B{abc} \if\A\B }}} À§ÀÇ Á¶°Ç¹®ÀÇ °á°ú´Â °ÅÁþÀÌ´Ù. ¿Ö³ÄÇϸé, À§ÀÇ ¼³¸í´ë·Î `\if` ´ÙÀ½¿¡ ³ª¿À´Â ¸ÅÅ©·Î¸¦ Àü°³Çϴµ¥, ¿©±â¼­´Â \A¸¦ Àü°³ÇϰԵȴÙ. ±×·±µ¥ \A¸¦ Àü°³ÇÏ°í³ª¸é `\if abc`°¡ µÇ°í, ¹®ÀÚ ÅäÅ« a, b ÀÌ¹Ì µÎ°³ÀÇ Àü°³ÇÒ ¼ö ¾ø´Â ÅäÅ«À» ¾ò¾úÀ¸¹Ç·Î ´õÀÌ»óÀÇ Àü°³¸¦ ¸¶Ä¡°í ±× µÎ°³ÀÇ ÅäÅ«À» ºñ±³ÇÑ´Ù. µû¶ó¼­ `\if ab`ÀÇ °á°ú°¡ ÀÌ Á¶°Ç¹®ÀÇ °ªÀÌ µÇ´Âµ¥, ´ç¿¬È÷ a ¿Í b´Â ´Ù¸£¹Ç·Î °ÅÁþÀÌ´Ù. {{{#!vim tex \def\A{aaa} \def\B{bbb} \if\A\B }}} À§ °æ¿ì´Â ¾î¶³±î? ¾Õ¿¡¼­ ÇÑ°Í Ã³·³ Çϸé `\if\A\B` ´Â °á°úÀûÀ¸·Î `\if aa` À̹ǷΠÀÌ Á¶°Ç¹®ÀÇ °ªÀº ÂüÀÌ´Ù. ´Ù¸¥ ¿¹¸¦ Çϳª ´õ µé¾îº¸ÀÚ. {{{#!vim tex \def\pion#1{$\if#1+\pi^+\else\pi^-\fi$} }}} `\if` expands the tokens, therefore, {{{#!vim tex \let\a+ \pion\a }}} would give the same result as `\pion+`. {{{#!latex \def\pion#1{$\if#1+\pi^+\else\pi^-\fi$} \let\a+ \begin{tabular}{lll} \verb|\pion\a| & °á°ú : & \pion\a \\ \verb|\pion+| &°á°ú : & \pion+ \end{tabular} }}} === `\ifcat` === The `\if` test ignores CategoryCode''''''s; these can be tested by {{{#!vim tex \ifcat }}} This test is a lot like `\if` : TEX expands after it until unexpandable tokens remain. For this test ControlSequences are considered to have CategoryCode 16 (ordinarily, category codes are in the range 0–15), which makes them all equal to each other, and different from all character tokens. === `\ifx` === °¡Àå ¸¹ÀÌ ¾²´Â `\if` °ü·Ã ¹®¹ý ÁßÀÇ Çϳª. `\ifx`´Â µÎ °³ÀÇ tokenÀÌ ÀÏÄ¡ÇÏ´ÂÁö °Ë»çÇÑ´Ù. ±×·¯³ª ¸í·ÉÀ» È®ÀåÇÏÁö´Â ¾Ê´Â´Ù. ÀÌ Á¶°ÇÀÌ Âü(true)ÀÌ µÇ·Á¸é ´ÙÀ½ Áß ¾î´À Çϳª¿©¾ß ÇÑ´Ù. 1. µÎ °³ÀÇ tokenÀÌ ¸í·ÉÀÌ ¾Æ´Ò °Í. µ¿ÀÏÇÑ ¹®ÀÚÄÚµå¿Í CategoryCode¸¦ °¡Áö°Å³ª µ¿ÀÏÇÑ TeX ¿ø½Ã¸í·ÉÀ̰ųª µ¿ÀÏÇÑ `\font`, `\chardef`, `\countdef`¿¡ ÀÇÇØ Á¤ÀÇµÈ °ÍÀÏ °Í. 1. µÎ °³ÀÇ tokenÀÌ ¸í·ÉÀÌ°í `\long`À̳ª `\outer`¿Í °°Àº »óÅ°¡ µ¿ÀÏÇÒ °Í. µ¿ÀÏÇÑ ÆĶó¹ÌÅ͸¦ °¡Áú °Í. µ¿ÀÏÇÑ »óÀ§¼öÁØ È®Àå»óÅ¿¡ ÀÖÀ» °Í. {{{#!vim tex \let\boxhor=\hbox \ifx\boxhor\hbox %is true \font\a=cmr10 \font\b=cmr10 \ifx\a\b %is true }}} {{{#!vim tex \ifx\commandsfile\undefined\else\endinput\fi \let\commandsfile\null }}} ¸í·ÉÀ» È®ÀåÇÏÁö ¾Ê´Â´Ù´Â °ÍÀº, À§¿¡ º¸ÀÎ `\if`¿¡¼­ÀÇ ¿¹¿Í À¯»çÇÏ°Ô {{{#!vim tex \def\pion#1{$\ifx#1+\pi^+\else\pi^-\fi$} }}} ·Î Á¤ÀÇÇÑ ´ÙÀ½ {{{#!vim tex \def\a{+} \pion\a }}} ÇÑ °á°ú´Â, `\if`¿¡¼­¿Í´Â ´Þ¸® $\pi^-$ °¡ µÈ´Ù. Áï, `\a`¸¦ `+`·Î È®ÀåÇÏÁö ¾Ê¾ÒÀ¸¹Ç·Î `\ifx` Á¶°Ç¹®ÀÇ °ªÀº °ÅÁþ(false)ÀÌ µÇ°í, ±× °á°ú `\else\pi^-`°¡ ½ÇÇàµÈ °ÍÀÌ´Ù. === Mode °Ë»ç(`\ifhmode,\ifvmode,\ifmmode`) === • `\ifhmode` is true if TEX is in HorizontalMode or restricted horizontal mode. • `\ifvmode` is true if TEX is in VerticalMode or internal vertical mode. • `\ifmmode` is true if TEX is in MathMode or display math mode. === Number °Ë»ç(`\ifnum, \ifodd`) === {{{#!vim tex \ifnum }}} Àº $>, =, <$ °¡¿îµ¥ ÇϳªÀÌ´Ù.(catcode 12) {{{#!vim tex \ifodd }}} is true if the is odd. === Dimension °Ë»ç(\ifdim) === {{{#!vim tex \ifdim }}} »ç¿ë¹ýÀº `\ifnum`°ú °°Áö¸¸ ¼ýÀÚ°¡ ¾Æ´Ñ [±æÀ̺¯¼ö]°¡ ¿Â´Ù. === Box °Ë»ç(\ifvoid, \ifhbox, \ifvbox) === Contents of box registers can be tested with {{{#!vim tex \ifvoid<8-bit number> }}} which is true if the register contains no box, {{{#!vim tex \ifhbox<8-bit number> }}} which is true if the register contains a horizontal box, and {{{#!vim tex \ifvbox<8-bit number> }}} which is true if the register contains a vertical box. === ÆÄÀÏ °Ë»ç(\ifeof) === ÀÔ·ÂÆÄÀÏÀÇ EOF »óŸ¦ °Ë»çÇÑ´Ù. `\ifeof` ÇüÅ·Π¾²À̸ç, ``°¡ 0-15À̸é falseÀÌ´Ù. ÀÌ ¸í·ÉÀ» ÀÌ¿ëÇÏ¿© ÆÄÀÏÀÌ Á¸ÀçÇÏ´ÂÁö °Ë»çÇÒ ¼ö ÀÖ´Ù. {{{#!vim tex \newread\instream \openin\instream= fname.tex \ifeof\instream \message{File ¡¯fname¡¯ does not exist!} \else \closein\instream \input fname.tex \fi }}} === \iff :) === `$a\iff b$` $$a\iff b$$ === Case¹®(\ifcase) === {{{#!vim tex \ifcase \or ... \or \else \fi }}} `\ifcase`ÀÇ ÀüÇüÀûÀÎ º¸±âÀÌ´Ù. {{{#!vim tex \def\today{\ifcase\month\or January\or February\or March\or April\or May\or June\or July\or August\or September\or October\or November\or December\fi \space\number\day, \number\year} }}} === \newif, \iftrue, \iffalse === '''`\newif`''' »õ·Î¿î Á¶°Ç º¯¼ö¸¦ ¼³Á¤ÇÑ´Ù. {{{#!vim tex \newif\iffoo }}} ÀÌ ÇϳªÀÇ ¸í·ÉÀ¸·Î TeXÀº ¼¼ °³ÀÇ ControlSequences¸¦ Á¤ÀÇÇÑ´Ù. Áï, `\footrue, \foofalse, \iffoo`¸¦ Á¤ÀÇÇÏ´Â °ÍÀÌ´Ù. {{{#!vim tex \def\footrue{\let\iffoo=\iftrue} \def\foofalse{\let\iffoo=\iffalse} \foofalse }}} {{{#!vim tex \iffoo \else \fi }}} == LaTeX2eÀÇ Á¶°Ç¹® == LaTeX2eÀÇ Á¶°Ç¹®Àº TeXÀÇ °æ¿ì¿Í´Â ´Þ¸® ´ë°³ ¼¼ °³ÀÇ ÀÎÀÚ¸¦ °¡Áö´Â Çü½ÄÀ» ÃëÇÑ´Ù. ¿¹ÄÁ´ë {{{#!vim tex \@ifXXX{condition}{iftrue_execution}{iffalse_execution} }}} ÀÌ ÀüÇüÀûÀÎ Çü½ÄÀÌ´Ù. ƯÈ÷ ifthen ÆÐÅ°Áö´Â ÀÌ·¯ÇÑ Çü½ÄÀÇ ¸í·ÉÀ» Á»´õ ÀÚÀ¯·Ó°Ô È°¿ëÇÒ ¼ö ÀÖµµ·Ï ÇÑ´Ù. °¢°¢ÀÇ ÆÐÅ°ÁöµéÀº µ¶ÀÚÀûÀÎ `\if` Çü½ÄÀ» °®Ãß°í ÀÖ´Â °æ¿ì°¡ ¸¹´Ù. ¿¹¸¦ µé¸é FancyHdr ÆÐÅ°ÁöÀÇ `\iffloatpage` ¸í·ÉÀÌ ±× ÇÑ º¸±âÀÌ´Ù. See FancyHdr. === LaTeXÀÇ `\newif, \iffalse, \iftrue` »ç¿ë === `article.cls`ÀÇ titlepage °ü·Ã ¼³Á¤À» º¸¸é ´ÙÀ½°ú °°´Ù. {{{#!vim tex \newif\if@titlepage \@titlepagefalse \DeclareOption{titlepage}{\@titlepagetrue} \ProcessOptions \if@titlepage .... \else .... \fi }}} ÀÌ¿Í µ¿ÀÏÇÑ ±¸¹®¹ýÀ¸·Î ´Ù¸¥ `\if@` Çü½ÄÀÇ ¼³Á¤À» ÇÒ ¼ö ÀÖ´Ù. °£´ÜÇÑ ¿¹¸¦ µé¾îº»´Ù. {{{#!vim tex \newif\if@pdfmake \@pdfmaketrue }}} ¶ó´Â ÀÓÀÇÀÇ ¼³Á¤À» »õ·Î ÇÏ°Ô µÇ¸é, `\@pdfmaketrue`¿Í `\@pdfmakefalse`¸¦ ¼±¾ðÇÒ ¼ö ÀÖ°Ô µÈ´Ù. ÀÌ ÀÌÈķδ {{{#!vim tex \if@pdfmake ... \else ... \fi }}} ÇüÅÂÀÇ TeX Çü½Ä ¸í·ÉÀ» »ç¿ëÇÒ ¼ö ÀÖ´Ù. ±×·¯³ª ÀÌ·± TeX ±¸¹®Çü½ÄÀÇ »ç¿ë¹ýÀº ¹ø°Å·Î¿ï »Ó ¾Æ´Ï¶ó syntax ¿À·ù¸¦ ÀÏÀ¸Å³ °¡´É¼ºÀÌ ³Ê¹« ¸¹¾Æ¼­, ÀÌ °úÁ¤À» LaTeX2e ±¸¹®¹ýÀ¸·Î Æí¸®ÇÏ°Ô Ã³¸®ÇÏ´Â ifthen ÆÐÅ°Áö¸¦ ÀÌ¿ëÇÏ´Â °ÍÀÌ ÁÁ´Ù. ¾Æ·¡ ifthen ÆÐÅ°Áö °ü·Ã ºÎºÐ ÂüÁ¶. === `\@if` === LaTeX¿¡¼­ `\newif`¿Í `\@if`´Â ´ÙÀ½°ú °°ÀÌ Á¤ÀǵǾî ÀÖ´Ù. {{{#!vim tex \def\newif#1{% \count@\escapechar \escapechar\m@ne \let#1\iffalse \@if#1\iftrue \@if#1\iffalse \escapechar\count@} \def\@if#1#2{% \expandafter\def\csname\expandafter\@gobbletwo\string#1% \expandafter\@gobbletwo\string#2\endcsname {\let#1#2}} }}} === `\@ifnextchar` === LaTeX¿¡¼­ °¡Àå ¸¹ÀÌ ¾²´Â Á¶°Ç¹® Áß ÇϳªÀÌ´Ù. ÁÖ¾îÁø ¸í·É¿¡ ÇØ´çÇÏ´Â ºÎºÐÀÇ ´ÙÀ½ ÇÑ ±ÛÀÚ¸¦ Àо °Ë»çÇÑ´Ù. ´ÙÀ½ ¿¹´Â `\@ifnextchar` ¸í·ÉÀ¸·Î Á¦°ö±Ù ±âÈ£¸¦ Á¤ÀÇÇÑ ºÎºÐÀÌ´Ù. {{{#!vim tex \renewcommand\sqrt{\@ifnextchar[\@sqrt\sqrtsign} \def\@sqrt[#1]{\root #1\of} }}} ÀÌ ¸í·ÉÀº `\sqrt[3]`°ú °°Àº ¸í·ÉÀÌ ÀÖÀ¸¸é `\@ifnextchar[`°¡ Âü°ª(true)·Î µÇµ¹·ÁÁö¹Ç·Î `\@sqrt[3]`À» ºÎ¸¥´Ù. ±×·¯³ª `\sqrt`ÀÇ °æ¿ì¿¡´Â `\@ifnextchar[`°¡ °ÅÁþ(false)À̹ǷΠ`\sqrtsign` ¸í·ÉÀ» È£ÃâÇÏ°Ô µÈ´Ù. === `\IfFileExists` === ÀÌ ¸í·ÉÀº ¼¼ °³ÀÇ ÀÎÀÚ¸¦ °¡Áø´Ù. ù¹ø° °ÍÀº ÆÄÀÏÀ̸§ÀÌ°í, ±× ´ÙÀ½Àº °¢°¢ ''then''°ú ''else''¿¡ ÇØ´çÇϴ ó¸® ¸í·ÉµéÀÌ´Ù. ÆÄÀÏÀÌ Á¸ÀçÇÏ¸é µÎ¹ø° ÀÎÀÚ°¡, Á¸ÀçÇÏÁö ¾ÊÀ¸¸é ¼¼¹ø° ÀÎÀÚ°¡ ½ÇÇàµÈ´Ù. ÆÄÀÏÀÌ Á¸ÀçÇÏ¸é ºÒ·¯µéÀ̵µ·Ï ÇÏ´Â ¸í·ÉÀ¸·Î `\InputIfFileExists`°¡ ÀÖ´Ù. ¿ª½Ã ¼¼ °³ÀÇ ÀÎÀÚ¸¦ °¡Áö¸ç, ÆÄÀÏÀÌ Á¸ÀçÇÏ¸é ºÒ·¯µéÀÎ ´ÙÀ½, µÎ¹ø° ÀÎÀÚ·Î ÁÖ¾îÁø ¸í·ÉÀ» ½ÇÇàÇÏ°í, ±×·¸Áö ¾ÊÀ¸¸é ¼¼¹ø° ÀÎÀÚ·Î ÁÖ¾îÁø ¸í·ÉÀ» ½ÇÇàÇÑ´Ù. {{{#!vim tex \newcommand{\printglossary}{% \InputIfFileExists{\jobname.gld}{}{% \typeout{No file exists! \jobname.gld}}% } }}} === `\@ifstar` === º°Ç¥ºÙÀº ¸í·É(`\table*`, `\section*` µî)À» ó¸®Çϱâ À§ÇÑ Å×½ºÆ®. {{{#!vim tex \def\@ifstar#1{\@ifnextchar *{\@firstoftwo{#1} }} }}} === `\@ifpackage[class]loaded, \@ifpackage[class]later, \@ifpackage[class]with` === '''`\@ifpackageloaded`''' To find out if a package has already been loaded. `\@ifpackageloaded{`''package_name''`}{`''then_commands''`}{`''else_commands''`}` '''`\@ifpackagelater`''' To find out if a package has already been loaded with a version more recent than ''_version_''. `\@ifpackagelater{`''package_name''`}{`''_version_''`}{`''then_commands''`}{`''else_commands''`}` '''`\@ifpackagewith`''' To find out if a package has already been loaded with at least the options _options_. `\@ifpackagewith{`''package_name''`}{`''_options_''`}{`''then_commands''`}{`''else_commands''`}` === ifthen ÆÐÅ°Áö === ifthen ÆÐÅ°Áö´Â David Carlisle¾¾°¡ ¸¸µç °ÍÀ¸·Î, Á¶°Ç¹® 󸮸¦ ¿ëÀÌÇÏ°Ô ÇØÁÖ´Â ¿ªÇÒÀ» ÇÑ´Ù. ==== `\ifthenelse` ¸í·É ==== {{{#!vim tex \ifthenelse{}{}{} }}} ``¸¦ boolean ÇÔ¼ö·Î º¸°í °Ë»çÇÏ¿©, ÂüÀ̸é ``¸¦, °ÅÁþÀ̸é ``¸¦ ½ÇÇàÇÑ´Ù. calc ÆÐÅ°Áö¿Í ÇÔ²² ½á¼­ am-pm Çü½ÄÀ» ¹Ù²Ù´Â ±¸¹®À» ÀÛ¼ºÇغ»´Ù. calc ÆÐÅ°Áö¿¡ ´ëÇؼ­´Â [TeX»ê¼ú¿¬»ê]À» º¼ °Í. {{{#!vim tex \usepackage{ifthen,calc} %% preamble \newcommand{\printtime}{% \setcounter{hours}{\time / 60}% \setcounter{minutes}{\time - \value{hours} * 60}% \ifthenelse{\value{hours}>12}% {\setcounter{hours}{\value{hours} - 12}% \thehours:\theminutes\,pm\ \today}% {\thehours:\theminutes\,am\ \today} } }}} ==== `\ifthenelse`¿¡¼­ ¾²ÀÌ´Â Á¶°Ç °Ë»ç ==== `\ifthenelse`ÀÇ Ã¹¹ø° ÀÎÀÚ¿¡ ¿À´Â Á¶°Ç °Ë»ç¸¦ À§Çؼ­´Â ´ÙÀ½°ú °°Àº Çü½ÄÀÌ ¾²ÀÏ ¼ö ÀÖ´Ù. 1. '''³í¸®¿¬»ê''' * `\and` * `\or` * `\not` * °ýÈ£ `\( \)` 1. '''¼ýÀÚ ºñ±³''' * ''number'' $$<$$ ''number'' * ''number'' $$=$$ ''number'' * ''number'' $$>$$ ''number'' * `\isodd{`''number''`}` 1. '''commands ºñ±³''' * `\isundefined{`''command name''`}` * `\equal{`''string''`}{`''string''`}` 1. '''[±æÀ̺¯¼ö] ºñ±³''' * `\lengthtest{`''dimen'' $$<$$ ''dimen''`}` * `\lengthtest{`''dimen'' $$=$$ ''dimen''`}` * `\lengthtest{`''dimen'' $$>$$ ''dimen''`}` 1. '''boolean °Ë»ç''' * `\boolean{`''name''`}` `\equal`¸í·ÉÀ¸·Î °Ë»çÇÏ´Â ``Àº tokenÀ¸·Î È®ÀåµÈ ¸í·É¾îµéÀÌ´Ù. ¸í·ÉÀ» È®ÀåÇÑ °á°ú°¡ µ¿ÀÏ(equal)Çϸé ÀÌ Á¶°ÇÀº Âü(true)ÀÌ µÈ´Ù. `\isodd` ¸í·ÉÀº ``°¡ Ȧ¼öÀ̸é ÂüÀÌ µÈ´Ù. ÀÎÀÚ°¡ ¼ýÀÚ°¡ ¾Æ´Ï°Å³ª Ȧ¼ö°¡ ¾Æ´Ï¸é °ÅÁþ(false)ÀÌ´Ù. `\isundefined{\cmd}`´Â `\cmd`°¡ Á¤ÀǵǾî ÀÖÁö ¾ÊÀ» ¶§ ÂüÀÌ´Ù. `\boolean{xyz}` ¸í·ÉÀº TeXÀÇ ¿ø½Ã `\if`¹®¿¡ ÀÇÇØ Á¤ÀÇµÈ `\ifxyz`°¡ `\iftrue`ÀÏ ¶§ Âü(true) °ªÀ» µÇµ¹·ÁÁØ´Ù. `xyz`´Â `\newboolean` ¶Ç´Â `\provideboolean`¿¡ ÀÇÇÏ¿© Á¤ÀÇµÉ ¼ö ÀÖ´Ù. ±×¸®°í, TeXÀÇ `\newif`¿¡ ÀÇÇÏ¿© Á¤ÀÇµÈ ÅäÅ«¿¡ ´ëÇؼ­µµ ¾µ ¼ö ÀÖ´Ù. ¿¹¸¦ µé¸é, `\boolean{true}`´Â `\iftrue`¸¦ °¡¸®Å°´Â °ÍÀÌ´Ù. ¶Ç, `\boolean{mmode}`´Â `\ifmmode`¿Í °°´Ù. ==== `\newboolean`, `\setboolean` ==== {{{#!vim tex \usepackage{ifthen} %% preamble \newboolean{BoolVar} \setboolean{BoolVar}{true} \ifthenelse{\boolean{BoolVar}}{1}{2} }}} ÀÌ Çü½ÄÀ» ÀÌ¿ëÇÏ¿©, ¾Õ¼­ `\@pdfmake`¸¦ ¼³Á¤Çß´ø ¹æ½Ä¿¡ ÀÀ¿ëÇغ¸ÀÚ. ¸ÕÀú, `@pdfmake`¶ó´Â ºÒ¸° º¯¼ö¸¦ ¸¸µé°í true °ªÀ» ÇÒ´çÇÑ´Ù. {{{ \newboolean{@pdfmake} \setboolean{@pdfmake}{true} }}} ÀÌÁ¦ `\ifthenelse` Á¶°Ç¹®À» ¾´´Ù. {{{ \ifthenelse{\boolean{@pdfmake}}% {.....} % if true {.....} % if false }}} == etoolboxÀÇ Á¶°Ç¹® == etoolbox´Â [e-TeX]ÀÇ primitive¸¦ ÀÌ¿ëÇÏ´Â ´Ù¾çÇÑ ¸í·ÉÀ» Á¦°øÇÑ´Ù. Á¶°Ç °Ë»ç¿Í °ü·ÃÇؼ­ ÇÊ¿äÇÑ °ÍÀÌ °ÅÀÇ ´Ù ÀÖ´Ù½ÃÇÇÇÒ Á¤µµÀ̹ǷΠÀÚ¼¼ÇÑ °ÍÀº etoolbox ¹®¼­¸¦ Âü°íÇÒ °Í. ¿©±â¼­´Â boolean °ü·ÃµÈ °Í°ú Á¶°Ç¹® µÎ¾î °³¸¸À» ¼Ò°³ÇÑ´Ù. Á¶°Ç¿¡ µû¸¥ ½ÇÇàÀº LaTeX Á¶°Ç¹®ÀÇ ¹®¹ýÀ» µû¸¥´Ù. === boolean === * \newbool{name} * \providebool{name} * \setbool{name}{value} : value´Â true³ª false. * \booltrue{name} * \boolfalse{name} * \ifbool{name}{true}{false} * \notbool{name} === Á¶°Ç °Ë»ç === control sequences * \ifdef{controlsequence}{true}{false}, \ifcsdef{name}{true}{false} * \ifundef{controlsequence}{true}{false}, \ifcsundef{name}{true}{false} * \ifdefequal{controlsequence}{controlsequence}{true}{false}, \ifcsequal{name}{name}{true}{false} string * \ifstrequal{string}{string}{true}{false} * \ifstrempty{string}{true}{false} * \ifblank{string}{true}{false} arithmetic * \ifnumcomp{integer}{relation}{integer}{true}{false} : integer´Â e-TeXÀÇ number expression ¾µ ¼ö ÀÖÀ½. * \ifnumequal{integer}{integer}{true}{false} * \ifnumgreater, \ifnumless * \ifnum.... ²ÃÀÇ ¸í·É¿¡ »ó´çÇÏ´Â \ifdim... ¸í·ÉµéÀÌ ÀÖÀ½. * \ifnumodd == Loop == === PlainTeXÀÇ `\loop` `\repeat` === {{{#!vim tex \newcount\MyCount \MyCount=0 \newcount\Summation \Summation=0 \loop \message{\number\MyCount} \advance\MyCount by 1 \advance\Summation by \MyCount \hbox{MyCounter Number: \number\MyCount\quad Summatioin: \number\Summation} \ifnum\MyCount<10\repeat \bye }}} === ifthen ÆÐÅ°ÁöÀÇ `\whiledo` === {{{#!vim tex \whiledo{}{} }}} ``´Â À§¿¡¼­ ¾ð±ÞÇÑ Á¶°Ç°Ë»ç¿Í µ¿ÀÏÇÑ ±¸¹®À» »ç¿ëÇÑ´Ù. ÀÌ Á¶°ÇÀÌ trueÀÎ ÇÑ ``°¡ ½ÇÇàµÈ´Ù. 1ºÎÅÍ 10±îÁö ´õÇÏ¿© ÇÕÀ» Ãâ·ÂÇغ»´Ù. {{{#!vim tex \documentclass{article} \usepackage{ifthen,calc} \usepackage{hfont} \begin{document} \newcounter{myloopcnt} \setcounter{myloopcnt}{0} \newcounter{summation} \setcounter{summation}{0} \noindent\textbf{1ºÎÅÍ 10±îÁö ´õÇغ»´Ù.} \noindent\whiledo{% \value{myloopcnt} < 10}{% \stepcounter{myloopcnt}% \setcounter{summation}{\thesummation + \themyloopcnt}% \themyloopcnt¹ø° ½ÇÇà : \qquad ÇöÀç±îÁö ÇÕ°è \thesummation\\} \end{document} }}} === `\for`-loop === {{{#!vim tex \makeatletter \def\for#1#2#3{\@ifnextchar[{\@for@{#1}{#2}{#3}}{\@for@{#1}{#2}{#3}[1]}} \long\def\@for@#1#2#3[#4]#5{\setcounter{#1}{#3}\addtocounter{#1}{1}% \edef\for@loopend{\arabic{#1}}% \setcounter{#1}{#2}% \loop \ifnum \expandafter\the\csname c@#1\endcsname < \for@loopend\relax #5\addtocounter{#1}{#4}\repeat} \newcounter{repeatcnt} \makeatother }}} °°Àº ±â´ÉÀ» ÀÌ `\for` ¹®À» ½á¼­ ±¸ÇöÇغ¸ÀÚ. ¿©±â¼­´Â ifthen ÆÐÅ°Áö°¡ ºÒÇÊ¿äÇÏ´Ù. {{{#!vim tex \documentclass{article} \usepackage{calc} \usepackage{hfont} \makeatletter \def\for#1#2#3{\@ifnextchar[{\@for@{#1}{#2}{#3}}{\@for@{#1}{#2}{#3}[1]}} \long\def\@for@#1#2#3[#4]#5{\setcounter{#1}{#3}\addtocounter{#1}{1}% \edef\for@loopend{\arabic{#1}}% \setcounter{#1}{#2}% \loop \ifnum \expandafter\the\csname c@#1\endcsname < \for@loopend\relax #5\addtocounter{#1}{#4}\repeat} \newcounter{repeatcnt} \makeatother \begin{document} \newcounter{summation} \setcounter{summation}{0} \noindent\textbf{1ºÎÅÍ 10±îÁö ´õÇغ»´Ù.} \noindent \for{repeatcnt}{1}{10}% {\setcounter{summation}{\thesummation + \therepeatcnt}% \therepeatcnt¹ø° ½ÇÇà : \qquad ÇöÀç±îÁö ÇÕ°è \thesummation\\} \end{document} }}} === multido === Timothy van Zandt ¾¾°¡ ÀÛ¼ºÇÑ ¸ÅÅ©·ÎÀÌ´Ù. {{{multido.tex}}}°ú {{{multido.sty}}}·Î »ç¿ëÇÒ ¼ö ÀÖ´Ù. PSTricks ¸ÅÅ©·Î´Â ÀÌ ½ºÅ¸ÀÏÀ» ÀÚµ¿À¸·Î ºÒ·¯µéÀδÙ. {{{ \multido{_variables_}{_repetitions_}{_stuff_} }}} ¿©±â¼­ {{{_variables_}}}Àº ´ÙÀ½ Çü½ÄÀ¸·Î ¾²ÀδÙ. {{{ variable = initial value + increment }}} variable·Î ¿Ã ¼ö ÀÖ´Â °ÍÀº Dimension, Number, Integer, RealÀÌ°í °¢°¢ {{{\d, \n, \i, \r}}} µîÀ¸·Î Çü½ÄÀ» Áö½ÃÇÑ´Ù. ´ÙÀ½ ¿¹¸¦ º¸¶ó. {{{ \multido{}{10}{\TeX\ } \multido{\d=2pt+3pt}{5}{\d, } \multido{\n=2+3}{10}{\n, } \multido{\i=2+-3}{10}{\i, } \multido{\r=2+3.05}{6}{\r, } }}} * {{{\multido}}} ¸í·ÉÀº nestingÀÌ °¡´ÉÇÏ´Ù. * ½ÇÇàÀü¿¡ Ä«¿îÅ͸¦ 1¾¿ Áõ°¡½ÃÅ°´Â {{{\mmultido}}} ¸í·Éµµ ÀÖ´Ù. * {{{\multidostop}}}Àº multido ¹Ýº¹¹®À» ÇöÀç À§Ä¡¿¡¼­ °­Á¦·Î ºüÁ®³ª°¡°Ô ÇÑ´Ù. == ÀÀ¿ë : Á¶°ÇºÎ ÄÄÆÄÀÏ == === TTY¸¦ ÅëÇÏ¿© »ç¿ëÀÚ ÀÔ·ÂÀ» ¹Þ¾ÆµéÀÌ´Â ¹æ¹ý === main.tex ÆÄÀÏÀ» ÄÄÆÄÀÏ ½ÃµµÇϸé È­¸é¿¡ "Yes/No"¸¦ ¹¯°í, `y` ¶Ç´Â `n`·Î ´äÇÏ´Â µ¥ µû¶ó¼­ ´Ù¸¥ °á°ú¸¦ º¸¿©ÁÖ´Â °£´ÜÇÑ ¼Ò½º¸¦ ÀÛ¼ºÇغ¸ÀÚ. ÇÑ±Û Å͹̳ÎÀÏÁö ¾Ë ¼ö ¾øÀ¸¹Ç·Î È­¸é»óÀÇ ÀÀ´äÀº ¿µ¹®À¸·Î ÇÏ´Â °ÍÀ¸·Î ÇÑ´Ù. {{{#!vim tex \documentclass{article} \usepackage{hfont} \usepackage{ifthen} }}} ¿©±â¿¡¼­ºÎÅÍ Preamble ¼³Á¤À» ½ÃÀÛÇÑ´Ù. ttyin, ttyoutÀ» Á¤ÀÇÇÏ°í `\Msg` ¸í·É°ú `\Ask` ¸í·ÉÀ» Á¤ÀÇÇÑ´Ù. {{{#!vim tex \makeatletter \chardef\ttyin16 \chardef\ttyout16 \def\iden#1{#1} \def\strip#1#2 \@gobble{\def #1{#2}} \def\@defpar{\par} \def\yes{yes} \def\y{y} \def\n{n} \def\Msg{\immediate\write\ttyout} \def\Ask#1#2{% \message{#2}\read\ttyin to #1\ifx#1\@defpar\def#1{}\else \iden{\expandafter\strip \expandafter#1#1\@gobble\@gobble} \@gobble\fi} \makeatother }}} »ç¿ëÀÚ ÀÎÅÍÆäÀ̽º¸¦ À§ÇÑ `YesOrNo`¶ó´Â boolean º¯¼ö(ÀÌ°ÍÀ» ¾²·Á¸é ifthen ÆÐÅ°Áö°¡ ÇÊ¿äÇÏ´Ù.)¸¦ ¼³Á¤ÇÑ´Ù. ±âº»°ªÀº true. {{{#!vim tex \newboolean{YesOrNo} \setboolean{YesOrNo}{true} }}} º»¹® ½ÃÀÛ. {{{#!vim tex \begin{document} }}} È­¸é¿¡ "Please Answer Me, Yes or No(y/n)?"À̶ó´Â ¸Þ½ÃÁö¸¦ º¸¿©ÁÖ°í »ç¿ëÀÚ ÀÔ·ÂÀ» ¹Þ¾ÆµéÀδÙ. {{{#!vim tex \Msg{**************************************************^^J% * Please Answer Me, Yes or No(y/n)?}% \Ask\answer{% **************************************************}% }}} ¸¸¾à `y`°¡ ÀԷµǸé `YesOrNo`¸¦ true·Î, ±×¹ÛÀÇ °æ¿ì¿¡´Â ¸ðµÎ false·Î ¼³Á¤ {{{#!vim tex \ifx\y\answer\setboolean{YesOrNo}{true} \else\setboolean{YesOrNo}{false}\fi }}} Ãâ·Â·çƾ. `YesOrNo`°¡ trueÀÎÁö falseÀÎÁö¿¡ µû¶ó ´Ù¸¥ ¸Þ½ÃÁö¸¦ DVI·Î Ãâ·ÂÇÑ´Ù. ifthen ÆÐÅ°ÁöÀÇ `\ifthenelse` ¸í·ÉÀ» »ç¿ëÇÔ. {{{#!vim tex \ifthenelse{\boolean{YesOrNo}}% {`¿¹½º'¸¦ ¼±ÅÃÇϼ̽À´Ï´Ù.}% {`³ë'¸¦ ¼±ÅÃÇϼ̽À´Ï´Ù.} }}} ¹®¼­ ³¡. {{{#!vim tex \end{document} }}} === ¸í·ÉÇàÀ» ÀÌ¿ëÇÏ´Â ¹æ¹ý === °°Àº ÀÏÀ» ¸í·ÉÇà¿¡¼­ ÇѲ¨¹ø¿¡ ÇÏ´Â ¹æ¹ýÀº ¾øÀ»±î? ±× °¡¿îµ¥ °¡Àå ½¬¿î ¹æ¹ýÀ» »ý°¢Çغ¸ÀÚ. ¿øº»À» ´ÙÀ½°ú °°ÀÌ ÀÛ¼ºÇÑ´Ù. {{{#!vim tex \documentclass{article} \usepackage{hfont} \usepackage{ifthen} \makeatletter \chardef\ttyin16 \chardef\ttyout16 \def\iden#1{#1} \def\strip#1#2 \@gobble{\def #1{#2}} \def\@defpar{\par} \def\Ask#1#2{% \message{#2}\read\ttyin to #1\ifx#1\@defpar\def#1{}\else \iden{\expandafter\strip \expandafter#1#1\@gobble\@gobble} \@gobble\fi} \def\Msg{\immediate\write\ttyout} \def\yes{yes} \def\y{y} \def\n{n} \makeatother \newboolean{YesOrNo} \setboolean{YesOrNo}{true} \def\getYesOrNo{% \Msg{**************************************************^^J% * Please Answer Me, Yes or No(y/n)?}% \Ask\answer{% **************************************************}% } \newcommand\DetermineYesOrNo{% %% ¸¸¾à \answer°¡ ÀÌ¹Ì ÁÖ¾îÁ®ÀÖÁö ¾Ê´Ù¸é \ifx\answer\undefined \getYesOrNo \else\fi %% \answer¿¡ µû¶ó YesOrNo ºÒ¸°°ªÀ» °áÁ¤ÇÔ \ifx\y\answer\setboolean{YesOrNo}{true} \else\setboolean{YesOrNo}{false}\fi } %%% Ãâ·Â¹®ÀÚ¿­ \newcommand\YesMessage{`¿¹½º'¸¦ ¼±ÅÃÇϼ̽À´Ï´Ù.} \newcommand\NoMessage{`³ë'¸¦ ¼±ÅÃÇϼ̽À´Ï´Ù.} \begin{document} \DetermineYesOrNo \ifthenelse{\boolean{YesOrNo}}% {\YesMessage}% {\NoMessage} \end{document} }}} ¸í·ÉÇà¿¡¼­´Â ´ÙÀ½°ú °°ÀÌ Ã³¸®ÇÑ´Ù.(ÆÄÀÏÀ̸§Àº test.tex) {{{ #> latex \def\answer{y}\input{test} }}} `YesOrNo`¸¦ `no`·Î ÇÏ°í ½ÍÀ¸¸é {{{ #> latex \def\answer{n}\input{test} }}} ¸¸¾à ´Ü¼øÇÏ°Ô `latex test`¸¸À» ½ÇÇàÇÑ´Ù¸é ¾Õ¼­¿Í °°Àº ´ëÈ­½ÄÀ¸·Î (y/n)À» È­¸é¿¡¼­ ¹°¾î¼­ ¾ò´Â´Ù. ÀÌ°ÍÀ» ¹èÄ¡ÆÄÀÏ ¶Ç´Â ½ºÅ©¸³Æ®·Î ½ÇÇàÇÒ ¼ö ÀÖÀ» °ÍÀÌ´Ù. ---- ¾ÕºÎºÐÀº Victor Eijkhout, ''TeX By Topic''(http://www.eijkhout.net/tbt/), pp.112-117. ¿¡¼­ ÁÖ·Î ¹ßÃé, ÀοëÇÏ¿´½À´Ï´Ù. DeleteMe ÀÌ ºÐ ¼ºÇÔÀ» ¿ìÂî ÀÐÁö¿ä? --[Karnes] My name is approximately pronounced "ike-howt". -- Victor Eijkhout [HJhan] ''DeleteMe \ifXXX °°Àº °ÍÀÌ ¸¹ÀÌ »ç¿ëµÇ´øµ¥ ÀÚ¼¼ÇÑ ¼³¸íÀ» ¸ø ã¾Ò½À´Ï´Ù. ;) °í¼ö´ÔµéÀÇ ¼³¸íÀ» µé¾úÀ¸¸é ÇÕ´Ï´Ù. --[[Date(2004-03-27T23:24:44)]][hermian]'' DeleteMe À¯¿ëÇÑ ÆäÀÌÁö ÀÛ¼ºÇØÁֽɿ¡ °¨»çÀÇ ¸»¾¸ µå¸³´Ï´Ù. LaTeXÀ» ¾²·Á¸é ÄÄÇ»Å͵µ Á» ¾Ë¾Æ¾ßÇÏ°í, ¼öÇеµ, ÆùÆ®µµ Á» ¾Ë¾Æ¾ßÇÏ°í, ÆíÁýµµ Á¶±Ý ¾Ë¸é ÁÁ°í... ±×·¯³ª °á±¹ ÀÌ [Conditionals]À» ¾Ë¾Æ¾ß °¡Àå È¿À²ÀûÀÎ ¹®¼­ÀÛ¼ºÀ» ÇÒ ¼ö ÀÖÀ¸¸®¶ó´Â »ý°¢À» Áö¿ï ¼ö ¾ø½À´Ï´Ù. --[Progress] °í¸¿½À´Ï´Ù. ;) À̵û±Ý ĪÂù¹Þ±¸ ½ÍÀ» ¶§µµ ÀÖ´ä´Ï´Ù. ´¥¶ì¹Ì Ç߰ŵ¢¿ä. :) µµ¿òÀÌ µÇ¸é ÁÁ°Ú½À´Ï´Ù. --[Karnes] ±×³É ÆäÀÌÁö¸¸ ´ú·· ¸¸µé¾ú´õ´Ï ³¯¸¶´Ù ¹«·°¹«·°ÀÚ¶ó´Â±º¿ä . Àß°¡²Ù¾î ÁֽŠ[Karnes]´Ô °¨»çÇÕ´Ï´Ù. ''´¥¶ì¹Ì'' °¡ ¾Ð±ÇÀÔ´Ï´Ù. :) ¿­½ÉÈ÷ °øºÎÇÏ°Ú½À´Ï´Ù. ~²Ù¹÷ --[hermian] ---- Contributors: [Karnes] ---- CategoryTeXMacro