なんだこれは

はてなダイアリーから移転しました。

mkimgの次はcutterだ

これはperlだからperlのパスを確認して変更すること。

cutter hoge.tex

すると、hedderというファイルと数式部分のファイルが多数ぶち撒かれる。要
注意だ。

#!/usr/bin/perl -w
#  file:cutter 
#  TeX source cutter to get headder and equation part of tex

$TimeStamp="Time-stamp: <05/09/09 03:10:03 fu7mu4>";
$Version="2.3macosx-vine";

# Special Thanks to ------- .

###Options##

# $NoNumber="YES" : remove all equation number , ="NO" : don't remove
 
$NoNumber="YES" ; 

# $Eqpart is output file name , ex. "$EqFile$i" :$i = 1,2,3...

$EqFile="eqpart" ;

# headder file name 

$HeadderFile = "headder" ; 

###CODE###

#initialize 
@mathenv = ( "equation" , "eqnarray" , "gather" , "align" , "alignat" , "multline" );
 
$FileNum = 0 ;

#version and help
print <<EOD;
cutter Version $Version is wriiten at $TimeStamp
cutter USAGE

    cutter file
or
    cat \*\.tex | cutter
No input , send me Ctrl-D
EOD

while (<>) {

    s/\%.*$// ; #remove all comments
    s/\\label\{.*\}// ; #remove all label commands
    s/\\tag(\*)?{.*\}// ; #remove all tags command
    
    if ( $_ =~ /\\document/ ) {
	$FileName = "$HeadderFile";
	open(W,">${FileName}");
	select W;
    }

    if ( $_ =~ /\\\[|\\begin\{(equation|eqnarray|gather|align|alignat|multline)\*?\}/ ) {
	$FileNum++ ;
        $FileName = "${EqFile}".$FileNum;
	open(W,">${FileName}");
	select W;
    }
  
    if ( ${NoNumber} eq "YES" ) {
	
	foreach $env (@mathenv ) {
	    s/\\begin\{$env\}/\\begin\{$env\*\}/g ;
	    s/\\end\{$env\}/\\end\{$env\*\}/g ;
	
	}
    # for jlatex
    s/\\begin\{equation\*\}/\\\[/;
    s/\\end\{equation\*\}/\\\]/;
    }
#    s/^.*?(\\\[|\\begin\{equation\})/$1/;
#    s/(\\\]|\\end\{equation\}).*$/$1/;

    foreach $env (@mathenv ) {
	s/^.*?(\\\[|\\begin\{$env\*?\})/$1/;
	s/(\\\]|\\end\{$env\*?\}).*$/$1/;
    }	

    print $_;

    if ( $_ =~ /\\begin\{document\}/) {

	close W;
        select STDOUT;

    }

    if ( $_ =~ /\\\]|\\end\{(equation|eqnarray|gather|align|alignat|multline)\*?\}/ ) {

	close W;
	select STDOUT;

    }

}

print <<EOD;
   see , there are $FileNum files 
EOD