スクリプトで出力データをフォーマットしようとしていますが、幅だけでなく左右の位置合わせを行う方法も肯定的ではありません。誰かが私を正しい方向に向けることができますか?
10928 次
6 に答える
1
あなたはあまり明確ではありませんが、おそらく最も簡単な方法は、単に使用することですprintf()
(同じ名前のC関数ではなく、シェルコマンド)。
于 2010-02-04T13:10:34.767 に答える
0
以下は、完全な正当化とハイフネーションを行う Perl スクリプトです。
そのスクリプトに左マージン機能を追加するための差分を次に示します。
--- paradj.pl 2003-11-17 09:45:21.000000000 -0600
+++ paradj.pl.NEW 2010-02-04 09:14:09.000000000 -0600
@@ -9,16 +9,18 @@
use TeX::Hyphen;
my ($width, $hyphenate, $left, $centered, $right, $both);
-my ($indent, $newline);
+my ($indent, $margin, $newline);
GetOptions("width=i" => \$width, "help" => \$hyphenate,
"left" => \$left, "centered" => \$centered,
"right" => \$right, "both" => \$both,
+ "margin:i" => \$margin,
"indent:i" => \$indent, "newline" => \$newline);
my $hyp = new TeX::Hyphen;
syntax() if (!$width);
$indent = 0 if (!$indent);
+$margin = 0 if (!$margin);
local $/ = "";
@@ -147,6 +149,7 @@
}
}
+ print " " x $margin;
print "$lineout\n";
}
}
@@ -185,6 +188,9 @@
print "initial\n";
print " indention (defaults ";
print "to 0)\n";
+ print "--margin=n (or -m=n or -m n) Add a left margin of n ";
+ print "spaces\n";
+ print " (defaults to 0)\n";
print "--newline (or -n) Output an empty line \n";
print " between ";
print "paragraphs\n";
于 2010-02-04T14:51:23.817 に答える