#!/usr/bin/perl use strict; use warnings; unlink "title.tex"; unlink "abstract.tex"; unlink "abstract-e.tex"; unlink "cover.tex"; # for msdos system("rm -f 0*.tex 1*.tex 2.tex 3.tex 4.tex 5.tex 6.tex 7.tex 8.tex 9.tex"); my $alt0 = "fig000"; my $paper = $ARGV[0]; my $fh; &Pick('>', "title.tex") ; print $fh <', "00.tex") ; print $fh <', "jsss00.tex") ; print $fh <', "ohp00.tex") ; print $fh <', "trcover.tex") ; print $fh <) { chop; # strip record separator if( $verbatim && (!/^\s/) && (!/^$/) && $pre) { print $fh "\\end{verbatim}\n}\n"; $pre = 0; } if (/^-*input: (.*)/) { open(my $fdbase,"nkf -w $1 |"); push(@depend,$1); # print STDOUT "$1 "; &o2tex($fdbase); next line; } if (/^-title:/) { $file = 'title.tex'; $title = substr($_, 8, length($_) - 7); &Pick('>>', $file) && (printf $fh "\\title{{\\bf %s}}\n", $title); &Pick('>>', $ohp) && (printf $fh "\\title{{\\bf %s}}\n", $title); next line; } if (/^--*date:/) { my $tmp; for ($tmp = 1; substr($_, $tmp, 1) eq '-'; $tmp++) { ; } $tmp += 5; $day = substr($_, $tmp, length($_) - $tmp + 1); next line; } if (/^--*number:/) { my $tmp; for ($tmp = 1; substr($_, $tmp, 1) eq '-'; $tmp++) { ; } $tmp += 7; $number = substr($_, $tmp, length($_) - $tmp + 1); next line; } if (/^--*note:/) { &trcover(); $note = 2; $file = 'trcover.tex'; &Pick('>>', $file) && (printf $fh "\\clearpage\n"); (printf $fh "\\vspace*{\\fill}\n"); (printf $fh "\\begin{quote}\n"); next line; } if (/^--*author:/) { my $tmp; $file = 'title.tex'; for ($tmp = 1; substr($_, $tmp, 1) eq '-'; $tmp++) { ; } $tmp += 7; $author = substr($_, $tmp, length($_) - $tmp + 1); &Pick('>>', $file) && (printf $fh "%%\\pagenumbering{roman}\n"); (printf $fh "\\author{%s \\\\[5mm]\n", $author); (printf $fh "e-mail:kono\@ie.u-ryukyu.ac.jp\\\\\n"); (printf $fh "Information Engineering, University of the Ryukyus\\\\\n"); (printf $fh "Nishihara-cyo 1, Okinawa, 903-01, Japan}\n"); if ($day) { (printf $fh "\\date{%s}\n", $day); } else { (printf $fh "%% \\date{}\n"); } $file = sprintf('%d', $section) . '.tex'; &Pick('>>', $ohp) && (printf $fh "\\author{%s \\\\[5mm]\n", $author); (printf $fh ".Information Engineering, University of the Ryukyus\n"); (print $fh "%% \\today"); (print $fh "\\maketitlepage"); next line; } if (/^--*author-e:/) { $file = 'title-e.tex'; next line; } if (/^--*abstract-e:/) { $file = 'abstract-e.tex'; $abstract = 1; &Pick('>', $file); # && (printf $fh "\\begin{quotation}\n"); next line; } if (/^--*abstract:/) { $file = 'abstract.tex'; $abstract = 1; &Pick('>', $file); # && (printf $fh "\\begin{quotation}\n"); (print $fh "\\mbox{}"); next line; } if (/^--*begin-comment:/) { $backup = $file; $file = '/dev/null'; next line; } if (/^--*end-comment:/) { $file = $backup; next line; } if (/^-/) { if ($abstract == 1) { &Pick('>>', $file); # && (printf $fh "\\end{quotation}\n"); $abstract = 0; } if ($note) { if ($note == 2) { &Pick('>>', $cover) && (printf $fh "\\end{quote}\n"); } else { &trcover(); } $note = 0; } for ($depth = 1; substr($_, $depth, 1) eq '-'; $depth++) { ; } if ($depth == 2) { $file = sprintf('%d', $section) . '.tex'; &Pick('>>', $file) && (print $fh "\\section{", substr($_, $depth, length($_) - $depth + 1) . '}'); &Pick('>>', $ohp) && (print $fh "\\begin{bwslide}"); (print $fh "\\ctitle{", substr($_, $depth, length($_) - $depth + 1) . '}'); (print $fh "\\end{bwslide}\n\n"); &Pick('>>', '0.tex') && (printf $fh "\\input{%d}\t%% %s\n", $section, substr($_, $depth, length($_) - $depth + 1)); $section++; # print STDOUT "$section "; } elsif ($depth == 3) { $file = sprintf('%d', $section - 1) . '.tex'; &Pick('>>', $file) && (print $fh "\\subsection{", substr($_, $depth, length($_) - $depth + 1) . '}'); &Pick('>>', $ohp) && (print $fh "\\begin{bwslide}"); (print $fh "\\ctitle{", substr($_, $depth, length($_) - $depth + 1) . '}'); (print $fh "\\end{bwslide}\n\n"); } elsif ($depth == 4) { $file = sprintf('%d', $section - 1) . '.tex'; &Pick('>>', $file) && (print $fh "\\subsubsection{", substr($_, $depth, length($_) - $depth + 1) . '}'); &Pick('>>', $ohp) && (print $fh "\\begin{bwslide}"); (print $fh "\\ctitle{", substr($_, $depth, length($_) - $depth + 1) . '}'); (print $fh "\\end{bwslide}\n\n"); } else { $file = sprintf('%d', $section - 1) . '.tex'; &Pick('>>', $file) && (printf $fh "%s\\\\\n", substr($_, $depth, length($_) - $depth + 1)); } next line; } elsif (m!^
\s*"]*)"[^>]*alt="([^>"]*)"[^>]*>\s*
!i) { my $fig = $1; my $alt = $2; my $caption; if ($fig) { $fig =~ s/\.gif|\.jpg/.eps/; } if (! $alt) { $alt = $alt0++; $caption = ""; } else { $caption = "\\caption{$alt}\n"; } &Pick('>>', $file); # center environment disturbes caption counter and label reference my $line = <<"EOF"; \\begin{figure}[htb] \\begin{center} \\includegraphics[width=6cm]{${fig}} ${caption}\\end{center} \\label{${alt}} \\end{figure} EOF # print $fh "(fig.\\ref{$alt})\n"; print $fh $line; &Pick('>>', $ohp) && (print $fh "\\centerline{$line}\n"); if(! /^\s*%/) { $fig =~ s/[{}]//g; push(@depend,$fig); push(@ohpdepend,$fig); } next line; } elsif (m!^
\s*"]*)"[^>]*>\s*
!i) { my $fig = $1; my $alt = $2; my $caption; if ($fig) { $fig =~ s/\.gif|\.jpg/.eps/; } if (! $alt) { $alt = $alt0++; $caption = ""; } else { $caption = "\\caption{$alt}\n"; } &Pick('>>', $file); my $line = <<"EOF"; \\begin{figure}[htb] \\begin{center} \\includegraphics[width=6cm]{${fig}} ${caption}\\end{center} \\label{${alt}} \\end{figure} EOF # print $fh "(fig.\\ref{$alt})\n"; print $fh $line; &Pick('>>', $ohp) && (print $fh "\\centerline{$line}\n"); if(! /^\s*%/) { $fig =~ s/[{}]//g; push(@depend,$fig); push(@ohpdepend,$fig); } next line; } elsif (/\\epsfile\{.*file=([^{},]+)/ || /\\includegraphics\{([^{},]+)\}/ || /\\input (.*)/ || /\\include (.*)/) { my $fig = $1; &Pick('>>', $file) && (print $fh $_); &Pick('>>', $ohp) && (print $fh "\\centerline{$_}\n"); if(! /^\s*%/) { $fig =~ s/[{}]//g; push(@depend,$fig); push(@ohpdepend,$fig); } next line; } elsif ($verbatim && /^\s/) { if(! $pre) { print $fh "{\\small\n\\begin{verbatim}"; $pre = 1; } print $fh $_; } elsif (!/^-/) { &Pick('>>', $file) && (print $fh $_); } if (/\\cite\{/) { $cite = ""; } } } foreach my $arg (@ARGV) { open(my $fdbase,"nkf -w $arg |") || die("$arg cannot open"); &o2tex($fdbase); } &Pick('>>', $zero); select($fh); printf $fh "%s\\bibliographystyle{jplain} %% for bibliography\n", $cite; print <>', $zero) && (printf $fh "\\end{document}\n"); close($fh); &Pick('>>', $ohp) && (printf $fh "\n\\end{document}\n"); close($fh); sub trcover { if ($title) { &Pick('>>', $cover) && (printf $fh "{\\LARGE\\bf %s}\\\\[+5mm]\n", $title); } if ($author) { &Pick('>>', $cover) && (printf $fh "{\\large %s}\\\\[+5mm]\n", $author); } if ($number) { &Pick('>>', $cover) && (printf $fh "{\\large %s}\\\\[+4mm]\n", $number); } if ($day) { &Pick('>>', $cover) && (printf $fh "{\\large %s}\n", $day); } &Pick('>>', $cover) && (print $fh "\\end{center}}\\\\"); (print $fh "\\vfill"); (printf $fh "{\\Large Information Engineering, University of the Ryukyus\\\\\n"); (print $fh "Nishihara-cho 1, Okinawa, 903-01 JAPAN}\\\\[+2cm]"); (print $fh "{\\small Copyright \\copyright\\ \\number\\year\\"); (print $fh 'University of the Ryukyus'); (print $fh "}\\\\[+1cm]"); (print $fh "\\end{center}"); (print $fh "\\end{titlepage}\n\n"); return; } sub Pick { my ($mode,$name,$pipe) = @_; $pipe = "" if (! defined $pipe) ; if (! defined $opened{$name}) { open(my $mfh,$mode, $name.$pipe); $fh = $mfh; $opened{$name} = $fh; } else { $fh = $opened{$name}; } 1; } &Pick('>>', $cover) && print $fh "\\end{document}\n"; close $fh; if (! -f "Makefile") { open($fh,">Makefile"); select($fh); print "PAPER = ". $paper . "\n"; print <<"RogueRogue"; PRINTER = ab OHP = ohp MAIN = main COVER = trcover LATEX = platex SLITEX = jslitex BIBTEX = jbibtex AWK = awk SED = sed DVI2PS = dvi2ps R = PRINTER = $m.SUFFIXES: .c .d .tokio .x .xfig .fig .tex .dvi .print .lw .next .ps .gs .xdvi .d.tex: tgrind -F -ldb \$< >\$@ .c.tex: tgrind -F -lC \$< >\$@ .tokio.tex: tgrind -F -ltokio \$< >\$@ .fig.tex: f2tpic \$< >\$@ .xfig.tex: f2tpic \$< >\$@ .fig.ps: f2ps1 \$< >\$@ .x.tex: x2tpic \$< -rm -f \$*.pic .tex.dvi: jlatex \$< .dvi.print: \$(DVI2PS) \$(R) \$< | lpr -P\$(PRINTER) # lpr \$(PRINTER) -d \$< .dvi.lw: \$(DVI2PS) \$(R) \$< | lpr -P\$(PRINTER) .dvi.next: dviNeXT \$< .dvi.xdvi: (exec xdvi \$< & ) .dvi.ps: -\$(DVI2PS) \$(R) \$< > \$*.ps .ps.gs: gs \$*.ps all: -rm -f \$(MAIN).dvi make \$(MAIN).dvi print: \$(MAIN).print lw: \$(MAIN).lw next: \$(MAIN).next gs: \$(MAIN).gs \$(MAIN).gs : \$(MAIN).ps \$(MAIN).ps : \$(MAIN).dvi \$(OHP).gs : \$(OHP).ps \$(OHP).ps : \$(OHP).dvi xdvi: \$(MAIN).xdvi dvips: \$(MAIN).dvi dvips \$(MAIN).dvi -o \$(MAIN).ps \$(MAIN).dvi: 1.tex \$(LATEX) \$(MAIN) jsss.dvi: jsss.tex 1.tex \$(LATEX) jsss.tex wc: \$(SED) -e '/\\\\special{/d' \$(PAPER) | delatex | wc uu: tar cBf - \$(MAIN).[tab]* [0-9]*.tex \$(DEPENDENCY) \\ title.tex abstract.tex ohp.tex \\ Makefile | gzip | uuencode \$(PAPER).tar.gz > uu bbl: \$(MAIN).bbl \$(MAIN).bbl: ref.bib 1.tex # \$(MAIN).aux -\$(BIBTEX) \$(MAIN) \$(MAIN).aux: \$(MAIN).tex 1.tex \$(LATEX) \$(MAIN) 1.tex: \$(PAPER) \$(DEPENDENCY) -o2tex \$(PAPER) # OHP with slitex \$(OHP): \$(OHP).dvi \$(OHP).dvi : \$(OHP).tex \$(DEPENDOHP) \$(SLITEX) \$(OHP) ohpprint: \$(OHP).dvi lpr -c \$(OHP).dvi ohplw: \$(OHP).dvi \$(DVI2PS) \$(R) -o landscape \$(OHP).dvi | lpr -P\$(PRINTER) ohpnext: \$(OHP).dvi \$(DVI2PS) -h -i /usr/lib/tex/ps/tex-j.next -o landscape \$(OHP).dvi |\\ lpr -Pcb ohpgs: \$(OHP).gs cover: \$(COVER).dvi \$(COVER): \$(COVER).dvi \$(COVER).dvi : \$(PAPER) coverprint: \$(COVER).print coverlw: \$(COVER).lw covernext: \$(COVER).next covergs: \$(COVER).gs clean: -rm -f \$(MAIN).ps *.dvi *.log *.blg \\ *~ \\#* ?.tex *.toc *.lof *.lot xfig/*.tex tgrindfig.tex: ln -s "\$\$HOME"/paper/tgrindfig.tex . # for MSDOS tgrindfi.tex: ln -s "\$\$HOME"/paper/tgrindfig.tex tgrindfi.tex ref.bib: ln -s "\$\$HOME"/paper/ref.bib . RogueRogue close $fh; } if ( ! -f "main.tex") { rename('00.tex','main.tex'); } if ( ! -f "jsss.tex") { rename('jsss00.tex','jsss.tex'); } if ( ! -f "ohp.tex") { rename('ohp00.tex','ohp.tex'); } # make depend > /dev/null rename("Makefile","Makefile.old"); open(MAKE, "Makefile"); select($fh); print "DEPENDENCY = @depend\n"; print "DEPENDOHP = @ohpdepend\n"; while() { next if(/^DEPEND/); chop; print; } close($fh); # end