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