summaryrefslogtreecommitdiffstats
path: root/doc/kdvi/KDVI-features.tex
blob: 66c3f9f5b19f693f3c02b3b79d6bc063bf108134 (plain)
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
\documentclass{article}

\usepackage{amstext}
\usepackage{colordvi}
\usepackage{graphicx}
\usepackage{times} 
\usepackage[arrow,matrix,curve,ps]{xy}
\xyoption{dvips}
\usepackage[active]{srcltx}
\usepackage[hypertex]{hyperref}
\sloppy

\newcommand{\KDVI}{{\sf KDVI 1.1}}

\begin{document}

\title{Support for \TeX\ extensions in \KDVI}

\author{Stefan Kebekus}

\maketitle
\begin{abstract}
  This document describes the extensions to the standard format of DVI
  files which \KDVI\ implements in order to support PostScript
  inclusion and hyperlinks.
  
  \KDVI\ is a program that displays DVI-files generated by the \TeX\ 
  typesetting system. If you don't know what \TeX\ is then you are
  most likely not interested in this. If you would like to know how to
  use special features of \KDVI, then you can find examples here.
\end{abstract}

\tableofcontents

\section{What's all this}

The DVI-previewing program \KDVI\ is able to display standard
DVI-files as specified in \cite{Level0Std}. In order to support
graphics inclusion, hyperlinks and non-standard fonts, \KDVI\ 
implements a number of features which extend \cite{Level0Std}. In
particular, \KDVI\ supports a number of \TeX 's $\backslash${\tt
  special} commands. The aim of this document is to describe these
extensions and give examples of their use.

Unfortunately, in spite of several attempts to find a sound standard
for the use of $\backslash${\tt special} commands, there is now a
wealth of competing and mutually incompatible definitions.

\KDVI\ does not attempt to support all possible features. Instead, we
tried to implement those which are most useful and used most commonly.
In this, we have tried to be consistent with the {\sf dvips} program.
\KDVI\ does not support a number of outdated and unsane standards, nor
does it support features which impair the system security.


\section{Virtual fonts}

\KDVI\ supports ``virtual fonts''. This enables \TeX\ to use
PostScript fonts. For more information, and a complete specification,
consult \cite{dvips}.

\paragraph*{Example}

This text uses the ``Times'' family of fonts instead of the ``Computer
Modern'' fonts which are usually used by \TeX. This was realized in
\LaTeX 2$\epsilon$ by including the line
\begin{verbatim}
\usepackage{times} 
\end{verbatim}
in the header of this document.


\section{PostScript support}

\KDVI\ implements basic facilities to include PostScript graphics in a
DVI file, which will enable the reader to conviently read most
scientific papers which use such features. 

\subsection{Literal PostScript}

\KDVI\ supports the inclusion of PostScript into DVI-files by means of
the quote-special. The syntax follows the specification of
\cite{dvips}:
\begin{verbatim}
\special{" PostScript-commands}
\end{verbatim}
The PostScript-commands are not directly included, in fact they are
sandwiched between a {\tt save} and {\tt restore} pair. That way
\KDVI\ ensures that the command cannot affect PostScript-commands
which appear somewhere else in your file.

\paragraph*{Example}

Figure~\ref{quote-special} shows an example taken from \cite{dvips}.
The generating \TeX -code is
\begin{verbatim}
\vbox to 100bp{\vss
\special{" newpath 0 0 moveto 100 100 lineto
 300 0 lineto closepath gsave 0.8 setgray fill 
 grestore stroke}}
\end{verbatim}

\begin{figure}
\vbox to 100bp{\vss
\special{" newpath 0 0 moveto 100 100 lineto 300 0 lineto closepath gsave 0.8 setgray fill grestore stroke}}
\caption{Graphic generated by literal PostScript inclusion\label{quote-special}}
\end{figure}


\subsection{Direct PostScript}

\KDVI\ supports the inclusion of PostScript into DVI-files by means of
the direct-special. The syntax follows the specification of
\cite{dvips}:
\begin{verbatim}
\special{ps: Postscript-commands}
\end{verbatim}
The PostScript-commands are directly included, and there is no
protective {\tt save} and {\tt restore} pair. The use of this command
is not recommended, as it may have funny side effects on other
PostScript commands which appear later in your file.

\KDVI\ also supports the following syntactical variants which are
explained in \cite{dvips}:
\begin{verbatim}
\special{ps: Postscript-commands}
\special{ps::[begin] Postscript-commands}
\special{ps:: Postscript-commands}
\special{ps::[end] Postscript-commands}
\end{verbatim}
The variant
\begin{verbatim}
\special{ps: plotfile filename}
\end{verbatim}
is not currently supported.

\paragraph*{Example}

The command
\begin{verbatim}
\includegraphics[height=3cm, angle=20]{aboutkde.ps}
\end{verbatim}
which is used in section~\ref{chap:eps} uses the direct-special
internally in order to set the rotation.

\subsection{Literal headers}

Literal headers work as described in \cite{dvips}.
\begin{verbatim}
\special{! PostScript-Header-commands}
\end{verbatim}

\paragraph*{Example}
The following diagram, which was generated using the \Xy -pic macro
packages uses literal postscript inclusion which relies on literal
headers.
$$
\xymatrix{ {\tilde X}
  \ar@{-->}[rrd]_{\exists \alpha} \ar[rrrr]^{\eta}_{\txt{\tiny
      normalization}} \ar@/_/ [rrdd]_ {\tilde \pi} & & & & {X}
  \ar@/^/[lldd]^{\pi}  \\ & & {X'}
  \ar@{-->}[rru]_{\exists \beta} \ar@{-->}[d]_{\exists \pi'} & & \\ & &
  {Y}& &}
$$
Note that the actual headers are defined on the first page of the
document. This was a major source of trouble in earlier versions of
KDVI.



\subsection{PostScript headers}

PostScript headers work as described in \cite{dvips}. This command is
very similar to the literal header command, but expects the name of a
file which should be included.
\begin{verbatim}
\special{header=filename}
\end{verbatim}




\subsection{EPS inclusion}\label{chap:eps}

A popular way to include PostScript-files into \TeX\ documents uses
the PSFile $\backslash${\tt special} command. Again this is explained
in detail in \cite{dvips}. Currently \KDVI\ supports the syntax
\begin{verbatim}
\special{psfile=File keyword=value keyword=value ...}
\end{verbatim}
Where keyword is one of the following
\begin{description}
\item[llx] lower left corner of the bounding box, $x$-coordinate
\item[lly] lower left corner of the bounding box, $y$-coordinate
\item[urx] upper right corner of the bounding box, $x$-coordinate
\item[ury] upper right corner of the bounding box, $y$-coordinate
\item[rwi] width of the bounding box. If $llx-urx \not = rwi$, then
the boundig box is scaled accordingly. 
\item[rhi] height of the bounding box If $lly-ury \not = rhi$, then
the boundig box is scaled accordingly.
\item[angle] rotates the picture counterclockwise
\end{description}
Unknown keywords are silently ignored. The keywords {\tt llx}, {\tt
  lly}, {\tt urx}, {\tt ury} and {\tt rwi} are usually generated by
the {\tt epsf} macros.  The keywords {\tt hoffset}, {\tt voffset},
{\tt hsize}, {\tt vsize}, {\tt hscale}, {\tt vscale}, {\tt angle} and
{\tt clip} are not currently implemented. The ``uncompression''
feature of {\sf dvips} and {\sf xdvi} which allows to execute
arbitrary commands in via the syntactical variant
\begin{verbatim}
\special{psfile="'shell-command" keyword=value ...}
\end{verbatim}
is deliberately not implemented for security reasons.

\paragraph*{Example}
Figure~\ref{epsf-special} shows an embedded postscript-file. 
\begin{figure}
  \begin{center}
    \includegraphics[height=3cm]{aboutkde.ps}
    \includegraphics[height=4cm]{aboutkde.ps}
    \includegraphics[height=3cm, angle=20]{aboutkde.ps}
  \end{center}
\caption{Embedded PostScript graphic\label{epsf-special}}
\end{figure}
This was easily realized by including the line
\begin{verbatim}
\usepackage{graphicx}
\end{verbatim}
into the header of this document, and the lines
\begin{verbatim}
\includegraphics[height=3cm]{aboutkde.ps}
\includegraphics[height=4cm]{aboutkde.ps}
\includegraphics[height=3cm, angle=20]{aboutkde.ps}
\end{verbatim}
at the place where the graphic should appear. It is strongly
recommended to use the {\tt graphicx} macro package for this purpose.
\begin{figure}
  \begin{center}
    \includegraphics[height=2cm, bb=0 0 150 50]{nonexistent.ps}
  \end{center}
\caption{Reference to a non-existent PS-file\label{nonex-special}}
\end{figure}
Figure~\ref{nonex-special} shows how \KDVI\ warns you about
non-existent files.


\section{Hypertext support}

\KDVI\ supports commands for hyperlink support which commands
establish links between sections of documents in a manner exactly
analogous to the HTML of the WWW. For a detailed specification we
refer to \cite{HFAQ99} or \cite{Rah98}. Note, however, that \KDVI\ 
does currently not allow nested hyperlinks.

\subsection{Hyper-Labels}

The commands
\begin{verbatim}
\special{html:<a name="namestring">}
\special{html:</a>}
\end{verbatim}
labels the current point of the text for later reference.

\subsection{Hyper-References}

The commands 
\begin{verbatim}
\special{html:<a href="hrefstring">}
Text
\special{html:</a>}
\end{verbatim}
makes {\tt Text} a link to {\tt hrefstring}, where {\tt hrefstring} is
an absolute or relative URL in the standard format used on the
internel. If {\tt hrefstring} is of the form {\tt \#label} then it
points to the section of the current document which is labeled using
the labeling command described above:
\begin{verbatim}
\special{html:<a name="namestring">}
\end{verbatim}



\paragraph*{Example}
This document features a clickable table of contents, and also the
references can be clicked on. This has been achieved by using the {\tt
  hyperref} macro package in \LaTeX\ by including the line
\begin{verbatim}
\usepackage[hypertex]{hyperref}
\end{verbatim}
into the document preamble. Everything else is automatic.

Here is an external link which points to the \href{http://www.kde.org}{main
  website of the KDE project}. For this, the command {\tt href} of the
{\tt hyperref} macro package was used:
\begin{verbatim}
\href{http://www.kde.org}{main
  website of the KDE project}
\end{verbatim}


\paragraph{Warning.} On some installations, the {\tt
  hyperref} macro package is configured to generate PostScript
hyperlinks for {\tt dvips} by default. On these systems, using the
line
\begin{verbatim}
\usepackage{hyperref}
\end{verbatim}
will generate DVI file whose hyperlinks are not visible in KDVI.
Worse, KDVI will call the {\tt ghostview} PostScript interpreter for
every page, which makes the display very slow.



\section{Colored \Red{text} \Green{and} \Blue{background}}

The DVI specials for colored text are supported as they are described
in \cite{dvips}. 

\paragraph*{Example} In this document, the following code was used to
generate the text below.
\begin{verbatim}
\usepackage{colordvi}

...

\textGreen This text is green but here we are
\Red{switching to red, \Blue{nesting blue}, 
recovering the red} and back to original green.
\textCyan The text from here on will be cyan 
unless \Yellow{locally changed to yellow}. Now
we are back to cyan. \textBlack
\end{verbatim}

This gave the following output:
\begin{verse}
 \textGreen This text is green but here
we are \Red{switching to red, \Blue{nesting blue}, recovering the red}
and back to original green.  \textCyan The text from here on will be
cyan unless \Yellow{locally changed to yellow}. Now we are back to
cyan.  \textBlack
\end{verse}

To set the background color of the page, the command
\background{Lavender}
\begin{verbatim}
\background{Lavender}
\end{verbatim}
was used. To switch back to normal, the command
\begin{verbatim}
\background{White}
\end{verbatim}
was placed somewhere on the following page. As you see, the background
command does not fit well into \LaTeX's philosophy and should be
avoided.

\section{Rotated Text}

Rotated text can sometimes be useful, e.g. to fit large table onto a
single page. This is used, e.g.~in the style files of journals of the
American Astronomical Society. Here is one example.

\begin{table}[h]
  \centering
\begin{tabular}{l|ll}
  & \rotatebox{90}{uses \TeX} & \rotatebox{90}{uses Linux} \\ \hline
  Stefan & $\times$ & $\times$ \\
  Anke & & $\times$ \\
  Thomas & $\times$ &\\
\end{tabular}
\end{table}

This was easily realized by including the line
\begin{verbatim}
\usepackage{graphicx}
\end{verbatim}
into the header of this document. The table itself was then typeset by
{\footnotesize
\begin{verbatim}
\begin{tabular}{l|ll}
  & \rotatebox{90}{uses \TeX} & \rotatebox{90}{uses Linux} \\ \hline
  Stefan & $\times$ & $\times$ \\
  Anke & & $\times$ \\
  Thomas & $\times$ &\\
\end{tabular}
\end{verbatim}
}

\section{Source text specials}

\KDVI\ is able to make use of source file information which is included
in the DVI file. To include source file information, a {\tt special}
command like to following should be included at the beginning of every
paragraph or every line:
\begin{verbatim}
\special{src:123text.tex}
\end{verbatim}
This tells \KDVI\ that the next paragraph should be associated with
line 123 in the source file text.tex.

It is of course not practical to add these commands manually to the
beginning of every line ---see the \href{help:/kdvi}{Handbook of
\KDVI} to learn how to add the special commands automatically to your
DVI files.

The main use of source file specials is the interaction between \KDVI\
and your editor. Starting from version~1.0, both \emph{forward search}
and \emph{inverse search} are supported.

\subsection{Forward search}

Forward search is a feature that helps you find the place in the DVI
file that corresponds to a certain line in the source text. If source
file information is included, you can find the place in the DVI file
{\tt test.dvi} which corresponds to line 1234 in the source file {\tt
text.tex} by starting \KDVI\ like this:
\begin{verbatim}
kdvi file:test.dvi#1234text.tex
\end{verbatim}
In pracitse, this command line will be generated by a script that
communicates with your editor. Currently, scripts for Emacs and XEmacs
exist. As usual, the \href{help:/kdvi/forward-search.html}{Handbook of
\KDVI} explains how to set up your editor with thest scripts.


\subsection{Inverse search}

\background{White}
Inverse search means that you can click into the document in \KDVI,
and your editor will open, load the source file and jump to the proper
place. \KDVI\ currently supports the editors Emacs, Kate, NEdit, VI
and XEmacs. Users who prefer a different editor can specify shell
commands which are to be used. Again we refer to the
\href{help:/kdvi/inverse-search.html}{Handbook of \KDVI} for a detailed explanation.

\paragraph*{Example}
If you are viewing this document in \KDVI, you can click anywhere with
the middle mouse button (if your mouse has only two buttons, click
left and right simultaneously). An editor will pop up, load the
\LaTeX\ sourcefile and jump to the appropriate line in the
text. Source specials has been added using the {\tt srcltx} macro
package in \LaTeX\ by including the line
\begin{verbatim}
\usepackage[active]{srcltx}
\end{verbatim}
into the document preamble. Everything else is automatic.


\begin{thebibliography}{CM97}

\bibitem[Bha99]{HFAQ99}
T.~Bhattacharya et al.
\newblock {\em Hyper\TeX\ FAQ}
\newblock available on the internet site of the preprint server of the
 Los Alamos National Labatories at 
\href{http://arXiv.org/hypertex}{\small \tt http://arXiv.org/hypertex}

\bibitem[Rah98]{Rah98}
S.~Rahts
\newblock {\em Hypertext marks in \LaTeX: the {\sf hyperref} package}
\newblock included in the tetex distribution. A copy can be found on KDVI's 
home page at \hfill \linebreak
\href{http://devel-home.kde.org/~kdvi/DVI/hyperref-manual.pdf}{\small \tt http://devel-home.kde.org/$\sim$kdvi/DVI/hyperref-manual.pdf}

\bibitem[Rok00]{dvips}
T.~Rokicki
\newblock {\em DVIPS: A \TeX\ Driver}
\newblock included in the tetex distribution. A copy can be found on KDVI's 
home page at \hfill \linebreak
\href{http://devel-home.kde.org/~kdvi/DVI/dvips.dvi}{\small \tt http://devel-home.kde.org/$\sim$kdvi/DVI/dvips.dvi}

\bibitem[TUG0]{Level0Std}
The TUG DVI Driver Standards Committee
\newblock {\em The DVI Driver Standard, Level 0}
\newblock included in the tetex distribution. A copy can be found on KDVI's 
home page at \hfill \linebreak
\href{http://devel-home.kde.org/~kdvi/DVI/dvistd0.dvi}{\small \tt http://devel-home.kde.org/$\sim$kdvi/DVI/dvistd0.dvi}


\end{thebibliography}
\end{document}