prepared for release 0.5
[PyX/mjg.git] / faq / pyxfaq.tex
blobf511722c708dbedc4debe0dde09c8447ad5ce767
1 \documentclass[11pt,DIV14]{scrartcl}
2 \usepackage[latin1]{inputenc}
3 \usepackage{url}
4 \usepackage{mathptmx}
5 %\usepackage[all,comments]{glifaq}
6 \usepackage[answered]{glifaq}
7 \usepackage[pdftex]{hyperref}
8 \hypersetup{pdftitle={PyX FAQ}%
9 ,pdfauthor={\textcopyright\ Gert-Ludwig Ingold
10 <gert.ingold@physik.uni-augsburg.de>}%
11 ,colorlinks=true%
12 ,linkcolor=blue}
13 \begin{document}
14 \begin{center}
15 \LARGE\sffamily Some frequently and\\
16 not so frequently asked questions\\
17 about \PyX\footnote{This version of the FAQ is intended for use with \PyX\
18 version 0.5.}\\
19 \par
20 {\small\sffamily (\today)}\\[1truecm]
21 \large
22 Gert-Ludwig Ingold \par
23 \href{mailto:gert.ingold@physik.uni-augsburg.de}{\url{<gert.ingold@physik.uni-augsburg.de>}}
24 \end{center}
25 \toc
27 \vspace{2truecm}
28 \section*{Acknowledgements}
29 The following persons have in one way or the other contributed to the answers
30 given in this FAQ:\\
31 Jörg Lehmann, Michael Schindler, Andr{\'e} Wobst.
32 \newpage
34 \section{General aspects of \PyX}
35 \question{a}{Where do I get the latest version of \PyX?}
37 {The current release of \PyX{} (as well as older ones) is freely available
38 from \url{http://pyx.sourceforge.net} where also a CVS repository with the
39 latest patches can be found. Possibly older versions of \PyX{} are
40 also available as package for
41 various Linux distributions: see, for instance,
42 \url{http://packages.debian.org/testing/python/python-pyx.html} for
43 information on the \PyX{} package in Debian GNU/Linux,
44 \url{http://packages.gentoo.org/ebuilds/?pyx-0.3.1} for a Gentoo Linux
45 ebuild, and
46 \url{http://www.suse.de/en/private/products/suse_linux/i386/packages_professional/python-pyx.html}
47 for the \PyX{} package in the SUSE LINUX professional distribution.
50 \question{c}{How can I determine the version of \PyX{} running on my
51 machine?}
53 {Start a python session (usually by typing \texttt{python} at the system
54 prompt) and then type the following two commands (\texttt{>>>} is the python
55 prompt)
56 \begin{progcode}
57 >>> import pyx\\
58 >>> pyx.\us\us{}version\us\us
59 \end{progcode}
62 \question{c}{Does \PyX{} run under my favorite operating system?}
64 {Yes, if you have installed Python (\uaref{q:what_is_python})
65 and \TeX{} (\uaref{q:what_is_tex}). Both are available for
66 a large variety of operating systems so chances are pretty good that you will
67 get \PyX{} to work on your system.
70 \question{c}{Under which versions of Python will \PyX{} run?}
72 {\PyX{} is supposed to work with Python 2.0 and above. However, most of the
73 development takes place under the current production version of Python (2.3.3
74 by the time of this writing) and thus \PyX{} is better tested with this version. On the other hand, the examples and tests are verified to run with all Python
75 versions 2.x. \PyX{} will not work with Python 1.x due to missing language
76 features.
78 The version of your Python interpreter can be determined by calling
79 it with the option \texttt{-V}. Alternatively, you can simply start the
80 interpreter and take a look at the startup message. Note that there may be
81 different versions of Python installed on your system at the same time. The
82 default Python version need not be the same for all users.
85 \question{a}{Where can I get help if my question is not answered in this FAQ?}
87 {The \PyX{} sources contain a reference manual and a set of examples
88 demonstrating various features of \PyX. If the feature you are looking for is
89 among them, using the appropriate part of the example code or adapting it for
90 your purposes may help.
92 There is also a user discussion list about \PyX{} which you can subscribe to
93 at \url{http://lists.sourceforge.net/lists/listinfo/pyx-user}. The archive of
94 the discussion list is available at \url{http://sourceforge.net/mailarchive/forum.php?forum_id=23700}.
96 Finally, it might be worth checking \url{http://pyx.sourceforge.net/pyxfaq.pdf}
97 for an updated version of this FAQ.
100 \section{Python}
102 \question{c}{What is Python?}
104 {\label{q:what_is_python}
105 From \url{www.python.org}:
106 \begin{quote}
107 Python is an \textit{interpreted, interactive, object-oriented} programming
108 language. It is often compared to Tcl, Perl, Scheme or Java.
110 Python combines remarkable power with very clear syntax. It has modules,
111 classes, exceptions, very high level dynamic data types, and dynamic typing.
112 There are interfaces to many system calls and libraries, as well as to various
113 windowing systems (X11, Motif, Tk, Mac, MFC). New built-in modules are easily
114 written in C or C++. Python is also usable as an extension language for
115 applications that need a programmable interface.
117 The Python implementation is portable: it runs on many brands of UNIX, on
118 Windows, OS/2, Mac, Amiga, and many other platforms. If your favorite system
119 isn't listed here, it may still be supported, if there's a C compiler for it.
120 Ask around on \href{news:comp.lang.python}{news:comp.lang.python} --- or just
121 try compiling Python yourself.
123 The Python implementation is
124 \href{http://www.python.org/doc/Copyright.html}{copyrighted}
125 but \textbf{freely usable and distributable, even for commercial use}.
126 \end{quote}
129 \question{a}{Where can I learn more about Python?}
131 {The place to start is \url{www.python.org} where you will find plenty of
132 information on Python including tutorials.
135 \question{c}{What do I need to import in order to use \PyX?}
137 {It is recommended to begin your Python code with
138 \begin{progcode}
139 from pyx import *
140 \end{progcode}
141 when using \PyX. This allows you for example to write simply
142 \texttt{graph.graphxy}
143 instead of \texttt{pyx.graph.graphxy}. The following modules will be loaded:
144 \texttt{box}, \texttt{canvas}, \texttt{color}, \texttt{connector}, \texttt{data},
145 \texttt{deco}, \texttt{epsfile}, \texttt{graph}, \texttt{path},
146 \texttt{style}, \texttt{trafo}, \texttt{tex}, \texttt{text}, and
147 \texttt{unit}.
149 For convenience, you might import specific objects of a module like in
150 \begin{progcode}
151 from graph import graphxy
152 \end{progcode}
153 which allows you to write \texttt{graphxy()} instead of \texttt{graph.graphxy()}.
155 All code segments in this document assume that the import line mentioned in
156 the first code snippet is present.
159 \question{a}{What is a raw string and why should I know about it when
160 using \PyX?}
162 {\label{q:raw_string}
163 The backslash serves in standard Python strings to start an escape sequence.
164 For example {\cs n} corresponds to a newline character. On the other hand,
165 \TeX{} and \LaTeX{}, which do the typesetting in \PyX, use the backslash to
166 indicate the start of a command. In order to avoid the standard interpretation,
167 the string should be marked as a raw string by prepending it by an \texttt{r}
168 like in
169 \begin{progcode}
170 c.text(0, 0, r"\${\cs alpha}{\cs beta}{\cs gamma}\$")
171 \end{progcode}
174 \section{Plotting of graphs}
176 \subsection{General aspects}
178 \question{c}{How do I generate a graph from data as simply as possible?}
180 {\label{q:mingraphdata}
181 Suppose that you have a data file \texttt{x.dat} containing values for
182 $x$ and $y$ in two columns. Then the following code will do the job
183 \begin{progcode}
184 from pyx import *\\
186 g = graph.graphxy(width=10)\\
187 g.plot(graph.data("x.dat", x=1, y=2))\\
188 g.writetofile("x")
189 \end{progcode}
190 \texttt{graphxy} creates a canvas (called \texttt{g} in this example) onto
191 which the graph will be drawn and it sets the default behavior including the
192 axis. There is, however, no default value for the width of the graph. In
193 \texttt{plot} you have to specify the name of the data file and the columns
194 from which the data should be taken. Finally, \texttt{writetofile} will
195 generate the postscript file \texttt{x.eps} which you can view or print.
197 A minimal example is also provided in the \PyX{} distribution as
198 \path{examples/graphs/minimal.py}.
201 \question{a}{How do I generate a graph of a function as simply as possible?}
203 {The following example will draw a parabola:
204 \begin{progcode}
205 from pyx import *\\
207 g = graph.graphxy(width=10,\\
208 ~~~~~~~~~~~~~~~~~~x=graph.linaxis(min=-2, max=2)\\
209 ~~~~~~~~~~~~~~~~~~)\\
211 g.plot(graph.function("y=x**2"))\\
213 g.writetofile("x")
214 \end{progcode}
215 Most of the code has been explained in \uaref{q:mingraphdata}. The main
216 difference is that here you need to specify minimum and maximum for the
217 $x$-axis so that \PyX{} knows in which range to evaluate the function.
219 See \uaref{q:zeropathattrs} for an explanation of how one can suppress the
220 zero lines.
222 Another, slightly more complex, example is also provided in the \PyX{}
223 distribution as \path{examples/graphs/piaxis.py}.
226 \question{a}{How can I stack graphs?}
228 {\PyX{} always needs a canvas to draw on. One possibility therefore consists
229 in creating a new canvas with
230 \begin{progcode}
231 c = canvas.canvas()
232 \end{progcode}
233 and inserting the graphs into this canvas with \texttt{c.insert(...)}. Here,
234 \texttt{...} has to be replaced by the name of the graph. Alternatively, the
235 canvas created with \texttt{graph.graphxy} for one of the graphs can be used
236 to insert the other graphs even if they will be positioned outside the
237 first graph.
239 The second issue to address is positioning of the graphs. By specifying
240 \texttt{xpos} and \texttt{ypos} when calling \texttt{graphxy}, you can
241 define the position of a graph. Later on, the position and size of a
242 graph \texttt{g} can be referred to as \texttt{g.xpos}, \texttt{g.ypos},
243 \texttt{g.width}, and \texttt{g.height} even if for example the height has
244 never been specified explicitly but is only defined by a \PyX{} default.
246 The following example shows how to put graph \texttt{gupper} above graph
247 \texttt{glower} on a canvas \texttt{c}:
248 \begin{progcode}
249 from pyx import *\\
250 from graph import graphxy\\
252 c = canvas.canvas()\\
254 glower = graphxy(width=10)\\
255 glower.plot(...)\\
256 c.insert(glower)\\
258 gupper = graphxy(width=10, ypos=glower.ypos+glower.height+2)\\
259 gupper.plot(...)\\
261 c.insert(gupper)\\
262 c.writetofile(...)
263 \end{progcode}
264 where \texttt{...} has to be replaced by the appropriate information like
265 data and symbol specifications and the name of the output file. Here,
266 \texttt{c.insert} is used to actually insert the subcanvasses
267 for the graphs into the main canvas \texttt{c} and \texttt{c.writetofile}
268 in the last line requests to write the contents of this canvas to a file.
270 %In order to suppress the labels of the $x$-axis of the upper graph, use
271 %\begin{progcode}
272 %myaxispainter = graph.axispainter(labelattrs=None)
274 %gupper = graph.graphxy(...,
275 % x=graph.linaxis(...,
276 % part=graph.linpart(),
277 % painter=myaxispainter)
279 %\end{progcode}
282 \question{t}{How can I plot grid data?}
286 \question{t}{I would like a key for only some of my data sets. How do I do
287 that?}
292 \subsection{Axis properties}
294 \question{a}{How do I specify the tick increment?}
296 {In the partition of a linear axis, the increments associated with ticks,
297 subticks etc.\ can be specified as argument of \texttt{linpart}. In the
298 following example, ticks will be drawn at even values while subticks will
299 be drawn at all integers:
300 \begin{progcode}
301 tg = graph.graphxy(width=10,\\
302 ~~~~~~~~~~~~~~~~~~~x=graph.linaxis(min=1, max=10,\\
303 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~part=graph.linpart(tickdist=[2,1]))\\
304 ~~~~~~~~~~~~~~~~~~~)
305 \end{progcode}
308 \question{a}{How do I get rid of the zero line?}
310 {\label{q:zeropathattrs}
311 The \texttt{axispainter} takes an argument \texttt{zeropathattrs} which
312 defaults to an empty list. Setting the \texttt{axispainter} for the
313 appropriate axis to \texttt{None} will remove the zero line like in this
314 example:
315 \begin{progcode}
316 myaxispainter = graph.axispainter(zeropathattrs=None)\\
318 g = graph.graphxy(width=10,\\
319 ~~~~~~~~~~~~~~~~~~x=graph.linaxis(min=-5, max=5, painter=myaxispainter),\\
320 ~~~~~~~~~~~~~~~~~~y=graph.linaxis(min=-5, max=5)\\
321 ~~~~~~~~~~~~~~~~~~)
322 \end{progcode}
323 This will keep the horizontal zero line but discard the vertical one.
326 \subsection{Data properties}
328 \question{a}{How do I choose the symbol?}
330 {\label{q:choose_symbol}
331 Suppose a graph called \texttt{g} has been initialized, e.g. by using
332 \texttt{graph.graphxy}. Then, data and the style of their representation
333 in the graph are defined by calling \texttt{g.plot} like in the following
334 example in which filled circles are requested:
335 \begin{progcode}
336 g.plot(graph.data("test.dat"),\\
337 ~~~~~~~graph.symbol(graph.symbol.circle, symbolattrs=[deco.filled]\\
338 ~~~~~~~)
339 \end{progcode}
342 \question{a}{How do I choose the color of the symbols?}
344 {Colors are not properties of the symbol as such and can therefore not
345 be specified in \texttt{symbolattrs} directly. The color is rather related
346 to the plotting of the symbol as defined by \texttt{deco.stroked} or
347 \texttt{deco.filled}. With
348 \begin{progcode}
349 graph.symbol(graph.symbol.circle,\\
350 ~~~~~~~~~~~~~symbolattrs=[deco.stroked([color.rgb.red]),\\
351 ~~~~~~~~~~~~~~~~~~~~~~~~~~deco.filled([color.rgb.green])]\\
352 ~~~~~~~~~~~~~)
353 \end{progcode}
354 you will obtain a circle filled in green with a red borderline.
357 \question{a}{How do I choose the line style?}
359 {If you do not want to use symbols, you can set the line style as in this
360 example
361 \begin{progcode}
362 g.plot(graph.data("test.dat"),\\
363 ~~~~~~~graph.line(lineattrs=[style.linewidth.Thin])\\
364 ~~~~~~~)
365 \end{progcode}
366 where the linewidth is set.
368 If you also want to use symbols, you can set the line attributes together
369 with the symbols. Extending the example in \ref{q:choose_symbol}),
370 you could use
371 \begin{progcode}
372 g.plot(graph.data("test.dat"),\\
373 ~~~~~~~graph.symbol(graph.symbol.circle, \\
374 ~~~~~~~~~~~~~~~~~~~~symbolattrs=[deco.filled],\\
375 ~~~~~~~~~~~~~~~~~~~~lineattrs=[style.linewidth.Thin, style.linestyle.dashed]\\
376 ~~~~~~~~~~~~~~~~~~~~)\\
377 ~~~~~~~)
378 \end{progcode}
379 to set the linewidth and to choose dashed lines.
382 \section{\TeX{} and \LaTeX{}}
384 \subsection{General aspects}
386 \question{a}{What is \TeX/\LaTeX{} and why do I need it?}
388 {\label{q:what_is_tex}
389 \TeX{} is a high quality typesetting system developed by Donald E. Knuth
390 which is available for a wide variety of operating systems. \LaTeX{} is a
391 macro package originally developed by Leslie Lamport which makes life with
392 \TeX{} easier, in particular for complex typesetting tasks. The current
393 version of \LaTeX{} is referred to as \LaTeXe{} and offers e.g.\ improved
394 font selection as compared to the older \LaTeX{} 2.09 which should no longer
395 be used.
397 All typesetting tasks in \PyX{} are finally handed over to \TeX{} (which is the
398 default) or \LaTeX{}, so that \PyX{} cannot do without it. On the other hand,
399 the capabilities of \TeX{} and \LaTeX{} can be used for complex tasks where
400 both graphics and typesetting are needed.
403 \question{a}{I don't know anything about \TeX{} and \LaTeX{}. Where can I read
404 something about it?}
406 {\label{q:intro_tex_latex}
407 Take a look at CTAN (\uaref{q:ctan}) where in \ctan{info}
408 you may be able to find some useful information. There exists for example
409 ``A Gentle Introduction to \TeX'' by M.~Doob (\ctan{gentle/gentle.pdf}) and
410 ``The Not So Short Introduction to \LaTeXe''
411 (\ctan{info/lshort/english/lshort.pdf}) by T.~Oetiker et al. The latter has
412 been translated into a variety of languages among them korean (which you will
413 not be able to read unless you have appropriate fonts installed) and mongolian.
415 Of course, it is likely that these documents will go way beyond what you
416 will need for generating graphics with \PyX{} so you don't have to read all
417 of it (unless you want to use \TeX{} or \LaTeX{} for typesetting which can be
418 highly recommended).
420 There exists also a number of FAQs on \TeX{} at \ctan{help}.
423 \question{a}{What is CTAN?}
425 {\label{q:ctan}
426 CTAN is the Comprehensive TeX Archive Network where you will find almost
427 everything related to \TeX{} and friends. The main CTAN servers are
428 \url{tug.ctan.org}, \url{dante.ctan.org}, and \url{cam.ctan.org}. A list of
429 FTP mirrors can be found at \ctan{CTAN.sites}.
431 In this FAQ, \texttt{CTAN:} refers to the root of an anonymous ftp CTAN tree,
432 e.g. \url{ftp://ctan.tug.org/tex-archive/},
433 \url{ftp://ftp.dante.de/tex-archive/},
434 and \url{ftp://ftp.tex.ac.uk/tex-archive/}. The links to CTAN in this document
435 point to one of these servers but you might consider using a FTP mirror closer
436 to you in order to reduce traffic load.
439 \question{a}{Is there support for Con\TeX{}t?}
441 {No, and as far as I know there no plans to provide it in the near future.
442 Given the close ties between Con\TeX{}t and Meta\-Post, Con\TeX{}t users
443 probably prefer to stick with the latter anyway.
446 \subsection{\TeX{} and \LaTeX{} commands useful for \PyX}
448 \question{a}{How do I get a specific symbol with \TeX{} or \LaTeX?}
450 {A list of mathematical symbols together with the appropriate command name
451 can be found at \ctan{info/symbols/math/symbols.ps}. A comprehensive list
452 containing more than 2500 symbols for use with \LaTeX{} can be obtained from
453 \ctan{info/symbols/comprehensive/symbols-a4.pdf}. In some cases it might be
454 necessary to install fonts or packages available from CTAN
455 (\uaref{q:ctan}).
458 \subsection{\TeX{} and \LaTeX{} errors}
460 \question{a}{Undefined control sequence \cs{usepackage}}
462 {\label{q:undefined_usepackage}
463 The command \cs usepackage is specific to \LaTeX{}. Since by default \PyX{}
464 uses \TeX{}, you have to specify the correct mode:
465 \begin{progcode}
466 text.set(mode="latex")
467 \end{progcode}
470 \question{a}{Undefined control sequence \cs{frac}}
472 {\label{q:undefined_frac}
473 The command \cs frac is only available in \LaTeX{}. In \TeX{} you should
474 use \texttt{\cb{a\cs over b}} in math mode to produce ${a\over b}$. As an
475 alternative you may ask for the \LaTeX{} mode as explained in
476 \ref{q:undefined_usepackage}.
479 \question{a}{Missing \$ inserted}
481 {You have specified \TeX- or \LaTeX-code which is only valid in math mode.
482 Typical examples are greek symbols, sub- and superscripts or fractions.
484 On the \PyX{} level, you can specify math mode for the whole string by using
485 \texttt{text.mathmode} as in
486 \begin{progcode}
487 c.text(0, 0, r"{\cs alpha}", text.mathmode)
488 \end{progcode}
489 Keep also in mind that the standard Python interpretation of the backslash as
490 introducing escape sequences needs to be prevented
491 \uaref{q:raw_string}.
493 On the \TeX/\LaTeX{} level you should enclose the commands requiring math
494 mode in \$'s. As an example, \texttt{\$\cs alpha\us i\hat j\$} will produce
495 $\alpha_i^j$. This allows you to specify math mode also for substrings. There
496 exist other ways to specify math mode in \TeX{} and \LaTeX{} which are
497 particularly useful for more complex typesetting tasks. To learn more about
498 it, you should consult the documentation
499 \uaref{q:intro_tex_latex}.
502 \question{a}{Font shape `OT1/xyz/m/n' undefined}
504 {\label{q:fontshape_undefined}
505 You have asked to use font \texttt{xyz} which is not available. Make sure that
506 you have this font available in Type1 format, i.e.\ there should be a
507 file \texttt{xyz.pfb} somewhere. If your \TeX{} system is TDS compliant
508 (TDS=\TeX{} directory structure, cf.\ \ctan{tds/draft-standard/tds/tds.pdf})
509 you should take a look at the subdirectories of
510 \path{TEXMF/fonts/type1}.
513 \question{a}{File \dots\ is not available or not readable}
515 {\label{q:no_lfs}
516 Such an error message might already occur when running the example file
517 \texttt{hello.py} included in the \PyX{} distribution. Usually, the error
518 occurs due to an overly restrictive umask setting applied when unpacking the
519 \texttt{tar.gz} sources. This may render the file mentioned in the error
520 message unreadable because the python distutil installation package doesn't
521 change the file permissions back to readable for everyone.
523 If the file exists, the problem can be solved by changing the permissions to
524 allow read access.}
526 \question{a}{No information for font `cmr10' found in font mapping file}
528 {\label{q:no_cmr10}
529 Such an error message can already be encountered by simply running the example
530 file \texttt{hello.py} included in the \PyX{} distribution. The likely reason
531 is that the \TeX{} system does not find the cmr fonts in Type1 format.
532 \PyX{} depends on these fonts as it does not work with the traditional
533 pk fonts which are stored as bitmaps.
535 Therefore, the first thing to make sure is that the cmr Type1 fonts are
536 installed. In some \TeX{} installations, the command \texttt{kpsewhich
537 cmr10.pfb} will return the appropriate path if the cmr fonts exist in the
538 binary Type1 format (extension \texttt{pfb}) required by \PyX. If the command
539 does not work but the TeX{} system is TDS compliant
540 (\uaref{q:fontshape_undefined}), a look should be taken at
541 \path{TEXMF/fonts/type1/bluesky/cm} where \texttt{TEXMF} is the root of the
542 \texttt{texmf} tree.
544 If the Type1 fonts do not exist on the system, they may be obtained from
545 the CTAN \uaref{q:ctan} at \ctan{fonts/cm/ps-type1/bluesky}. See the
546 \texttt{README} for information about who produced these fonts and why they
547 are freely available.
549 If the Type1 fonts exist, the next step is to take a look at
550 \texttt{psfonts.map}. There may be several files with this name on the system,
551 so it is important to find out which one TeX is actually using.
552 \texttt{kpsewhich psfonts.map} might give this information.
554 The most likely problem is that this file does not contain a line telling TeX
555 what to do if it encounters a request for font \texttt{cmr10}, i.e. the
556 following line
557 may be missing
558 \begin{progcode}
559 ~~~cmr10~~~~~~~~~~~CMR10~~~~~~~~~~~<cmr10.pfb
560 \end{progcode}
561 It is probable that the required lines (in practice, you do not just need
562 \texttt{cmr10}) are found in a file named \texttt{psfonts.cmz} which resides in
563 \path{TEXMF/dvips/bluesky}.
565 One solution is to instruct \PyX{} to read additional map files like
566 \texttt{psfonts.cmz} or \texttt{psfonts.amz}. This can be achieved by modifying
567 the appropriate \texttt{pyxrc} file which is either the systemwide
568 \texttt{/etc/pyxrc} or \texttt{.pyxrc} in the user's home directory. Here, the
569 names of the map files to be read by \PyX{} should be appended separated by
570 whitespaces like in the following example:
571 \begin{progcode}
572 fontmaps = psfonts.map psfonts.cmz psfonts.amz
573 \end{progcode}
575 Alternatively, the contents of \texttt{psfonts.cmz} can be inserted into
576 \texttt{psfonts.map}. Probably, \texttt{psfonts.map} recommends not to do this
577 by hand. In this case the instructions given in the file should be followed.
578 Otherwise, \texttt{psfonts.cmz} should be copied into \texttt{psfonts.map} while
579 keeping a backup of the old \texttt{psfonts.map} just in case. After these
580 changes, \PyX{} most likely will be happy. When inserting \texttt{psfonts.cmz}
581 into \texttt{psfonts.map} it may be a good idea to include \texttt{psfonts.amz}
582 as well. \texttt{psfonts.amz} contains information about some more fonts which
583 might be needed at some point. Making these changes ot \texttt{psfonts.map}
584 will imply that the \TeX{} system will use the cmr fonts in Type1 format
585 instead of pk format which is actually not a bad thing, in particular if
586 \texttt{latex}~/ \texttt{dvips}~/ \texttt{ps2pdf} is used to generate PDF
587 output. With fonts in pk format this will look ugly and using Type1 fonts
588 solves this problem as well. When \texttt{pdflatex} is used to create PDF files,
589 Type1 fonts will be used anyway.
592 \subsection{Fonts}
594 \question{t}{I have Type1 fonts in \texttt{pfa} format. How do I obtain the
595 corresponding \texttt{pfb} files needed by \PyX?}
600 \question{a}{I want to use a font other than computer modern roman}
602 {\label{q:other_font}
603 As long as you have a font in Type1 format available, this should be no
604 problem (even though it may cost you some time to set up things properly).
606 In the simplest case, your \LaTeX{} system contains everything needed.
607 Including the following line into your code will probably work
608 \begin{progcode}
609 text.set(mode="latex")\\
610 text.preamble(r"\cs{usepackage}\cb{mathptmx}")
611 \end{progcode}
612 and give you Times as roman font.
614 If you own one of the more common commercial fonts, take a look at
615 \ctan{fonts} and its subdirectories as well as at the web page
616 \url{http://home.vr-web.de/was/fonts.html} of Walter Schmidt. It is not
617 unlikely that somebody has already done most of the work for you and created
618 the files needed for the font to work properly with \LaTeX. But remember:
619 we are talking about commercial fonts here, so do not expect to find the fonts
620 themselves for free.
622 If none of these cases applies, you should spend some time reading
623 manuals about font installation, e.g.\ \ctan{macros/latex/doc/fntguide.pdf}
624 (of course, I do not expect font wizards to read the last few lines).
627 \question{a}{Can I use a TrueType font with \PyX?}
629 {Not directly as \PyX{} only knows how to handle Type1 fonts (although it is
630 possible to get \LaTeX{} to work with TrueType fonts). However, you may use
631 \texttt{ttf2pt1} (from \url{http://ttf2pt1.sourceforge.net}) to convert a
632 TrueType font into a Type1 font which you then install in your \TeX{} system
633 \uaref{q:other_font}. You will loose hinting information
634 in the conversion process but this should not really matter on output devices
635 with not too low resolution.
638 \end{document}