KTUGFaq

KTUG FAQ

·Î±×ÀÎ:
ºñ¹Ð¹øÈ£:
°¡ÀÔ
If you always postpone pleasure you will never have it. Quit work and play for once!
FrontPage › noweb

nowebÀ̶õ

noweb Àº LaTeX À» »ç¿ëÇÏ´Â cweb ÀÌ´Ù. web/cweb ÀÌ TeX À» ´ë»óÀ¸·Î ÇÏ´Â °Íó·³ noweb Àº LaTeX À» ´ë»óÀ¸·Î ÇÑ´Ù. Áï, ±âÁ¸ÀÇ ¸ðµç LaTeX ÀÇ ÆÐÅ°Áö¸¦ cweb ¿¡¼­ Á¦°øÇÏ´Â literate programming °ú ÇÔ²² »ç¿ëÇÒ ¼ö ÀÖ´Ù.

´Ù¿î·Îµå/ÀνºÅç

http://www.eecs.harvard.edu/nr/noweb/ ¿¡¼­ ¼Ò½º¸¦ ´Ù¿î·Îµå ÇÏ¿© ÄÄÆÄÀÏ ÇØÁÖ¸é µÈ´Ù.

PC ¿¡¼­ ÀνºÅç Çϱâ

´ÙÀ½ÀÇ À§Ä¡¸¦ Âü°íÇÑ´Ù. http://www.literateprogramming.com/noweb/nowebinstall.html

¸Æ¿¡¼­ ÀνºÅç Çϱâ1

°¡Àå ½±°Ô ÀνºÅç ÇÏ´Â °ÍÀº port (http://www.macports.org/) ¸¦ »ç¿ëÇÏ´Â °ÍÀÌ´Ù.
sudo port install noweb
/opt/local/bin ¿¡ noweb ÀÌ ¼³Ä¡µÈ´Ù.

¸Æ¿¡¼­ ÀνºÅç Çϱâ2

noweb Àº ¿ÜºÎ ÇÁ·Î±×·¥À» ºÒ·¯¼­ Ãß°¡ 󸮸¦ ÇÏ´Â ±â´ÉÀÌ ÀÖ´Ù. ¿ÜºÎ ÇÁ·Î±×·¥Àº C Äڵ带 ÄÄÆÄÀÏÇÑ ¹ÙÀ̳ʸ®°Å³ª, awk ÇÁ·Î±×·¥À̰ųª icon ÇÁ·Î±×·¥ÀÌ´Ù. ±×·¯¹Ç·Î noweb À» ÀÌ¿ëÇؼ­ ´Ù¾çÇÑ ±â´ÉÀ» ÀÌ¿ëÇϱâ À§Çؼ­´Â ¹Ýµå½Ã awk ¿Í icon ÀÌ ±ò·Á ÀÖ¾î¾ß ÇÑ´Ù.
  • ÀÏ´Ü src µð·ºÅ丮·Î À̵¿ÇÑ´Ù.
  • awk ¸¦ nawk ·Î ÀνĽÃÅ°±â sudo ln -s /usr/bin/awk /usr/bin/nawk
  • icon Àº ´ÙÀ½ÀÇ À§Ä¡¿¡ ÀÖ´Ù. http://www.cs.arizona.edu/icon/
    • ¸ÆÀÇ °æ¿ì ¹ÙÀ̳ʸ®°¡ ÀÖÀ¸¹Ç·Î À̸¦ ÀνºÅç ÇÏ¿© »ç¿ëÇϵµ·Ï ÇÑ´Ù. ÀÎÅÚ ¸ÆÀÇ °æ¿ì¿¡µµ Àß µ¿ÀÛÇÑ´Ù.
    • icon ¹ÙÀ̳ʸ®´Â PATH»ó¿¡ À§Ä¡½ÃÄÑÁØ´Ù.
  • src µð·ºÅ丮¿¡¼­ Makefile À» ´ÙÀ½°ú °°ÀÌ º¯°æÇÑ´Ù. ¿©±â¿¡¼­ º¸¸é ¶óÀ̺귯¸® ¼Ò½º°¡ awk ÀÏ °æ¿ì¿Í icon ÀÏ °æ¿ì, µÎ°¡Áö°¡ ÀÖÀ¸¹Ç·Î ÇØ´çµÇ´Â LIBSRC¸¦ ÁöÁ¤ÇØÁÖ°í ¸ÞÀÌÅ© ÇØÁÖ¾î¾ß ÇÑ´Ù. Áï, ÀüüÀûÀ¸·Î º¸¸é make install À» µÎ¹øÇØÁÖ¾î¾ß ÇÑ´Ù.
    #LIBSRC=./icon 
    LIBSRC=awk
    # If you have no Icon compiler, but do have icont, make ICONC=icont
    ICONC=icont
    ICONT=icont
      
  • Åؼ³Á¤ µð·ºÅ丮µµ º¯°æÇØ ÁÖ¾î¾ß ÇÑ´Ù. ÀÌ °æ¿ì (´ç¿¬È÷) ÇÊ¿äÇÑ °æ¿ì µð·ºÅ丮¸¦ ¸¸µé¾î ÁÖ¾î¾ß ÇÑ´Ù.
    TEXINPUTS=/Users/smcho/Library/texmf/tex/latex/
      
  • ÀÌÈÄ make; sudo make install; ÇØÁÖ¸é ÀÚµ¿À¸·Î ±ò¸°´Ù.
    • ¹Ýµå½Ã ¸ðµç ¾ÆÀÌÄÜ ¼Ò½ºÄڵ尡 ±ò¸®´Â °ÍÀ» È®ÀÎÇØ ÁÖ¾î¾ß ÇÑ´Ù!!!!

¸®´ª½º¿¡¼­ ÀνºÅç

¸ÆÀÇ °æ¿ì¸¦ Âü°íÇؼ­ ÀνºÅç ÇÏ¸é µÉ°ÍÀ¸·Î »ý°¢µË´Ï´Ù. -- smcho

¿ìºÐÅõ¿¡¼­´Â ²Ù·¯¹Ì °ü¸®ÀÚ¿¡ µî·ÏµÇ¾î ÀÖ´Ù. ´Ù¸¥ ÆÐÅ°Áö¿Í µ¿ÀÏÇÏ°Ô ¼³Ä¡ÇÑ´Ù.

knoweb

±âÁ¸ÀÇ noweb À» °³¼±ÇÑ ½ºÅ¸ÀÏ ÆÄÀÏ, http://www.k-online.com/~joer/noweb/knoweb.html ¿¡¼­ ´Ù¿î·Îµå ¹ÞÀ» ¼ö ÀÖ´Ù.

¿¹Á¦ ¸¸µé±â

°£´ÜÈ÷ ±¸±¸´ÜÀ» ÇØÁÖ´Â ¿¹Á¦¸¦ ¸¸µé¾î º¸¾Ò´Ù.

\documentclass{article}
\usepackage{noweb}
\usepackage{dhucs}
\begin{document}

\section{±¸±¸´Ü ¸¸µé±â}
±¸±¸´ÜÀ» ÇØÁÖ´Â ÇÁ·Î±×·¥À» ÀÛ¼ºÇØ º¸ÀÚ. 

@ 
°¡Àå ³ôÀº ·¹º§¿¡¼­´Â ´ÙÀ½°ú °°ÀÌ Ã³¸®ÇÒ ¼ö ÀÖ´Ù. 
<<nine.c>>=
<<headers>>
<<engine>>
<<main>>
<<print>>
<<test>>
@

»óÅ´ [[status]]·Î Ç¥½Ã°¡ °¡´ÉÇÏ´Ù. 
<<headers>>=
/* Çì´õÆÄÀÏ */
#include <stdio.h>
#include <assert.h>
@

<<engine>>=
/*
   DoxyGen string
*/
int engine(int x, int y)
{
  assert(x >= 0 && y >= 0);
  return (x * y);
}
@

<<print>>=
/*
  Write down the result.
*/
int print(int x, int y, int z)
{
  printf("(%d) X (%d) = (%d)\n",x,y,z);
}
@

<<main>>=
/*
  Main Routine
*/
int main()
{
  int i, j;
  for (i = 1; i < 3; i++) {
    for (j = 1; j < 3; j++) {
      int z = engine(i,j);
      print(i,j,z);
    }
  }
}
@

<<test>>=
/*
  Test routine
*/
int test()
{
  printf("testme\n");
}
@
\end{document}

»ç¿ë¹ý

ÅØÆÄÀÏ ¾ò±â
noweave -delay nine.nw > nine.tex

¼Ò½ºÄÚµå ¾ò±â
notangle nine.nw -Rnine.c > nine.c

°á°ú

Åؼҽº¸¦ ÄÄÆÄÀÏ Çϸé pdf ¸¦ ¾òÀ» ¼ö ÀÖ´Ù.

¼Ò½ºÄڵ带 ÄÄÆÄÀÏ Çϸé ÇÁ·Î±×·¥À» ¾òÀ» ¼ö ÀÖ´Ù.
 $ gcc nine.c -o nine
$ ./nine 
(1) X (1) = (1)
(1) X (2) = (2)
(2) X (1) = (2)
(2) X (2) = (4)

ÄÚµå ûũ

noweb Àº <<>> ·Î »ó¡µÇ´Â ÄÚµå ûũµéÀ» Çϳª·Î ¸ð¾ÆÁÖ´Â ±â´ÉÀ» Á¦°øÇÑ´Ù. \nowebchunks ¸í·ÉÀ» ÀÌ¿ëÇÑ´Ù.

À妽º

noweb Àº ¾î¶°ÇÑ Á¤ÀÇ°¡ ¾îµð¿¡¼­ »ç¿ëµÇ¾ú´ÂÁö¸¦ ¾Ë·ÁÁÖ´Â index ¸¦ ¸¸µé ¼ö ÀÖ´Ù.

À妽º Á¤ÀÇ

[[main]] °ú °°ÀÌ »ç¿ëÇϸé main ÀÌ À妽º·Î ±â·ÏµÈ´Ù.

À妽º ÁöÁ¤

@ %def main À» ÄÚµåûũ ´ÙÀ½¿¡ ±â·ÏÇϸé À妽º¿Í ÄÚµåûũ°¡ ¿¬°áÀÌ µÈ´Ù. main Àº À妽º·Î »ç¿ëÇÒ, ¹Ì¸® Á¤ÀÇµÈ °ªÀÌ´Ù.

À妽º »ý¼º

\nowebindex ¸¦ »ç¿ëÇÏ¿© »ý¼ºÇÑ´Ù.
  • noweb ¸í·É¿¡¼­ -index ¸¦ Ãß°¡ÇÑ´Ù.

Ã¥°¥ÇÇ

º¸ÅëÀÇ hyperref ¸¦ »ç¿ëÇÏ´Â °Í ¸¸À¸·Îµµ ÄÚµå ûũ ³¢¸®ÀÇ ¿¬°áÀÌ ÀÚµ¿À¸·Î »ý¼ºµÈ´Ù.
\usepackage[pdftex,colorlinks,backref,bookmarks
  ,pdftitle={knoweb.sty}
  ,pdfauthor={smcho}
  ,pdfpagemode={UseOutline}
  ,bookmarksopen={true}
  ]{hyperref}

Å« ÇÁ·Î±×·¥ ¸¸µé±â

À¥Àº ÇϳªÀÇ nw ÆÄÀÏ¿¡¼­ ¿©·¯°³ÀÇ ¼Ò½ºÆÄÀÏÀ» ¸¸µé¾î ³¾ ¼ö°¡ ÀÖ´Ù. -R ¿É¼ÇÀ» »ç¿ëÇÏ¸é µÈ´Ù.

¶ÇÇÑ À¥Àº ¿©·¯°³ÀÇ nw ÆÄÀÏÀ» ¸¸µé°í, °¢°¢À» tex À¸·Î º¯È¯ÇÑ ´ÙÀ½¿¡ \input À» ÀÌ¿ëÇؼ­ ÇϳªÀÇ 'Å«' ÅØ ÆÄÀÏÀ» ¸¸µé¾î ³¾ ¼ö ÀÖ´Ù.

ÀÌ µÎ°¡Áö¸¦ Á¾ÇÕÇÏ¸é ¾ÆÁÖÅ« ÇÁ·ÎÁ§Æ®¸¦ À¥À¸·Î ¸¸µé¾î ³¾ ¼ö°¡ ÀÖ´Ù. ±×·¯³ª ÀÌ °æ¿ì make ÆÄÀϵµ µ¿½Ã¿¡ ¸¸µé¾î¾ß ÇÑ´Ù.

´ÙÀ½¿¡ Makefile ÀÇ ¿¹¸¦ µé¾ú´Ù. make tex À» ÀÌ¿ëÇؼ­ ÇöÀç µð·ºÅ丮¿¡ ÀÖ´Â ¸ðµç nw ÆÄÀÏ¿¡¼­ ÅØ ¼Ò½º¿Í ¸ÅÆ®·¦(.m) À» ÀÚµ¿À¸·Î »ý¼ºÇØ ³»°í, ÀÌÈÄ¿¡ make¸í·ÉÀ» ÀÌ¿ëÇؼ­ pdf ¸¦ ¸¸µå´Â ±¸Á¶·Î µÇ¾î ÀÖ´Ù.

±âÁ¸ÀÇ Makefile ¿¡ ºñÇؼ­ ¼ÐÀÇ for ±â´ÉÀ» ÀÌ¿ëÇØ¾ß ÇÑ´Ù. ÀÌ°ÍÀº ¿ÀºêÁ§Æ® ÆÄÀÏÀ» ¸ð¾Æ¼­ ÇϳªÀÇ ½ÇÇàÆÄÀÏÀ» ¸¸µå´Â º¸ÅëÀÇ C ÇÁ·Î±×·¡¹Ö °ú´Â ´Ù¸£°Ô, ÇϳªÀÇ tex ÆÄÀÏ¿¡ ´Ù¼öÀÇ .tex ÆÄÀÏÀ» include ÇÏ´Â ±¸Á¶¸¦ ÀÌ¿ëÇØ¾ß Çϱ⠶§¹®ÀÌ´Ù.

¸¸ÀÏ, Make °íÀ¯ÀÇ ±â´ÉÀ» ÀÌ¿ëÇؼ­ º¯°æµÈ ÆÄÀϸ¸À» ó¸®Çϱ⠹ٶõ´Ù¸é ÀÏÀÏÀÌ abc.m : abc.nw ó·³ ¼Ò½ºÆÄÀÏÀÇ ÀÇÁ¸¼ºÀ» ±â·ÏÇØ ÁÖ¸é µÈ´Ù. ¿¹¿¡¼­´Â ÀÚµ¿À¸·Î 󸮵Ǵ ¹æ¹ýÀ» »ç¿ëÇß´Ù.

SHELL=/bin/sh
NOWEAVE=noweave
NOTANGLE=notangle
NODEFS=nodefs
PDFLATEX=pdflatex

TARGET=codeanalysis
NWS = $(wildcard *.nw)
NAMES = $(NWS:.nw=)
TEXS = $(NWS:.nw=.tex)

.SUFFIXES: .nw .tex .dvi .html .pdf .m
.SECONDARY: $(TEXS) # Don't delete the tex file
.PHONY: tex

all: $(TARGET).pdf

test:
	@echo $(TEXS)
	
pdf:
	$(PDFLATEX) $(TARGET).tex

tex: 
	@for t in $(NAMES); do \
	echo "processing $$t.nw"; \
	$(NODEFS) -autodefs c $$t.nw > $$t.defs; \
	$(NOWEAVE) -delay -filter btdefn -autodefs c -indexfrom $$t.defs $$t.nw > $$t.tex; \
	$(NOTANGLE) -R$$t $$t.nw > $$t.m; \
	done

$(TARGET).pdf : $(TARGET).tex
	$(PDFLATEX) $< -o $@
	
.nw.tex:
	$(NODEFS) -autodefs c $*.nw > $*.defs
	$(NOWEAVE) -delay -filter btdefn -autodefs c -indexfrom $*.defs $*.nw > $@
	

sclean:
	rm -f *~  *.dvi *.log *.html *.pdf *.m *.out *.defs

clean:
	rm -f *~  *.dvi *.log *.html *.pdf *.m *.out *.defs *.tex *.aux
	

±âŸ

  • notangle ÀÌ ¸¸µé¾î ÁÖ´Â ¼Ò½ºÄÚµå´Â Á¶±Ý ´ä´äÇÑ ´À³¦À» ÁØ´Ù. ÀÌ°æ¿ì bcpp µîÀ» ÀÌ¿ëÇÏ¿© ¼Ò½º¸¦ ¿¹»Ú°Ô º¯È¯ÇÒ ¼ö ÀÖ´Ù.
  • memoir ¸¦ »ç¿ëÇÒ °æ¿ì \tt µî°ú °°Àº ÆùÆ® ¸í·ÉÀÌ memoir ¿¡ ¾ø´Ù°í ¿¡·¯°¡ ³­´Ù. ÀÌ°Ç memoirÀÇ "¹®Á¦"°¡ ¾Æ´Ï°í \tt °°Àº non-compatibleÇÑ command¸¦ ¾²°í ÀÖ´Â ½ºÅ¸ÀÏÀÌ ¹®Á¦À̱⠶§¹®¿¡ ¹ß»ýÇÑ´Ù. ÀÌ°æ¿ì [oldfontcommands] ¿É¼ÇÀ» »ç¿ëÇØ¾ß ÇÑ´Ù.

¿¹Á¦

À¯¸íÇÑ wc ¸¦ noweb À» ÀÌ¿ëÇؼ­ ¸¸µé¾î º»´Ù.

´Ù¿î·Îµå

@wc.zip (12.41 KB)

ÄÄÆÄÀÏ

nodefs -autodefs c wc.nw > wc.defs
noweave -delay -filter btdefn -autodefs c -indexfrom wc.defs wc.nw > wc.tex
pdflatex wc.tex
À¸·Î pdf ¸¦ »ý¼ºÇÒ ¼ö ÀÖ´Ù.

notangle wc.nw > wc.c
·Î C ¼Ò½ºÄڵ带 »ý¼ºÇÒ ¼ö ÀÖ´Ù.

°á°ú

@wc.pdf (204.25 KB) ¿¹Á¦¿¡¼­, À妽º ¹× ÄÚµå Á¤Å©°¡ pdf »ó¿¡¼­ ¿Ïº®ÇÏ°Ô ¿¬°áµÇ¾î Áö´Â °ÍÀ» º¼ ¼ö ÀÖ´Ù. Çѱ۵µ dhucs ¸¦ »ç¿ëÇÏ´Â °æ¿ì¿¡´Â ¹®Á¦¾øÀÌ Àß µÈ´Ù.



^
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2008-12-17 02:11:18
Processing time 0.0478 sec