| 1 |
[2] Modify a DVI file to be page-independent in specials |
| 2 |
[1] Translation between DVI file <-> Text file |
| 3 |
Originally written by SHIMA, Jan. 2003 |
| 4 |
Ver.YYYYMMDD (TeX Live YYYY) |
| 5 |
|
| 6 |
Usage: dvispc [-c] [-bvz] input_dvi_file [output_dvi_file] |
| 7 |
dvispc -d input_dvi_file |
| 8 |
dvispc -s [-p..] input_dvi_file [output_text_file] |
| 9 |
dvispc -a [-ltv][-J..][-p..][-r..] input_dvi_file [output_text_file] |
| 10 |
dvispc -x[..] [-ltv][-r..] [input_text_file] output_dvi_file |
| 11 |
|
| 12 |
Mode options: |
| 13 |
-c: correct input DVI to be page-indepent in specials (default) |
| 14 |
-d: dry run to check page-independence |
| 15 |
-s: show specials |
| 16 |
-a: translate DVI to Text |
| 17 |
-x: translate Text to DVI (-x0:str0 1:chkfnt 2:variety) |
| 18 |
|
| 19 |
Other options: |
| 20 |
-v: verbose -l: location |
| 21 |
-b: backup original even if output_dvi_file is not given |
| 22 |
-z: append empty pages if necessary to have multiple of 4 pages for book |
| 23 |
-p: T:preamble L:postamble pages with - (eg: -pT-L -pT2/4-8L -p-4 etc.) |
| 24 |
-r: replace (-rorg_1=new_1/org_2=new_2... eg. -rxxx=special/fnt=font) |
| 25 |
-t: compatible to DTL (the followings are suboptions if necessary eg. -t02) |
| 26 |
0:str 1:ch 2:ch2 3:cmd 4:c-sum 5:dir/name 6:err 7:page 8:oct 9:str0 |
| 27 |
-J: set Japanese characters output with a suboption: |
| 28 |
e:EUC-JP s:Shift_JIS u:UTF-8 for pTeX or U:UTF-8 for upTeX. |
| 29 |
output_dvi_file : overwrite if it is not specified. |
| 30 |
output_text_file : stdout if it is not specified. |
| 31 |
input_text_file : stdin if it is not specified. |
| 32 |
|
| 33 |
Supported specials: |
| 34 |
color specials: push, pop, background |
| 35 |
pdf specials: pdf:bcolor, pdf:ecolor, pdf:bgcolor |
| 36 |
tpic specials: pn |
| 37 |
|
| 38 |
|
| 39 |
***************************************************** |
| 40 |
[1] ** Translation between DVI file <-> Text file ** |
| 41 |
***************************************************** |
| 42 |
|
| 43 |
-a: transform DVI file into a text file (the option -v can be valid) |
| 44 |
|
| 45 |
-x: transform a text to DVI file. |
| 46 |
stack depth, page numbers and address are automatically corrected. |
| 47 |
-x0 is equivalent to -x -t9 |
| 48 |
The text should be the same format obtained by -a option. |
| 49 |
The line which starts with an alphabetical character of the lower |
| 50 |
case or the character [ or ] or \ has only been interpreted. |
| 51 |
The valid line is of the following format with several blocks separated by |
| 52 |
spaces. |
| 53 |
|
| 54 |
<key> <number><comment> ... <number><comment> '<string>' <any comment> |
| 55 |
|
| 56 |
<key>: key word |
| 57 |
<number>: decimal, hexadecimal starting with 0x or 0X, octal starting with 0 |
| 58 |
<comment>: void or a string without a space and not starting with a figure |
| 59 |
indicate after <number> without a space. |
| 60 |
This is ignored. |
| 61 |
<any comment>: void or any string. This is ignored. |
| 62 |
|
| 63 |
The number of the blocks of <number><comment> and the existence of '<string>' |
| 64 |
is determined by <key> as follows. |
| 65 |
|
| 66 |
List of <key> (X: 1 - 4 XX: 0 - 127 YY: 0 - 63) |
| 67 |
<key> <number><comment> '<string>' |
| 68 |
pre : 5 1 |
| 69 |
bop : 11 0 |
| 70 |
nop, eop, push, pop : 0 0 |
| 71 |
setcharXX : 0 0 |
| 72 |
fntnumYY : 0 0 |
| 73 |
setX, putX, rightX, downX : 1 0 |
| 74 |
setrule, writerule : 2 0 |
| 75 |
w0, x0, y0, z0 : 0 0 |
| 76 |
wX, xX, yX, zX : 1 0 |
| 77 |
fntX : 1 0 |
| 78 |
fntdefX : 6 1 |
| 79 |
xxxX : 1 1 |
| 80 |
dir : 1 0 |
| 81 |
post_post : 6 - 9 0 |
| 82 |
|
| 83 |
The following is used in DTL for illegal code |
| 84 |
opcode : 1 0 |
| 85 |
|
| 86 |
The following expression in DTL are also valid. |
| 87 |
|
| 88 |
push -> [ pop -> ] |
| 89 |
fntnum -> fn set -> s put -> p right -> r down -> d |
| 90 |
setrule -> sr putrule -> pr fnt -> f fntdef -> fd |
| 91 |
|
| 92 |
dvispc can read the format of the DVIware DTL (dt2dv/dv2dt) by Geoffrey Tobin. |
| 93 |
|
| 94 |
Transformations: [DVI file -> a text -> edit it -> DVI file] is possible |
| 95 |
The following command makes foo2.dvi by extracting the pages 4,5,6,8 from |
| 96 |
foo.dvi. |
| 97 |
|
| 98 |
dvispc -atpT4-6/8L foo1.dvi | dvispc -x foo2.dvi |
| 99 |
|
| 100 |
The following command is the same as the above. |
| 101 |
|
| 102 |
dvispc -atpT4-6/8L foo1.dvi | dvispc -x > foo2.dvi |
| 103 |
|
| 104 |
-x : 0: toggle length follows from the given string |
| 105 |
1: toggle omit unnecessary definitions of fonts |
| 106 |
2: toggle igonore the first line "variety ..." |
| 107 |
(If it is not ignored and it exists, then -t option is set). |
| 108 |
|
| 109 |
-p : Output instruction for DVI -> Text |
| 110 |
T: preambre |
| 111 |
L: postambre |
| 112 |
<n>: page <n> |
| 113 |
<n1>-<n2>: from the page <n1> to the page <n2> |
| 114 |
If <n1> is omitted, <n1> is assumed to be 1. |
| 115 |
If <n2> is omitted, <n2> is assumed to be the last page number. |
| 116 |
|
| 117 |
There are indicated by separating by appropriate characters if necessary. |
| 118 |
|
| 119 |
-pT-L default (total as in the original order) |
| 120 |
-pTL preambre and postambre |
| 121 |
-p3-15/20L the pages 3,4,5,...,15 and 20 in this order and postambre |
| 122 |
|
| 123 |
-r -rorg_1=new_1/org_2=new_2/... means org_i is replaced by new_i for i=1,2.. |
| 124 |
Here org_i is the keyword omitting figures. For example |
| 125 |
|
| 126 |
-rxxx=special/setchar=set_char_ |
| 127 |
|
| 128 |
The first letter of orig_i should be an alphabet in the small case if the |
| 129 |
option -x is indicated. |
| 130 |
|
| 131 |
-t : Transformation is done according to the DTL(dt2dv/dv2dt) by Geoffrey Tobin. |
| 132 |
The following suboptions (0-9: toggle switch) can be indicated such as -t02. |
| 133 |
|
| 134 |
The option -t with no suboption means that the following all suboptions |
| 135 |
and the options corresponding to the switches -x0 -x1 -x2 are all On and -j |
| 136 |
is Off and also the following line is inserted at the top in case of |
| 137 |
DVI -> Text. |
| 138 |
|
| 139 |
variety sequences-6 |
| 140 |
|
| 141 |
If in case of Text -> dvi this line exists at the top, -t is automatically |
| 142 |
set. |
| 143 |
|
| 144 |
0: str |
| 145 |
A string is indicated by '...' with the transformations ' -> \' and |
| 146 |
\ -> \\. A character whose code is smaller that 32 or larger than 126 is |
| 147 |
expressed by hexadecimal as in the following. |
| 148 |
1: ch |
| 149 |
Characters with the code between 0 and 127 are indicated by (...). |
| 150 |
Here the transformations ( -> \(, ) -> \) and \ -> \\ are used and the |
| 151 |
character with the code between 0 and 31 or 127 is independently shown by |
| 152 |
hexadecimal character starting with \ such as \12. |
| 153 |
2: ch2 |
| 154 |
The code of a character larger than 128 is expressed in digits. |
| 155 |
3: cmd |
| 156 |
The key word corresponding to a code is in the format as in DTL. |
| 157 |
4: c-sum |
| 158 |
check sum in the font definition is expressed by octal. |
| 159 |
5: dir/name |
| 160 |
The string of fontname is expressed by dividing into the directory and name. |
| 161 |
6: err |
| 162 |
The illegal code is expressed by opcode x (x: code). |
| 163 |
7: page |
| 164 |
The page number is not shown. |
| 165 |
8: oct |
| 166 |
The octal number for the check sum of the font definition is expressed |
| 167 |
without the top 0. |
| 168 |
9: str0 |
| 169 |
The length of a string is determined by the given string in case of |
| 170 |
Text -> DVI. |
| 171 |
|
| 172 |
-l: The address of the code is shown at the top of line. |
| 173 |
In this case |
| 174 |
|
| 175 |
0: pre 2 ... |
| 176 |
|
| 177 |
exists at the head. |
| 178 |
In case of Text -> DVI, the option -l is set if this line exists. |
| 179 |
|
| 180 |
-J: Set Japanese characters output with a suboption |
| 181 |
|
| 182 |
e: EUC-JP |
| 183 |
s: Shift_JIS |
| 184 |
u: UTF-8 for pTeX |
| 185 |
U: UTF-8 for upTeX |
| 186 |
|
| 187 |
When the program dvispc is built without ptexenc library (i.e. |
| 188 |
built outside TeX Live), the -J option is unavailable. |
| 189 |
Instead, the -j option can be used. |
| 190 |
|
| 191 |
-j: toggle, If the code of the character is within JIS code, then the |
| 192 |
corresponding character is shown. (unavailable for TeX Live) |
| 193 |
|
| 194 |
|
| 195 |
************************************************************ |
| 196 |
[2] ** Modify a DVI file to be page-independent in specials ** |
| 197 |
************************************************************ |
| 198 |
DVI file should be page-independent in principle. But some specials break this |
| 199 |
principle. |
| 200 |
|
| 201 |
For example, color specials of graphics package of LaTeX2e for dvips break this. |
| 202 |
Suppose there is a command to make letters red at page 2 of a document with the |
| 203 |
total pages 100 and it continues up to page 99. Then there is no command to |
| 204 |
make letters red at page 50. |
| 205 |
|
| 206 |
\usepackages[dvips]{graphicx, color} |
| 207 |
... |
| 208 |
{\color{red}% page 2 |
| 209 |
... |
| 210 |
... |
| 211 |
...% page 99 |
| 212 |
} |
| 213 |
... |
| 214 |
|
| 215 |
dvips reads a DVI file from the first page and therefore it correctly interprets |
| 216 |
color specials. But some other DVIwares such as dviout (previewer) cannot do so |
| 217 |
because it may be requested only to display the page 50. The same problem |
| 218 |
occurs for some DVI tools such as dvidvi. |
| 219 |
|
| 220 |
dvispc modifies such a DVI file to be page-independent. Supporting specials are |
| 221 |
|
| 222 |
color specials: push, pop, background |
| 223 |
pdf specials: pdf:bcolor, pdf:ecolor, pdf:bgcolor |
| 224 |
tpic specials: pn |
| 225 |
|
| 226 |
--- specifications --- |
| 227 |
-c: the above modification will be done |
| 228 |
-d: check the necessity of the modification |
| 229 |
-s: show all specials in DVI file |
| 230 |
|
| 231 |
If none of the parameters -s -d -a -x is indicated, dvispc modifies DVI file as |
| 232 |
described. |
| 233 |
|
| 234 |
-b : dvispc by default overwrites the original DVI file after modification. |
| 235 |
If -b is specified, the original file is backuped with suffix .bak. |
| 236 |
|
| 237 |
-z : If the input DVI has less than multiple of 4 pages, append empty pages |
| 238 |
to have multiple of 4. |
| 239 |
The program dvibook has similar function, but dvispc ensures page |
| 240 |
independency by explicitly setting the background of empty pages white. |
| 241 |
|
| 242 |
Supported specials are the followings. |
| 243 |
|
| 244 |
color specials: dvispc inserts necessary specials "color pop" at the end of each |
| 245 |
page so that the stack becomes empty there. Then it also inserts necessary |
| 246 |
specials "color push" at the top of the following page. |
| 247 |
dvispc checks the underflow and overflow (the limit is about 500 in dvispc) |
| 248 |
of this stack. Usually the overflow of stack occurs by the wrong source of |
| 249 |
TeX. In the case of the unerflow, dvispc writes specials "color push Black" |
| 250 |
at the top of the corresponding page to recover the error. |
| 251 |
|
| 252 |
background : If the "background" color is defined in a page and the |
| 253 |
definition is not written in another page where the definition should be |
| 254 |
valid, then the definition is inserted at the top of the page. |
| 255 |
|
| 256 |
pdf:bcolor, pdf:ecolor : Similar to color push/pop. |
| 257 |
|
| 258 |
pdf:bgcolor : Similar to background. |
| 259 |
|
| 260 |
tpic specials : If tpic special "pn" is defined, then the same special will be |
| 261 |
inserted at the top of the following pages. |
| 262 |
|
| 263 |
The order to be inserted at the top of each page is as follows |
| 264 |
|
| 265 |
color push -> pdf:bcolor -> background -> pdf:bgcolor -> pn (tpic special) |