//cassavaからLaTeXのtabular形式にアウトプットするマクロ //by たけとり //multicolumnに対応(セル1文字目が">"のセルから"<"だけのセルを全て連結する) //TODO------------------------ //キャプションを任意のセルから得る。 //環境名がtabularxにできたりする。 //ConnectCellEx(結合後も左に詰めず、結合元のセルに"<"などを入力) //History--------------------- //0.01 '03/06/23 とりあえず動くようにした //0.02a '03/06/26 multicolumnに対応。cassava Ver.1.3a5 のバグに対応 //0.02a' '03/06/26 あすかぜによる若干の変更と公開。 /////////////////////////////////////////////////////////// B = Bottom; R = Right; function multicol(m, n, amp){ //\multicolumnを出力する。 //IN: x座標, y座標, Amp(&) //OUT: 連結されたセル数 ////cassavaに配列が実装されたら、下記の仕様で。 ////IN: x座標, y座標 ////OUT: 文字列"\multicolumn{n}{pos}{char}"(n=連結する数・pos=位置・char=内容),連結されたセル数 MCResult = amp + "\\multicolumn{"; MCChar = mid( cell(m,n), 2 ); for(MCNum=1; cell(m+1,n)=="<"; m++){ MCNum = MCNum + 1; } write( MCResult + MCNum + "}{|c|}{" +MCChar + "}\t" ); return MCNum; }//-----------end multicol---------------// //--------------main---------------------// writeln("\\documentclass[a4j]{jarticle}"); writeln(""); writeln("\\begin{document}"); writeln(""); write("\\begin{tabular}{|"); For(x to R){ write("c|"); } writeln("} \\hline"); For(y to B){ write("\t"); For(x to R){ if( x==1 ){ //cotinue文がほしい。 Amp = ""; }else{ Amp = "&"; } if([x,y] == ""){ write(Amp + "\t"); }else if( left( [x,y], 1) == ">"){ //連結開始セルと見なす Ret = multicol(x, y, Amp); x = x + Ret -1; //write( Amp + multicol(x, y, Amp)); ////hyper.sty用に温存 //}else if(left([x,y], 7) == "http://"){ // writeln(" "+ [x,y] + ""); }else{ str = [x,y]; str = replace(str, "&", "\\&"); //str = replace(str, "\\", "\\\\"); //セル内にコマンドを書く人向けにコメントアウト write( Amp + str + "\t" ); } } writeln("\\\\ \\hline"); } writeln("\\end{tabular}"); writeln(""); writeln("\\end{document}");