1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626
|
%表題 ETC 便利な道具たち
%
%履歴
%\Drireki{
% 92/03/26 沼口 敦
% 92/04/22 林祥介 (4.1版)
% 94/03/31(numaguti) 沼口 敦 (dclps初版)
% 03/02/05(kagimoto) 鍵本 崇
% }
%
% \Dchapter{PS出力の加工}
\Dchapterhead
\label{PS加工}
\section{はじめに}
ここでは, 電脳ライブラリのPostScript出力(dcl.ps)を
各種目的のために加工する方法と,
そのための道具(pslib)に付いて述べる.
\begin{enumerate}
\item ページの抜きだし
\item \LaTeX{}への組み込み
\item 描画ツールによる編集
\end{enumerate}
これらの方法は環境に大きく依存する.
以下で述べる手順を実行するために必要な環境を列挙する.
\begin{enumerate}
\item Unix 環境:
Windows環境への移植も, 描画ツールによる編集を除き容易であろう.
\item AWK処理系:
Unix には, 標準で{\tt /bin/awk}および{\tt /bin/nawk}が
付属している.
通常使われるAWKは{\tt /bin/nawk}であり,
基本的に{\tt /bin/awk}の上位互換であるため,
ここでは, {\tt /bin/nawk}を用いる.
{\tt jgawk}(GNU版AWK)を用いてもよい.
\item \LaTeX{}処理系:
以下では, ASCII版日本語\LaTeX{}を仮定する.(要確認)
\item {\tt epsf.sty}:
PSファイルを\LaTeX{}に組み込む時に
便利な機能を提供するスタイルファイル.
\LaTeX の標準スタイルファイルを置くディレクトリまたは
環境変数{\tt TEXINPUTS}の示すディレクトリに入れておく.
このツールは、もはやない.
\item {\tt dvi2ps}:
DVIファイルをポストスクリプトに変換するフィルタ.
以下では, 日本語化された, {\tt dvi2ps-j} を仮定する.
このツールについてはdvipdfmxを推奨するようになる予定である.
\footnote{ここでは述べないが,
{\tt postscript.sty + pstex + jdvi2kps}
の組み合わせでも使用可能である.}.
\item Xウィンドウ環境:
X11R4以上.
\item {\tt idraw}:
対話型描画ツールとして,
以下では, 日本語化された{\tt idraw}である{\tt kdraw}
\footnote{idraw はX11/contribに付属するC++
ライブラリであるInterviewsに含まれる.
コンパイルにはg++などのC++コンパイラが必要である.}
を仮定する.
\item ポストスクリプト出力が可能なプリンタ.
もしくは {\tt ghostscript} などのポストスクリプトインタプリタ.
\end{enumerate}
以下に述べるコマンドは, パスの通ったディレクトリに入れ,
実行可能フラグを立てておくとよい.
{\tt /bin/nawk} 以外のAWK処理系を使用する場合は,
1行目を書換えること.
\section{dclpsselect : dcl.psのページ抜きだし}
%\label{pslib.dclpsselect}
複数ページを含む dcl.ps から特定のページを抜き出す場合には,
{\tt dclpsselect} を使用する.
以下で述べる\LaTeX の取り込み, 描画ツールでの編集をするためには,
1ページがひとつのファイルになっている必要があるため,
場合によりこの作業が前段階として必要になる.
\subsection{dclpsselect}
\label{pslib.dclpsselect.cmd}
\begin{enumerate}
\item 機能
\begin{quote}
dcl.ps から特定の1ページを抜きだし, 標準出力に出力する.
\end{quote}
\item 使用方法
\begin{quote}
{\tt dclpsselect }{\em [p=<page>,<page>...] [from=<page>] [to=<page>] <file>}
Options:
+ from : select range of page from: [0]
+ to : select range of page to: [0]
+ p : select pages [0]
\end{quote}
\item 備考
\begin{enumerate}
\item 1つのファイルの中に複数ページのPSが入っている場合, それからある特
定の複数のページ, またはある範囲のページを選択する. p オプションで
指定する複数のページリストは昇順でなければならない.
\end{enumerate}
\end{enumerate}
\section{dclpsrot : dcl.psの\TeX{}への組み込み}
\label{pslib.dclps2tex}
dcl.psを\TeX{}に組み込む手順の概略は
以下の通りである.
\begin{enumerate}
\item 必要であれば, {\tt dcl.ps}に回転その他の加工を行い,
{\tt Boundingbox}コメントを調整する.
\item \LaTeX のスタイルオプションとして {\tt graphicx.sty} を指定し,
\verb!\includegraohics! コマンドで {\tt dcl.ps} ファイルを指定する.
\end{enumerate}
詳しい手順を以下に記す.
\begin{enumerate}
\item {\tt dcl.ps}を以下のように加工する.
\begin{enumerate}
\item 横長画面の場合({\tt IWS>0}).
\begin{enumerate}
\item 1行めの \verb/%! dclps OUTPUT FOR POSTSCRIPT FILE./
の後に,
( \verb!%%BoundingBox...!というコメントがすでにあれば
それを取り除き),
\verb!%%BoundingBox: -1 -1 751 531!
という行を入れる.
これは, PSファイルに含まれる座標の範囲を
{\tt graphicx.sty}に知らせるためのコメントである.
\item 25行目付近にある,
\verb!562 44 translate! \\
\verb!+90 rotate!
を取り除くか, 行の先頭に \verb!%!を挿入して
コメントアウトする.
\item ハードフィルを用いている場合,
20行目付近にある, {\tt /P1}, {\tt /P2} 等の定義を
以下の様に書き換える.
\begin{verbatim}
/P3 {{pop}} def
/P4 {{rightup}} def
/P1 {{exch pop}} def
/P2 {{rightdown}} def
\end{verbatim}
すなわち, {\tt P1}と{\tt P3}, {\tt P2}と{\tt P4}を
とりかえる.
\end{enumerate}
これらの作業は
\footnote{PSは縦長画面が標準であり,
横長画面の場合には
PSを90度回転させて出力していることから,
このような元に戻す作業が必要となっている.}
後述の{\tt dclpsrot}コマンドによって
行うことができる.
\item 縦長画面の場合({\tt IWS<0}).
\begin{enumerate}
\item 1行めの \verb/%! dclps OUTPUT FOR POSTSCRIPT FILE./
の後に,
\verb!%%BoundingBox: 31 43 563 795!
という行を入れる.
これは, PSファイルに含まれる座標の範囲を
{\tt graphicx.sty}に知らせるためのコメントである.
ただし, このコメントは標準で入っているものであるので,
通常はこの操作は必要ない.
\end{enumerate}
\end{enumerate}
\item \LaTeX のスタイルオプションとして {\tt graphicx.sty} を指定する.
すなわち, 以下のように設定リストのあたりに
{\tt \verb!\usepackage{graphicx}!}を入れる.
\verb!\documentclass[a4paper,12pt]{jarticle}!
\verb!\usepackage{graphicx}!
本文中で, 挿入したい場所に
\verb!\includegraphics! コマンドで入れるdcl.psファイルを指定する.
\verb!\includegraphics[width=10cm,keepaspectratio]{dcl.ps}!
または,
\verb!\includegraphics[height=10cm,keepaspectratio]{dcl.ps}!
\verb!width=10cm!, \verb!height=8cm!などの指定により,
図全体の幅, または高さが指定した値になるように
縮小拡大されて挿入される.\verb!keepaspectratio!で縦横比が保存される.
\begin{quote}
\small
このスケーリングには, \verb!%%BoundingBox!の値が使用される.
\verb!%%BoundingBox!の値は
順にx座標の下限, y座標の下限, x座標の上限, y座標の上限を示す.
座標の単位は1/72インチである.
この範囲が指定した実長におさまるようにスケーリングし,
その大きさの領域を確保するようになっている.
\end{quote}
\item \LaTeX の処理を行う.
ここで,\verb!\includegraphics!に指定したファイルが見つからないと,
エラーがとなる.
いろいろな方法で処理できるが、現在はpdfにするのがよくおこなわれており、
後々の使い勝手も良い.dvipdfmxなどで変換するのがよいだろう.
\end{enumerate}
\subsection{dclpsrot}
\label{pslib.dclpsrot.cmd}
\begin{enumerate}
\item 機能
\begin{quote}
dclps.ps を90度回転させて, 横長画面が\LaTeX にとりこめるようにする.
\end{quote}
\item 使用方法
\begin{quote}
{\tt dclpsrot} {\em psfile}
\end{quote}
\item 引数
\begin{quote}
\begin{tabular}{lp{11cm}}
{\em psfile\/} & 入力ファイル名. 標準的には{\tt dcl.ps\/}.
省略すると, 標準入力が用いられる.
\end{tabular}
\end{quote}
\item 備考
\begin{enumerate}
\item PSファイルは1ページごとに一つのファイルと
なっていなければならない.
ページを抜き出すには,
{\tt dclpsselect}(\ref{pslib.dclpsselect.cmd})が使用できる.
\end{enumerate}
\end{enumerate}
\section{dclps2kdraw : 描画ツールによるdclps.psの編集}
直接の印刷, あるいは\LaTeX{}への組み込みの前に
dcl.psファイルを対話型描画ツールによって編集加工することができる.
ここでは, idraw(あるいはその日本語対応版のkdraw)を
用いた方法を述べる.
kdraw は特殊なPSファイル(コメントとしてkdraw独自の命令が入っている)
を入出力として使っており, その形に合わせておけば, kdraw により編集
が可能となる. dclpsfont によって PS に変換された文字列は変換されな
い.
\begin{enumerate}
\item {\tt dclps2kdraw} を使用して, {\tt dcl.ps}ファイルを
{\tt kdraw}が読み込めるファイルに変換する.
\item {\tt kdraw}を起動してファイルを読み込み,
編集加工後セーブ, 印刷する.
\end{enumerate}
\subsection{dclps2kdraw}
\label{pslib.dclps2kdraw.cmd}
\begin{enumerate}
\item 機能
\begin{quote}
dclps.ps を kdraw が読み込める形に変換する.
\end{quote}
\item 使用方法
\begin{quote}
{\tt dcl2kdraw} {\em psfile}
\end{quote}
\item 引数
\begin{quote}
\begin{tabular}{lp{11cm}}
{\em psfile\/} & 入力ファイル名. 標準的には{\tt dcl.ps\/}.
省略すると, 標準入力が用いられる.
\end{tabular}
\end{quote}
\item 備考
\begin{enumerate}
\item PSファイルは1ページごとに一つのファイルと
なっていなければならない.
ページを抜き出すには,
{\tt dclpsselect}(\ref{pslib.dclpsselect.cmd})が使用できる.
\item ハードフィルは変換できない. 無視される.
\item {\tt dclps2idraw}で変換したファイルは
そのままでは印刷できない.
一度{\tt idraw}で読み込み, セーブすると印刷可能となる.
\item ある(比較的新しい?)バージョンの{\tt idraw}では
読み込んだ時非常に大きくなってしまい,
また線が太くなってしまう.
{\tt kdraw}は古いバージョンの{\tt idraw}({\tt Interviews2.6})を
元にしており, そのような症状は出ない.
\item 2つの{\tt idraw}を立ちあげて,
{\tt .clipboard}を用いて
cut and paste する場合, paste したイメージの
スケールがおかしくなる(大きくなる).
\item 編集加工された画像にあわせて\verb!BoundingBox!が
再設定されるために,
編集前と\LaTeX{}に組み込んだ時の大きさが異なってしまう
ことがある. その際には\verb!BoundingBox!の数値を
\ref{pslib.dclps2tex}で示したものに設定しなおすこと.
\end{enumerate}
\end{enumerate}
\section{その他のps用ツール}
いくつかのpsツールが追加されている.それぞれのコマンドの使い方について述べる.
\subsection{dclpscat}
\begin{enumerate}
\item 機能
\begin{quote}
複数のファイルからなる一連の図を1つのファイルの複数ページの出力の
形にする. 2ページめ以降のヘッダを削除し, 連接する.
\end{quote}
\item 使用方法
\begin{quote}
{\tt dclpscar <file> \///} {\em psfile}
\end{quote}
\item 引数
\begin{quote}
\begin{tabular}{lp{11cm}}
{\em psfile\/} & 入力ファイル名. 標準的には{\tt dcl.ps\/}.
省略すると, 標準入力が用いられる.
\end{tabular}
\end{quote}
\item 備考
\end{enumerate}
\subsection{dclpsfix}
\begin{enumerate}
\item 機能
\begin{quote}
TeX に組み込んだ時のプリンタのバグに対処するため, BoundigBox 以外
の %% コメントを削除. また, kdraw で編集した dcl.ps由来のファイル
で, そのままだとトーンが汚くなるので後処理を行う.
\end{quote}
\item 使用方法
\begin{quote}
{\tt dclpsfix <file> …}
\end{quote}
\item 引数
\begin{quote}
\begin{tabular}{lp{11cm}}
{\em psfile\/} & 入力ファイル名. 標準的には{\tt dcl.ps\/}.
省略すると, 標準入力が用いられる.
\end{tabular}
\end{quote}
\item 備考
\end{enumerate}
\subsection{dclpsfont}
\begin{enumerate}
\item 機能
\begin{quote}
dcl で書かれた文字を PS フォントに変換する. たくさんオプションがあ
り, フォントが選択できる. オプションにより, 上付き, 下付き文字にも
対応可. ギリシャ文字も出力される. 文字の向きは紙が縦向き
(Portrait) か横向き (Landscape) かによって自動判別する.
※sgtx[uvr], sgtxz[uvr] で書かれた文字列において, 文字コード 0 〜
127 の文字と文字コード 128 〜 255 の文字を混ぜた複合文字列を用いた
場合には変換されない.
※Adobe Illustrator 9.x 以降で用いる場合には Symbol フォントを
SymbolMT フォントに変更する必要がある(オプション ai=1).
\end{quote}
\item 使用方法
\begin{quote}
{\tt dclpsfont [f=<font id>..] [<option>=<value>...] <file>}
\end{quote}
\item 引数
\begin{tabular}{lrcp{10cm}}
f &:& font id (((idx,ifont),idx=1,imax),ifont=1,..) [ccCChhHHHttTT]\\
ai &:& SymbolMT font is used for Adobe Illustrator 9.x or later [0]\\
fht &:& text hight scale factor [1]\\
fwt &:& text width scale factor [1]\\
fact &:& scale factor [7500]\\
fhnc &:& hight scale factor for non-standard char [1]\\
fwnc &:& width scale factor for non-standard char [1]\\
imax &:& max. of index [4]\\
irst &:& end sub(super)script [\"]\\
isub &:& begin subscript [\_]\\
isup &:& begin superscript [|]\\
lcntl &:& 1/0 : sub(super)script on/off [0]\\
shift &:& shift of sub(super)script [0.3]\\
small &:& ratio of sub(super)script [0.7]\\
file & & 入力ファイル名. 標準的には{\tt dcl.ps\/}.省略すると, 標準入力が用いられる.
\end{tabular}
\vspace{10pt}
\item 備考
使用できるフォントID
\begin{tabular}{lrcp{10cm}}
a &:& AvantGarde-Book\\
A &:& AvantGarde-Demi\\
b &:& Bookman-Light\\
B &:& Bookman-Demi\\
c &:& Courier\\
C &:& Courier-Bold\\
h &:& Helvetica\\
H &:& Helvetica-Bold\\
i &:& Times-Italic\\
I &:& Times-BoldItalic\\
n &:& NewCenturySchlbk-Roman\\
N &:& NewCenturySchlbk-Bold\\
o &:& Courier-Oblique\\
O &:& Courier-BoldOblique\\
p &:& Palatino-Roman\\
P &:& Palatino-Bold\\
s &:& Helvetica-Oblique\\
S &:& Helvetica-BoldOblique\\
t &:& Times-Roman\\
T &:& Times-Bold\\
z &:& ZapfChancery\\
Z &:& ZapfChancery-Bold\\
\end{tabular}
\end{enumerate}
\subsection{dclpsline}
\begin{enumerate}
\item 機能
\begin{quote}
線のスタイル(join,cap)を変更する.
\end{quote}
\item 使用方法
\begin{quote}
{\tt dclpsline [lc=<0,1,2,b,r,p] [lj=<0,1,2,m,r,b>] [ml=<num>] <file>}
\end{quote}
\item 引数
\begin{tabular}{lrcp{10cm}}
lj&:& 0|m: miter join, 1|r: round join, 2|b: bevel join [0] \\
ml &:& miterlimit for lj=0|m [10] \\
lc &:& 0|b: butt cap, 1|r: round cap, 2|p: proj. square cap [0]
\end{tabular}
\item 備考
\begin{enumerate}
\item 線のスタイルは, 数字または頭文字で指定.
\end{enumerate}
\end{enumerate}
\subsection{dclpsmargin}
\begin{enumerate}
\item 機能
\begin{quote}
PostScript の余白の調節と BoundingBox の再設定.
\end{quote}
\item 使用方法
\begin{quote}
{\tt dclpsmargin [options]}
\end{quote}
\item 引数
\begin{tabular}{rcp{10cm}}
-m & margin & ratio of border to real figure size (default: 0.05) \\
-i & infile[.ps] & input file created by dcl. If not specified, the
standard input is used \\
-o & outfile[.eps] & output file. If not specified, the standard output
is used \\
-h & & print this message
\end{tabular}
\item 備考
\begin{enumerate}
\item TeX に dcl.ps を取り込む際に, 余分な余白を取り除くときに有効である.
たとえば dclpsrmcm でバックグラウンドの白い長方形とコーナーマーク
を取り除き, その後 dclpsmargin で余白のサイズを指定すると, その分
の余白を確保して残りは削除され, この作業に応じて BoundingBox の再
設定を行う. したがって TeX の graphics (あるいは graphicx) パッケー
ジにおいて BoundingBox の設定を trial and error で行う必要がなくな
る.
\end{enumerate}
\end{enumerate}
\subsection{dclpsmerge}
\begin{enumerate}
\item 機能
\begin{quote}
複数ページの図を1ページに重ねる.
\end{quote}
\item 使用方法
\begin{quote}
{\tt dclpsmerge <file>..}
\end{quote}
\item 引数
\item 備考
\begin{enumerate}
\item 複数のファイルまたは1つのファイルの中の一連の図を重ね合わせて1枚の
図にする.
\end{enumerate}
\end{enumerate}
\subsection{dclpsnup}
\begin{enumerate}
\item 機能
\begin{quote}
1枚の紙に複数のページの PostScript を配置.
\end{quote}
\item 使用方法
\begin{quote}
GNU awk版\\
{\tt dclpsnup -nup [-c] [-r] [-l] [-p] <file>...}\\
nawk版\\
{\tt dclpsnup nup=<number> [cmajor=1] [rmajor=1] [landscape=1] [portrait=1] <file>...}
\end{quote}
\item 引数
\begin{quote}
GNU awk 版
\begin{tabular}{lp{10cm}}
-nup: & number of pages on one sheet\\
-c: & column-major layout\\
-r: & row-major layout\\
-l: & landscape orientation\\
-p: & portrait orientation
\end{tabular}
nawk 版
\begin{tabular}{lp{10cm}}
usage : %
nup: & number of pages on one sheet \\
cmajor: & if the value is 1, column-major layout\\
rmajor: & if the value is 1, row-major layout\\
landscape: & if the value is 1, landscape orientation\\
portrait: & if the value is 1, portrait orientation
\end{tabular}
\end{quote}
\item 備考
\begin{enumerate}
\item psutils の psnup とほぼ同じ働きをするスクリプトである. 現在までの
ところ, 2-up(2x1), 4-up(2x2), 8-up(2x4), 9-up(3x3), 16-up(4x4),
25-up(5x5) まで対応済み.
\end{enumerate}
\end{enumerate}
\subsection{dclpsrmcm}
\begin{enumerate}
\item 機能
\begin{quote}
バックグラウンド, 外枠の除去.
\end{quote}
\item 使用方法
\begin{quote}
{\tt dclpsrmcm <file>}
\end{quote}
\item 引数
\item 備考
\begin{enumerate}
\item バックグラウンド(通常は白)と, 四隅のコーナーマークを削除する.
\end{enumerate}
\end{enumerate}
\subsection{dclpsseparate}
\begin{enumerate}
\item 機能
\begin{quote}
ページ毎のファイルに分割 .
\end{quote}
\item 使用方法
\begin{quote}
{\tt dclpsseparate <file>}
\end{quote}
\item 引数
\item 備考
\begin{enumerate}
\item 1つのファイルの中に複数ページのPSが入っている場合, それを1ページか
らなる複数のファイルに分割する. 出力は, ファイル名が XXX.ps の場合,
XXX\_001, XXX\_002, ... となる.
\end{enumerate}
\end{enumerate}
\subsection{dclpsunrot}
\begin{enumerate}
\item 機能
\begin{quote}
90度回転undoする.
\end{quote}
\item 使用方法
\begin{quote}
{\tt dclpsunrot <file>}
\end{quote}
\item 引数
\item 備考
\begin{enumerate}
\item dclpsrot で90度回転した図を元に戻す.
\end{enumerate}
\end{enumerate}
|