update upload data
[PyX.git] / manual / text.tex
blob14a1fd3b46ebc0c499eaac7a26a41bebd03e2971
1 \chapter[Module \module{text}: TeX/LaTeX interface]{Module \module{text}: \TeX/\LaTeX{} interface}
2 \label{module:text}
4 \section{Basic functionality}
6 The \module{text} module seamlessly integrates Donald E. Knuths famous
7 \TeX{} typesetting engine into \PyX. The basic procedure is:
8 \begin{itemize}
9 \item start a \TeX/\LaTeX{} instance as soon as a \TeX/\LaTeX{}
10 preamble setting or a text creation is requested
11 \item create boxes containing the requested text and shipout those
12 boxes to the dvi file
13 \item immediately analyse the \TeX/\LaTeX{} output for errors; the box
14 extents are also contained in the \TeX/\LaTeX{} output and thus become
15 available immediately
16 \item when your TeX installation supports the \texttt{ipc} mode and
17 \PyX{} is configured to use it, the dvi output is also analysed
18 immediately; alternatively \PyX{} quits the \TeX/\LaTeX{} instance to
19 read the dvi file once the output needs to be generated or marker
20 positions are accessed
21 \item Type1 fonts are used for the PostScript generation
22 \end{itemize}
24 Note that for using Type1 fonts an appropriate font mapping file has
25 to be provided. When your \TeX{} installation is configured to use
26 Type1 fonts by default, the \texttt{psfonts.map} will contain entries
27 for the standard \TeX{} fonts already. Alternatively, you may either
28 look for \texttt{updmap} used by many \TeX{} distributions to create
29 an appropriate font mapping file. You may also specify one or several
30 alternative font mapping files like \texttt{psfonts.cmz} in the global
31 \texttt{pyxrc} or your local \texttt{.pyxrc}. Finally you can also use
32 the \var{fontmap} keyword argument to a texrunners \method{text}
33 method to use different mappings within a single outout file.
35 \section[TeX/LaTeX instances: the \class{texrunner} class]%
36 {\TeX/\LaTeX{} instances: the \class{texrunner} class}
37 \declaremodule{}{text}
38 \modulesynopsis{\TeX/\LaTeX interface}
40 Instances of the class \class{texrunner} are responsible for executing
41 and controling a \TeX/\LaTeX{} instance.
43 \begin{classdesc}{texrunner}{mode="tex",
44 lfs="10pt",
45 docclass="article",
46 docopt=None,
47 usefiles=[],
48 fontmaps=config.get("text", "fontmaps", "psfonts.map"),
49 waitfortex=config.getint("text", "waitfortex", 60),
50 showwaitfortex=config.getint("text", "showwaitfortex", 5),
51 texipc=config.getboolean("text", "texipc", 0),
52 texdebug=None,
53 dvidebug=0,
54 errordebug=1,
55 pyxgraphics=1,
56 texmessagesstart=[],
57 texmessagesdocclass=[],
58 texmessagesbegindoc=[],
59 texmessagesend=[],
60 texmessagesdefaultpreamble=[],
61 texmessagesdefaultrun=[]}
62 \var{mode} should the string \samp{tex} or \samp{latex} and defines
63 whether \TeX{} or \LaTeX{} will be used. \var{lfs} specifies an
64 \texttt{lfs} file to simulate \LaTeX{} font size selection macros in
65 plain \TeX. \PyX{} comes with a set of \texttt{lfs} files and a
66 \LaTeX{} script to generate those files. For \var{lfs} being
67 \code{None} and \var{mode} equals \samp{tex} a list of installed
68 \texttt{lfs} files is shown.
70 \var{docclass} is the document class to be used in \LaTeX{} mode and
71 \var{docopt} are the options to be passed to the document class.
73 \var{usefiles} is a list of \TeX/\LaTeX{} jobname files. \PyX{} will
74 take care of the creation and storing of the corresponding temporary
75 files. A typical use-case would be \var{usefiles=["spam.aux"]}, but
76 you can also use it to access \TeX{}s log and dvi file.
78 \var{fontmaps} is a string containing whitespace separated names of
79 font mapping files. \var{waitfortex} is a number of seconds \PyX{}
80 should wait for \TeX/\LaTeX{} to process a request. While waiting
81 for \TeX/\LaTeX{} a \PyX{} process might seem to do not perform any
82 work anymore. To give some feedback to the user, a messages is
83 issued each \var{waitfortex} seconds. The \texttt{texipc} flag
84 indicates whether \PyX{} should use the \texttt{--ipc} option of
85 \TeX/\LaTeX{} for immediate dvi file access to increase the
86 execution speed of certain operations. See the output of
87 \texttt{tex~--help} whether the option is available at your \TeX{}
88 installation.
90 \var{texdebug} can be set to a filename to store the commands passed
91 to \TeX/\LaTeX{} for debugging. The flag \var{dvidebug} enables
92 debugging output in the dvi parser similar to \texttt{dvitype}.
93 \var{errordebug} controls the amount of information returned, when
94 an texmessage parser raises an error. Valid values are \code{0},
95 \code{1}, and \code{2}.
97 \var{pyxgraphics} allows use \LaTeX{}s graphics package without
98 further configuration of \texttt{pyx.def}.
100 The \TeX{} message parsers verify whether \TeX/\LaTeX{} could
101 properly process its input. By the parameters
102 \var{texmessagesstart}, \var{texmessagesdocclass},
103 \var{texmessagesbegindoc}, and \var{texmessagesend} you can set
104 \TeX{} message parsers to be used then \TeX/\LaTeX{} is started,
105 when the \texttt{documentclass} command is issued (\LaTeX{} only),
106 when the \texttt{\textbackslash{}begin\{document\}} is sent, and
107 when the \TeX/\LaTeX{} is stopped, respectively. The lists of
108 \TeX{} message parsers are merged with the following defaults:
109 \code{[texmessage.start]} for \var{texmessagesstart},
110 \code{[texmessage.load]} for \var{texmessagesdocclass},
111 \code{[texmessage.load, texmessage.noaux]} for
112 \var{texmessagesbegindoc}, and \code{[texmessage.texend,
113 texmessage.fontwarning]} for \var{texmessagesend}.
115 Similarily \var{texmessagesdefaultpreamble} and
116 \var{texmessagesdefaultrun} take \TeX{} message parser to be merged
117 to the \TeX{} message parsers given in the \method{preamble()} and
118 \method{text()} methods. The \var{texmessagesdefaultpreamble} and
119 \var{texmessagesdefaultrun} are merged with \code{[texmessage.load]}
120 and \code{[texmessage.loaddef, texmessage.graphicsload,
121 texmessage.fontwarning, texmessage.boxwarning]}, respectively.
122 \end{classdesc}
124 \class{texrunner} instances provides several methods to be called by
125 the user:
127 \begin{methoddesc}{set}{**kwargs}
128 This method takes the same keyword arguments as the
129 \class{texrunner} constructor. Its purpose is to reconfigure an
130 already constructed \class{texrunner} instance. The most prominent
131 use-case is to alter the configuration of the default
132 \class{texrunner} instance \code{defaulttexrunner} which is created
133 at the time of loading of the \module{text} module.
135 The \verb|set| method fails, when a modification cannot be applied
136 anymore (e.g. \TeX/\LaTeX{} has already been started).
137 \end{methoddesc}
139 \begin{methoddesc}{preamble}{expr, texmessages=[]}
140 The \method{preamble()} can be called prior to the \method{text()}
141 method only or after reseting a texrunner instance by
142 \method{reset()}. The \var{expr} is passed to the \TeX/\LaTeX{}
143 instance not encapsulated in a group. It should not generate any
144 output to the dvi file. In \LaTeX{} preamble expressions are
145 inserted prior to the \texttt{\textbackslash{}begin\{document\}} and
146 a typical use-case is to load packages by
147 \texttt{\textbackslash{}usepackage}. Note, that you may use
148 \texttt{\textbackslash{}AtBeginDocument} to postpone the
149 immediate evaluation.
151 \var{texmessages} are \TeX{} message parsers to handle the output of
152 \TeX/\LaTeX. They are merged with the default \TeX{} message
153 parsers for the \method{preamble()} method. See the constructur
154 description for details on the default \TeX{} message parsers.
155 \end{methoddesc}
157 \begin{methoddesc}{text}{x, y, expr, textattrs=[], texmessages=[]}
158 \var{x} and \var{y} are the position where a text should be typeset
159 and \var{expr} is the \TeX/\LaTeX{} expression to be passed to
160 \TeX/\LaTeX{}.
162 \var{textattrs} is a list of \TeX/\LaTeX{} settings as described
163 below, \PyX{} transformations, and \PyX{} fill styles (like colors).
165 \var{texmessages} are \TeX{} message parsers to handle the output of
166 \TeX/\LaTeX. They are merged with the default \TeX{} message
167 parsers for the \method{text()} method. See the constructur
168 description for details on the default \TeX{} message parsers.
170 The \method{text()} method returns a \class{textbox} instance, which
171 is a special \class{canvas} instance. It has the methods
172 \method{width()}, \method{height()}, and \method{depth()} to access
173 the size of the text. Additionally the \method{marker()} method,
174 which takes a string \emph{s}, returns a position in the text, where
175 the expression \texttt{\textbackslash{}PyXMarker\{\emph{s}\}} is
176 contained in \var{expr}. You should not use \texttt{@} within your
177 strings \emph{s} to prevent name clashes with \PyX{}
178 internal macros (although we don't the marker feature internally
179 right now).
180 \end{methoddesc}
182 Note that for the outout generation and the marker access the
183 \TeX/\LaTeX{} instance must be terminated except when \texttt{texipc} is
184 turned on. However, after such a termination a new \TeX/\LaTeX{}
185 instance is started when the \method{text()} method is called again.
187 \begin{methoddesc}{reset}{reinit=0}
188 This method can be used to manually force a restart of
189 \TeX/\LaTeX{}. The flag \var{reinit} will initialize the
190 \TeX/\LaTeX{} by repeating the \method{preamble()} calls. New
191 \method{set()} and \method{preamble()} calls are allowed when
192 \var{reinit} was not set only.
193 \end{methoddesc}
196 \section[TeX/LaTeX attributes]
197 {\TeX/\LaTeX{} attributes}
198 \declaremodule{}{text}
199 \modulesynopsis{\TeX/\LaTeX interface}
201 \TeX/\LaTeX{} attributes are instances to be passed to a
202 \class{texrunner}s \method{text()} method. They stand for
203 \TeX/\LaTeX{} expression fragments and handle dependencies by proper
204 ordering.
206 \begin{classdesc}{halign}{boxhalign, flushhalign}
207 Instances of this class set the horizontal alignment of a text box
208 and the contents of a text box to be left, center and right for
209 \var{boxhalign} and \var{flushhalign} being \code{0}, \code{0.5},
210 and \code{1}. Other values are allowed as well, although such an
211 alignment seems quite unusual.
212 \end{classdesc}
214 Note that there are two separate classes \class{boxhalign} and
215 \class{flushhalign} to set the alignment of the box and its contents
216 independently, but those helper classes can't be cleared independently
217 from each other. Some handy instances available as class members:
219 \begin{memberdesc}{boxleft}
220 Left alignment of the text box, \emph{i.e.} sets \var{boxhalign} to
221 \code{0} and doesn't set \var{flushhalign}.
222 \end{memberdesc}
224 \begin{memberdesc}{boxcenter}
225 Center alignment of the text box, \emph{i.e.} sets \var{boxhalign} to
226 \code{0.5} and doesn't set \var{flushhalign}.
227 \end{memberdesc}
229 \begin{memberdesc}{boxright}
230 Right alignment of the text box, \emph{i.e.} sets \var{boxhalign} to
231 \code{1} and doesn't set \var{flushhalign}.
232 \end{memberdesc}
234 \begin{memberdesc}{flushleft}
235 Left alignment of the content of the text box in a multiline box,
236 \emph{i.e.} sets \var{flushhalign} to \code{0} and doesn't set
237 \var{boxhalign}.
238 \end{memberdesc}
240 \begin{memberdesc}{raggedright}
241 Identical to \member{flushleft}.
242 \end{memberdesc}
244 \begin{memberdesc}{flushcenter}
245 Center alignment of the content of the text box in a multiline box,
246 \emph{i.e.} sets \var{flushhalign} to \code{0.5} and doesn't set
247 \var{boxhalign}.
248 \end{memberdesc}
250 \begin{memberdesc}{raggedcenter}
251 Identical to \member{flushcenter}.
252 \end{memberdesc}
254 \begin{memberdesc}{flushright}
255 Right alignment of the content of the text box in a multiline box,
256 \emph{i.e.} sets \var{flushhalign} to \code{1} and doesn't set
257 \var{boxhalign}.
258 \end{memberdesc}
260 \begin{memberdesc}{raggedleft}
261 Identical to \member{flushright}.
262 \end{memberdesc}
264 \begin{memberdesc}{left}
265 Combines \member{boxleft} and \member{flushleft}, \emph{i.e.}
266 \code{halign(0, 0)}.
267 \end{memberdesc}
269 \begin{memberdesc}{center}
270 Combines \member{boxcenter} and \member{flushcenter}, \emph{i.e.}
271 \code{halign(0.5, 0.5)}.
272 \end{memberdesc}
274 \begin{memberdesc}{right}
275 Combines \member{boxright} and \member{flushright}, \emph{i.e.}
276 \code{halign(1, 1)}.
277 \end{memberdesc}
279 \begin{figure}
280 \centerline{\includegraphics{textvalign}}
281 \caption{valign example}
282 \label{fig:textvalign}
283 \end{figure}
285 \begin{classdesc}{valign}{valign}
286 Instances of this class set the vertical alignment of a text box to
287 be top, center and bottom for \var{valign} being \code{0},
288 \code{0.5}, and \code{1}. Other values are allowed as well, although
289 such an alignment seems quite unusual. See the left side of
290 figure~\ref{fig:textvalign} for an example.
291 \end{classdesc}
293 Some handy instances available as class members:
295 \begin{memberdesc}{top}
296 \code{valign(0)}
297 \end{memberdesc}
299 \begin{memberdesc}{middle}
300 \code{valign(0.5)}
301 \end{memberdesc}
303 \begin{memberdesc}{bottom}
304 \code{valign(1)}
305 \end{memberdesc}
307 \begin{memberdesc}{baseline}
308 Identical to clearing the vertical alignment by \member{clear} to
309 emphasise that a baseline alignment is not a box-related alignment.
310 Baseline alignment is the default, \emph{i.e.} no valign is set by
311 default.
312 \end{memberdesc}
314 \begin{classdesc}{parbox}{width, baseline=top}
315 Instances of this class create a box with a finite width, where the
316 typesetter creates multiple lines in. Note, that you can't create
317 multiple lines in \TeX/\LaTeX{} without specifying a box width.
318 Since \PyX{} doesn't know a box width, it uses \TeX{}s LR-mode by
319 default, which will always put everything into a single line. Since
320 in a vertical box there are several baselines, you can specify the
321 baseline to be used by the optional \var{baseline} argument. You can
322 set it to the symbolic names \member{top}, \member{parbox.middle},
323 and \member{parbox.bottom} only, which are members of
324 \class{valign}. See the right side of figure~\ref{fig:textvalign}
325 for an example.
326 \end{classdesc}
328 Since you need to specify a box width no predefined instances are
329 available as class members.
331 \begin{classdesc}{vshift}{lowerratio, heightstr="0"}
332 Instances of this class lower the output by \var{lowerratio} of the
333 height of the string \var{heigthstring}. Note, that you can apply
334 several shifts to sum up the shift result. However, there is still a
335 \member{clear} class member to remove all vertical shifts.
336 \end{classdesc}
338 Some handy instances available as class members:
340 \begin{memberdesc}{bottomzero}
341 \code{vshift(0)} (this doesn't shift at all)
342 \end{memberdesc}
344 \begin{memberdesc}{middlezero}
345 \code{vshift(0.5)}
346 \end{memberdesc}
348 \begin{memberdesc}{topzero}
349 \code{vshift(1)}
350 \end{memberdesc}
352 \begin{memberdesc}{mathaxis}
353 This is a special vertical shift to lower the output by the height
354 of the mathematical axis. The mathematical axis is used by \TeX{}
355 for the vertical alignment in mathematical expressions and is often
356 usefull for vertical alignment. The corresponding vertical shift is
357 less than \member{middlezero} and usually fits the height of the
358 minus sign. (It is the height of the minus sign in mathematical
359 mode, since that's that the mathematical axis is all about.)
360 \end{memberdesc}
362 There is a \TeX/\LaTeX{} attribute to switch to \TeX{}s math mode. The
363 appropriate instances \code{mathmode} and \code{clearmathmode} (to
364 clear the math mode attribute) are available at module level.
366 \begin{datadesc}{mathmode}
367 Enables \TeX{}s mathematical mode in display style.
368 \end{datadesc}
370 The \class{size} class creates \TeX/\LaTeX{} attributes for changing
371 the font size.
373 \begin{classdesc}{size}{sizeindex=None, sizename=None,
374 sizelist=defaultsizelist}
375 \LaTeX{} knows several commands to change the font size. The command
376 names are stored in the \var{sizelist}, which defaults to
377 \code{[\textquotedbl{}normalsize\textquotedbl{},
378 \textquotedbl{}large\textquotedbl{},
379 \textquotedbl{}Large\textquotedbl{},
380 \textquotedbl{}LARGE\textquotedbl{},
381 \textquotedbl{}huge\textquotedbl{},
382 \textquotedbl{}Huge\textquotedbl{},
383 None, \textquotedbl{}tiny\textquotedbl{},
384 \textquotedbl{}scriptsize\textquotedbl{},
385 \textquotedbl{}footnotesize\textquotedbl{},
386 \textquotedbl{}small\textquotedbl{}]}.
388 You can either provide an index \var{sizeindex} to access an item in
389 \var{sizelist} or set the command name by \var{sizename}.
390 \end{classdesc}
392 Instances for the \LaTeX{}s default size change commands are available
393 as class members:
395 \begin{memberdesc}{tiny}
396 \code{size(-4)}
397 \end{memberdesc}
399 \begin{memberdesc}{scriptsize}
400 \code{size(-3)}
401 \end{memberdesc}
403 \begin{memberdesc}{footnotesize}
404 \code{size(-2)}
405 \end{memberdesc}
407 \begin{memberdesc}{small}
408 \code{size(-1)}
409 \end{memberdesc}
411 \begin{memberdesc}{normalsize}
412 \code{size(0)}
413 \end{memberdesc}
415 \begin{memberdesc}{large}
416 \code{size(1)}
417 \end{memberdesc}
419 \begin{memberdesc}{Large}
420 \code{size(2)}
421 \end{memberdesc}
423 \begin{memberdesc}{LARGE}
424 \code{size(3)}
425 \end{memberdesc}
427 \begin{memberdesc}{huge}
428 \code{size(4)}
429 \end{memberdesc}
431 \begin{memberdesc}{Huge}
432 \code{size(5)}
433 \end{memberdesc}
435 There is a \TeX/\LaTeX{} attribute to create empty text boxes with the
436 size of the material passed in. The appropriate instances
437 \code{phantom} and \code{clearphantom} (to clear the phantom
438 attribute) are available at module level.
440 \begin{datadesc}{phantom}
441 Skip the text in the box, but keep its size.
442 \end{datadesc}
444 \section[Using the graphics-bundle with LaTeX]%
445 {Using the graphics-bundle with \LaTeX}
447 The packages in the \LaTeX{} graphics bundle (\texttt{color.sty},
448 \texttt{graphics.sty}, \texttt{graphicx.sty}, \ldots) make extensive use of
449 \texttt{\textbackslash{}special} commands. \PyX{} defines a clean set of such
450 commands to fit the needs of the \LaTeX{} graphics bundle. This is done via the
451 \texttt{pyx.def} driver file, which tells the graphics bundle about the syntax
452 of the \texttt{\textbackslash{}special} commands as expected by \PyX{}. You can
453 install the driver file \texttt{pyx.def} into your \LaTeX{} search path and add
454 the content of both files \texttt{color.cfg} and \texttt{graphics.cfg} to your
455 personal configuration files.\footnote{If you do not know what this is all
456 about, you can just ignore this paragraph. But be sure that the
457 \var{pyxgraphics} keyword argument is always set!} After you have installed the
458 \texttt{cfg} files, please use the \module{text} module with unset
459 \code{pyxgraphics} keyword argument which will switch off a convenience hack
460 for less experienced \LaTeX{} users. You can then import the \LaTeX{} graphics
461 bundle packages and related packages (e.g.~\texttt{rotating}, \ldots) with the
462 option~\texttt{pyx},
463 e.g.~\texttt{\textbackslash{}usepackage[pyx]\{color,graphicx\}}. Note that the
464 option~\texttt{pyx} is only available with unset \var{pyxgraphics} keyword
465 argument and a properly installed driver file. Otherwise, omit the
466 specification of a driver when loading the packages.
468 When you define colors in \LaTeX{} via one of the color models \texttt{gray},
469 \texttt{cmyk}, \texttt{rgb}, \texttt{RGB}, \texttt{hsb}, then \PyX{} will use
470 the corresponding values (one to four real numbers). In case you use any of the
471 \texttt{named} colors in \LaTeX{}, \PyX{} will use the corresponding predefined
472 color (see module \texttt{color} and the color table at the end of the manual).
473 The additional \LaTeX{} color model \texttt{pyx} allows to use a PyX color
474 expression, such as \texttt{color.cmyk(0,0,0,0)} directly in LaTeX. It is
475 passed to PyX.
477 When importing Encapsulated PostScript files (\texttt{eps} files) \PyX{} will
478 rotate, scale and clip your file like you expect it. Other graphic formats can
479 not be imported via the graphics package at the moment.
481 For reference purpose, the following specials can be handled by \PyX{} at the
482 moment:
484 \begin{description}
485 \item[\texttt{PyX:color\_begin (model) (spec)}]
486 starts a color. \texttt{(model)}~is one of
487 \texttt{gray}, \texttt{cmyk}, \texttt{rgb}, \texttt{hsb}, \texttt{texnamed}, or
488 \texttt{pyxcolor}. \texttt{(spec)}~depends on the model: a name or
489 some numbers
490 \item[\texttt{PyX:color\_end}]
491 ends a color.
492 \item[\texttt{PyX:epsinclude file= llx= lly= urx= ury= width= height= clip=0/1}]
493 includes an Encapsulated PostScript file (\texttt{eps}
494 files). The values of \texttt{llx} to \texttt{ury} are in the files'
495 coordinate system and specify the part of the graphics that should
496 become the specified \texttt{width} and \texttt{height} in the
497 outcome. The graphics may be clipped. The last three parameters are
498 optional.
499 \item[\texttt{PyX:scale\_begin (x) (y)}]
500 begins scaling from the current point.
501 \item[\texttt{PyX:scale\_end}]
502 ends scaling.
503 \item[\texttt{PyX:rotate\_begin (angle)}]
504 begins rotation around the current point.
505 \item[\texttt{PyX:rotate\_end}]
506 ends rotation.
507 \end{description}
509 \section[TeX message parsers]%
510 {\TeX{} message parsers}
511 \declaremodule{}{text}
512 \modulesynopsis{\TeX/\LaTeX interface}
514 Message parsers are used to scan the output of \TeX/\LaTeX. The output
515 is analysed by a sequence of \TeX{} message parsers. Each message
516 parser analyses the output and removes those parts of the output, it
517 feels responsible for. If there is nothing left in the end, the
518 message got validated, otherwise an exception is raised reporting the
519 problem. A message parser might issue a warning when removing some
520 output to give some feedback to the user.
522 \begin{classdesc}{texmessage}{}
523 This class acts as a container for \TeX{} message parsers instances,
524 which are all instances of classes derived from \class{texmessage}.
525 \end{classdesc}
527 The following \TeX{} message parser instances are available:
529 \begin{memberdesc}{start}
530 Check for \TeX/\LaTeX{} startup message including scrollmode test.
531 \end{memberdesc}
532 \begin{memberdesc}{noaux}
533 Ignore \LaTeX{}s no-aux-file warning.
534 \end{memberdesc}
535 \begin{memberdesc}{end}
536 Check for proper \TeX/\LaTeX{} tear down message.
537 \end{memberdesc}
538 \begin{memberdesc}{load}
539 Accepts arbitrary loading of files without checking for details,
540 \emph{i.e.} accept \texttt{(\emph{file} ...)} where
541 \texttt{\emph{file}} is an readable file.
542 \end{memberdesc}
543 \begin{memberdesc}{loaddef}
544 Accepts arbitrary loading of \texttt{fd} files, \emph{i.e.} accept
545 \texttt{(\emph{file}.def)} and \texttt{(\emph{file}.fd)} where
546 \texttt{\emph{file}.def} or \texttt{\emph{file}.fd} is an readable
547 file, respectively.
548 \end{memberdesc}
549 \begin{memberdesc}{graphicsload}
550 Accepts arbitrary loading of \texttt{eps} files,
551 \emph{i.e.} accept \texttt{(\emph{file}.eps)} where
552 \texttt{\emph{file}.eps} is an readable file.
553 \end{memberdesc}
554 \begin{memberdesc}{ignore}
555 Ignores everything (this is probably a bad idea, but sometimes you
556 might just want to ignore everything).
557 \end{memberdesc}
558 \begin{memberdesc}{allwarning}
559 Ignores everything but issues a warning.
560 \end{memberdesc}
561 \begin{memberdesc}{fontwarning}
562 Issues a warning about font substitutions of the \LaTeX{}s NFSS.
563 \end{memberdesc}
564 \begin{memberdesc}{boxwarning}
565 Issues a warning on under- and overfull horizontal and vertical boxes.
566 \end{memberdesc}
568 \begin{classdesc}{texmessagepattern}{pattern, warning=None}
569 This is a derived class of \class{texmessage}. It can be used to
570 construct simple \TeX{} message parsers, which validate a \TeX{}
571 message matching a certain regular expression pattern \var{pattern}.
572 When \var{warning} is set, a warning message is issued. Several of
573 the \TeX{} message parsers described above are implemented using
574 this class.
575 \end{classdesc}
577 \section{The \member{defaulttexrunner} instance}
578 \declaremodule{}{text}
579 \modulesynopsis{\TeX/\LaTeX interface}
581 \begin{datadesc}{defaulttexrunner}
582 The \code{defaulttexrunner} is an instance of \class{texrunner}. It
583 is created when the \module{text} module is loaded and it is used as
584 the default texrunner instance by all \class{canvas} instances to
585 implement its \method{text()} method.
586 \end{datadesc}
588 \begin{funcdesc}{preamble}{...}
589 \code{defaulttexrunner.preamble}
590 \end{funcdesc}
592 \begin{funcdesc}{text}{...}
593 \code{defaulttexrunner.text}
594 \end{funcdesc}
596 \begin{funcdesc}{set}{...}
597 \code{defaulttexrunner.set}
598 \end{funcdesc}
600 \begin{funcdesc}{reset}{...}
601 \code{defaulttexrunner.reset}
602 \end{funcdesc}
604 \section{Some internals on temporary files etc.}
606 It is not totally obvious how \TeX{} processes are supervised by
607 \PyX{} and why it's done that way. However there are good reasons for
608 it and the following description is intended for people wanting and/or
609 needing to understand how temporary files are used by \PyX. All others
610 don't need to care.
612 Each time \PyX{} needs to start a new \TeX{} process, it creates a
613 base file name for temporary files associated with this process. This
614 file name is used as \verb|\jobname| by \TeX. Since \TeX{} does not
615 handle directory names as part of \verb|\jobname|, the temporary files
616 will be created in the current directory. The \PyX{} developers
617 decided to not change the current directory at all, avoiding all kind
618 of issues with accessing files in the local directory, like for
619 loading graph data, \LaTeX{} style files etc.
621 \PyX{} creates a \TeX{} file containing \verb|\relax| only. It's only
622 use is to set \TeX{}s \verb|\jobname|. Immediately after processing
623 \verb|\relax| \TeX{} falls back to stdin to read more commands. \PyX{}
624 than uses \code{stdin} and \code{stdout} to avoid various buffering
625 issues which would occur when using files (or named pipes). By that
626 \PyX{} can fetch \TeX{} errors as soon as they occur while keeping the
627 \TeX{} process running (i.e. in a waiting state) for further input.
628 The size of the \TeX{} output is also availble immediately without
629 fetching the \code{dvi} file created by \TeX, since \PyX{} uses some
630 \TeX{} macros to output the extents of the boxes created for the
631 requested texts to \code{stdout} immediately. There is a TeX hack
632 \verb|--ipc| which \PyX{} knows to take advantage of to fetch
633 informations from the \code{dvi} file immediately as well, but it's
634 not available on all \TeX installations. Thus this feature is disabled
635 by default and fetching informations from the \code{dvi} is tried to
636 be limited to those cases, where no other option exists. By that
637 \TeX{} usually doesn't need to be started several times.
639 By default \PyX{} will clean up all temporary files after \TeX{} was
640 stopped. However the \code{usefiles} list allows for a renaming of the
641 files from (and to, if existing) the temporary \verb|\jobname| (+
642 suffix) handled by \PyX{}. Additionally, since \PyX{} does not write a
643 useful \TeX{} input file in a file and thus a
644 \code{usefiles=["example.tex"]} would not contain the code actually
645 passed to \TeX{}, the \code{texdebug} feature of the texrunner can be
646 used instead to get a the full input passed to \TeX{}.
648 In case you need to control the position where the temporary files are
649 created (say, you're working on a read-only directory), the suggested
650 solution is to switch the current directory before starting with text
651 processing in \PyX{} (i.e. an \code{os.chdir} at the beginning of your
652 script will do fine). You than just need to take care of specifying
653 full paths when accessing data from your original working directory,
654 but that's intended and necessary for that case.