disable debug option
[PyX/mjg.git] / faq / pyxfaq.tex
blobb79cf0f408510a23299af40bd67f4d63ff59980b
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\\
18 \par
19 {\small\sffamily (\today)}\\[1truecm]
20 \large
21 Gert-Ludwig Ingold \par
22 \href{mailto:gert.ingold@physik.uni-augsburg.de}{\url{<gert.ingold@physik.uni-augsburg.de>}}
23 \end{center}
24 \toc
25 \newpage
27 \section{General aspects of \PyX}
28 \question{a}{Where do I get the latest version of \PyX?}
30 {The current release of \PyX{} (as well as older ones) is freely available
31 from \url{http://pyx.sourceforge.net} where also a CVS repository with the
32 latest patches can be found.
35 \question{a}{How can I determine the version of \PyX{} running on my
36 machine?}
38 {Start a python session (usually by typing \texttt{python} at the system
39 prompt) and then type the following two commands (\texttt{>>>} is the python
40 prompt)
41 \begin{progcode}
42 >>> import pyx\\
43 >>> pyx.\us\us{}version\us\us
44 \end{progcode}
47 \question{a}{Does \PyX{} run under my favorite operating system?}
49 {Yes, if you have installed Python (\uaref{q:what_is_python})
50 and \TeX{} (\uaref{q:what_is_tex}). Both are available for
51 a large variety of operating systems so chances are pretty good that you will
52 get \PyX{} to work on your system.
55 \question{a}{Under which versions of Python will \PyX{} run?}
57 {\PyX{} will definitely run under Python 2.2 and higher and it is supposed
58 to work under Python 2.1. Your are likely to encounter problems with Python 2.0
59 and with Python 1.x \PyX{} will not work. The version of your Python interpreter
60 can be determined by calling it with the option \texttt{-V}. Alternatively,
61 you can simply start the interpreter and take a look at the startup message.
62 Note that there may be different versions of Python installed on your system
63 at the same time.
66 \question{a}{Where can I get help if my question is not answered in this FAQ?}
68 {The \PyX{} sources contain a reference manual and a set of examples
69 demonstrating various features of \PyX. If the feature you are looking for is
70 among them, using the appropriate part of the example code or adapting it for
71 your purposes may help.
73 There is also a user discussion list about \PyX{} which you can subscribe to
74 at \url{http://lists.sourceforge.net/lists/listinfo/pyx-user}. The archive of
75 the discussion list is available at \url{http://sourceforge.net/mailarchive/forum.php?forum_id=23700}.
78 \section{Python}
80 \question{a}{What is Python?}
82 {\label{q:what_is_python}
83 From \url{www.python.org}:
84 \begin{quote}
85 Python is an \textit{interpreted, interactive, object-oriented} programming
86 language. It is often compared to Tcl, Perl, Scheme or Java.
88 Python combines remarkable power with very clear syntax. It has modules,
89 classes, exceptions, very high level dynamic data types, and dynamic typing.
90 There are interfaces to many system calls and libraries, as well as to various
91 windowing systems (X11, Motif, Tk, Mac, MFC). New built-in modules are easily
92 written in C or C++. Python is also usable as an extension language for
93 applications that need a programmable interface.
95 The Python implementation is portable: it runs on many brands of UNIX, on
96 Windows, OS/2, Mac, Amiga, and many other platforms. If your favorite system
97 isn't listed here, it may still be supported, if there's a C compiler for it.
98 Ask around on \href{news:comp.lang.python}{news:comp.lang.python} --- or just
99 try compiling Python yourself.
101 The Python implementation is
102 \href{http://www.python.org/doc/Copyright.html}{copyrighted}
103 but \textbf{freely usable and distributable, even for commercial use}.
104 \end{quote}
107 \question{a}{Where can I learn more about Python?}
109 {The place to start is \url{www.python.org} where you will find plenty of
110 information on Python including tutorials.
113 \question{a}{What do I need to import in order to use \PyX?}
115 {It is recommended to begin your Python code with
116 \begin{progcode}
117 from pyx import *
118 \end{progcode}
119 when using \PyX. This allows you for example to write simply
120 \texttt{graph.graphxy}
121 instead of \texttt{pyx.graph.graphxy}. The following modules will be loaded:
122 \texttt{box}, \texttt{connector}, \texttt{canvas}, \texttt{epsfile},
123 \texttt{color}, \texttt{text}, \texttt{tex}, \texttt{graph}, \texttt{path},
124 \texttt{data}, \texttt{unit}, and \texttt{trafo}.
126 For convenience, you might import specific objects of a module like in
127 \begin{progcode}
128 from graph import graphxy
129 \end{progcode}
130 which allows you to write \texttt{graphxy()} instead of \texttt{graph.graphxy()}.
132 All code segments in this document assume that the import line mentioned in
133 the first code snippet is present.
136 \question{a}{What is a raw string?}
138 {\label{q:raw_string}
140 The backslash serves in standard Python strings to start an escape sequence.
141 For example {\cs n} corresponds to a newline character. On the other hand,
142 \TeX{} and \LaTeX{}, which do the typesetting in \PyX, use the backslash to
143 indicate the start of a command. In order to avoid the standard interpretation,
144 the string should be marked as a raw string by prepending it by an \texttt{r}
145 like in
146 \begin{progcode}
147 c.text(0, 0, r"\${\cs alpha}{\cs beta}{\cs gamma}\$")
148 \end{progcode}
151 \section{Plotting of graphs}
153 \subsection{General aspects}
155 \question{a}{How do I generate a graph from data as simply as possible?}
157 {Suppose that you have a data file \texttt{x.dat} containing values for
158 $x$ and $y$ in two columns. Then the following code will do the job
159 \begin{progcode}
160 from pyx import *\\
162 g = graph.graphxy(width=10)\\
163 g.plot(graph.data("x.dat", x=1, y=2))\\
164 g.writetofile("x")
165 \end{progcode}
166 \texttt{graphxy} creates a canvas (called \texttt{g} in this example) onto
167 which the graph will be drawn and sets the default behavior including the
168 axis. There is, however, no default value for the width of the graph. In
169 \texttt{plot} you have to specify the name of the data file and the columns
170 from which the data should be taken. Finally, \texttt{writetofile} will
171 generate the postscript file \texttt{x.eps} which you can view or print.
174 \question{t}{How do I generate a graph of a function as simply as possible?}
178 \question{a}{How can I stack graphs?}
180 {\PyX{} always needs a canvas to draw on. One possibility therefore consists
181 in creating a new canvas with
182 \begin{progcode}
183 c = canvas.canvas()
184 \end{progcode}
185 and inserting the graphs into this canvas with \texttt{c.insert(...)}. Here,
186 \texttt{...} has to be replaced by the name of the graph. Alternatively, the
187 canvas created with \texttt{graph.graphxy} for one of the graphs can be used
188 to insert the other graphs even if they will be positioned outside the
189 first graph.
191 The second issue to address is positioning of the graphs. By specifying
192 \texttt{xpos} and \texttt{ypos} when calling \texttt{graphxy}, you can
193 define the position of a graph. Later on, the position and size of a
194 graph \texttt{g} can be referred to as \texttt{g.xpos}, \texttt{g.ypos},
195 \texttt{g.width}, and \texttt{g.height} even if for example the height has
196 never been specified explicitly but is only defined by a \PyX{} default.
198 The following example shows how to put graph \texttt{gupper} above graph
199 \texttt{glower} on a canvas \texttt{c}:
200 \begin{progcode}
201 from pyx import *\\
202 from graph import graphxy\\
204 c = canvas.canvas()\\
206 glower = graphxy(width=10)\\
207 glower.plot(...)\\
208 c.insert(glower)\\
210 gupper = graphxy(width=10, ypos=glower.ypos+glower.height+2)\\
211 gupper.plot(...)\\
213 c.insert(gupper)\\
214 c.writetofile(...)
215 \end{progcode}
216 where \texttt{...} has to be replaced by the appropriate information like
217 data and symbol specifications and the name of the output file. Here,
218 \texttt{c.insert} is used to actually insert the subcanvasses
219 for the graphs into the main canvas \texttt{c} and \texttt{c.writetofile}
220 in the last line requests to write the contents of this canvas to a file.
222 %In order to suppress the labels of the $x$-axis of the upper graph, use
223 %\begin{progcode}
224 %myaxispainter = graph.axispainter(labelattrs=None)
226 %gupper = graph.graphxy(...,
227 % x=graph.linaxis(...,
228 % part=graph.linpart(),
229 % painter=myaxispainter)
231 %\end{progcode}
234 \question{t}{How can I plot grid data?}
238 \question{t}{I would like a key for only some of my data sets. How do I do
239 that?}
244 \subsection{Axis properties}
246 \question{a}{How do I specify the tick increment?}
248 {In the partition of a linear axis, the increments associated with ticks,
249 subticks etc.\ can be specified as argument of \texttt{linpart}. In the
250 following example, ticks will be drawn at even values while subticks will
251 be drawn at all integers:
252 \begin{progcode}
253 tg = graph.graphxy(width=10,\\
254 ~~~~~~~~~~~~~~~~~~~x=graph.linaxis(min=1, max=10,\\
255 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~part=graph.linpart(tickdist=[2,1])),\\
256 ~~~~~~~~~~~~~~~~~~~)
257 \end{progcode}
260 \question{a}{Why are the axes extended beyond the data range?}
262 {Because the developers like it this way (God knows why). One way to avoid
263 this extension is to explicitly specify the minimum and maximum values for
264 the axis. The other possibility is to set \texttt{datavmin=0} and/or
265 \texttt{datavmax=1} in \texttt{linaxis} or \texttt{logaxis}.
267 Changes in the extension of axes are announced for version 0.5.
270 \question{a}{How do I get rid of the zero line?}
272 {The \texttt{axispainter} takes an argument \texttt{zerolineattrs} which
273 defaults to an empty list. Setting the \texttt{axispainter} for the
274 appropriate axis to \texttt{None} will remove the zero line like in this
275 example:
276 \begin{progcode}
277 myaxispainter = graph.axispainter(zerolineattrs=None)\\
279 g = graph.graphxy(width=10,\\
280 ~~~~~~~~~~~~~~~~~~x=graph.linaxis(min=-5, max=5, painter=myaxispainter),\\
281 ~~~~~~~~~~~~~~~~~~y=graph.linaxis(min=-5, max=5)\\
282 ~~~~~~~~~~~~~~~~~~)
283 \end{progcode}
284 This will keep the horizontal zero line but discard the vertical one.
287 \subsection{Data properties}
289 \question{a}{How do I choose the symbol?}
291 {\label{q:choose_symbol}
292 Suppose a graph called \texttt{g} has been initialized, e.g. using
293 \texttt{graph.graphxy}. Then, data and the style of their representation
294 in the graph are defined by calling \texttt{g.plot} like in the following
295 example in which filled circles are requested:
296 \begin{progcode}
297 g.plot(graph.data("test.dat"),\\
298 ~~~~~~~graph.symbol(graph.symbol.circle,symbolattrs=canvas.filled()\\
299 ~~~~~~~)
300 \end{progcode}
303 \question{a}{How do I choose the color of the symbols?}
305 {Colors are not properties of the symbol as such and can therefore not
306 be specified in \texttt{symbolattrs} directly. The color is rather related
307 to the plotting of the symbol as defined by \texttt{canvas.stroked} or
308 \texttt{canvas.filled}. With
309 \begin{progcode}
310 graph.symbol(graph.symbol.circle,\\
311 ~~~~~~~~~~~~~symbolattrs=[canvas.stroked(color.rgb.red),\\
312 ~~~~~~~~~~~~~~~~~~~~~~~~~~canvas.filled(color.rgb.green)]\\
313 ~~~~~~~~~~~~~)
314 \end{progcode}
315 you will obtain a circle filled in green with a red borderline.
318 \question{a}{How do I choose the line style?}
320 {If you do not want to use symbols, you can set the line style as in this
321 example
322 \begin{progcode}
323 g.plot(graph.data("test.dat"),\\
324 ~~~~~~~graph.line(lineattrs=canvas.linewidth.Thin)\\
325 ~~~~~~~)
326 \end{progcode}
327 where the linewidth is set.
329 If you also want to use symbols, you can set the line attributes together
330 with the symbols. Extending the example in \ref{q:choose_symbol}),
331 you could use
332 \begin{progcode}
333 g.plot(graph.data("test.dat"),\\
334 ~~~~~~~graph.symbol(graph.symbol.circle, \\
335 ~~~~~~~~~~~~~~~~~~~~symbolattrs=canvas.filled(),\\
336 ~~~~~~~~~~~~~~~~~~~~lineattrs=[canvas.linewidth.Thin,canvas.linestyle.dashed]\\
337 ~~~~~~~~~~~~~~~~~~~~)\\
338 ~~~~~~~)
339 \end{progcode}
340 to set the linewidth and to choose dashed lines.
343 \section{\TeX{} and \LaTeX{}}
345 \subsection{General aspects}
347 \question{a}{What is \TeX/\LaTeX{} and why do I need it?}
349 {\label{q:what_is_tex}
350 \TeX{} is a high quality typesetting system developed by Donald E. Knuth
351 which is available for a wide variety of operating systems. \LaTeX{} is a
352 macro package originally developed by Leslie Lamport which makes life with
353 \TeX{} easier, in particular for complex typesetting tasks. The current
354 version of \LaTeX{} is referred to as \LaTeXe{} and offers e.g.\ improved
355 font selection as compared to the older \LaTeX{} 2.09 which should no longer
356 be used.
358 All typesetting tasks in \PyX{} are finally handed over to \TeX{} (which is the
359 default) or \LaTeX{}, so that \PyX{} cannot do without it. On the other hand,
360 the capabilities of \TeX{} and \LaTeX{} can be used for complex tasks where
361 both graphics and typesetting are needed.
364 \question{a}{I don't know anything about \TeX{} and \LaTeX{}. Where can I read
365 something about it?}
367 {\label{q:intro_tex_latex}
368 Take a look at CTAN (\uaref{q:ctan}) where in \ctan{info}
369 you may be able to find some useful information. There exists for example
370 ``A Gentle Introduction to \TeX'' by M.~Doob (\ctan{gentle/gentle.pdf}) and
371 ``The Not So Short Introduction to \LaTeXe''
372 (\ctan{info/lshort/english/lshort.pdf}) by T.~Oetiker et al. The latter has
373 been translated into a variety of languages among them korean (which you will
374 not be able to read unless you have appropriate fonts installed) and mongolian.
376 Of course, it is likely that these documents will go way beyond what you
377 will need for generating graphics with \PyX{} so you don't have to read all
378 of it (unless you want to use \TeX{} or \LaTeX{} for typesetting which can be
379 highly recommended).
381 There exists also a number of FAQs on \TeX{} at \ctan{help}.
384 \question{a}{What is CTAN?}
386 {\label{q:ctan}
387 CTAN is the Comprehensive TeX Archive Network where you will find almost
388 everything related to \TeX{} and friends. The main CTAN servers are
389 \url{tug.ctan.org}, \url{dante.ctan.org}, and \url{cam.ctan.org}. A list of
390 FTP mirrors can be found at \ctan{CTAN.sites}.
392 In this FAQ, \texttt{CTAN:} refers to the root of an anonymous ftp CTAN tree,
393 e.g. \url{ftp://ctan.tug.org/tex-archive/},
394 \url{ftp://ftp.dante.de/tex-archive/},
395 and \url{ftp://ftp.tex.ac.uk/tex-archive/}. The links to CTAN in this document
396 point to one of these servers but you might consider using a FTP mirror closer
397 to you in order to reduce traffic load.
400 \question{a}{Is there support for Con\TeX{}t?}
402 {No, and as far as I know there no plans to provide it in the near future.
403 Given the close ties between Con\TeX{}t and Meta\-Post, Con\TeX{}t users
404 probably prefer to stick with the latter anyway.
407 \subsection{\TeX{} and \LaTeX{} commands useful for \PyX}
409 \question{a}{How do I get a specific symbol with \TeX{} or \LaTeX?}
411 {A list of mathematical symbols together with the appropriate command name
412 can be found at \ctan{info/symbols/math/symbols.ps}. A comprehensive list
413 containing more than 2500 symbols for use with \LaTeX{} can be obtained from
414 \ctan{info/symbols/comprehensive/symbols-a4.pdf}. In some cases it might be
415 necessary to install fonts or packages available from CTAN
416 (\uaref{q:ctan}).
419 \subsection{\TeX{} and \LaTeX{} errors}
421 \question{a}{Undefined control sequence \cs{usepackage}}
423 {\label{q:undefined_usepackage}
424 The command \cs usepackage is specific to \LaTeX{}. Since by default \PyX{}
425 uses \TeX{}, you have to specify the correct mode:
426 \begin{progcode}
427 text.set(mode="latex")
428 \end{progcode}
431 \question{a}{Undefined control sequence \cs{frac}}
433 {\label{q:undefined_frac}
434 The command \cs frac is only available in \LaTeX{}. In \TeX{} you should
435 use \texttt{\cb{a\cs over b}} in math mode to produce ${a\over b}$. As an
436 alternative you may ask for the \LaTeX{} mode as explained in
437 \ref{q:undefined_usepackage}.
440 \question{a}{Missing \$ inserted}
442 {You have specified \TeX- or \LaTeX-code which is only valid in math mode.
443 Typical examples are greek symbols, sub- and superscripts or fractions.
445 On the \PyX{} level, you can specify math mode for the whole string by using
446 \texttt{text.mathmode} as in
447 \begin{progcode}
448 c.text(0, 0, r"{\cs alpha}", text.mathmode)
449 \end{progcode}
450 Keep also in mind that the standard Python interpretation of the backslash as
451 introducing escape sequences needs to be prevented
452 \uaref{q:raw_string}.
454 On the \TeX/\LaTeX{} level you should enclose the commands requiring math
455 mode in \$'s. As an example, \texttt{\$\cs alpha\us i\hat j\$} will produce
456 $\alpha_i^j$. This allows you to specify math mode also for substrings. There
457 exist other ways to specify math mode in \TeX{} and \LaTeX{} which are
458 particularly useful for more complex typesetting tasks. To learn more about
459 it, you should consult the documentation
460 \uaref{q:intro_tex_latex}.
463 \question{a}{Font shape `OT1/xyz/m/n' undefined}
465 {\label{q:fontshape_undefined}
466 You have asked to use font \texttt{xyz} which is not available. Make sure that
467 you have this font available in Type1 format, i.e.\ there should be a
468 file \texttt{xyz.pfb} somewhere. If your \TeX{} system is TDS compliant
469 (TDS=\TeX{} directory structure, cf.\ \ctan{tds/draft-standard/tds/tds.pdf})
470 you should take a look at the subdirectories of
471 \path{TEXMF/fonts/type1}.
474 \question{a}{No information for font `cmr10' found in font mapping file}
476 {\label{q:no_cmr10}
477 Such an error message can already be encountered by simply running the example
478 file \texttt{hello.py} included in the \PyX{} distribution. The likely reason
479 is that the \TeX{} system does not find the cmr fonts in Type1 format.
480 \PyX{} depends on these fonts as it does not work with the traditional
481 pk fonts which are stored as bitmaps.
483 Therefore, the first thing to make sure is that the cmr Type1 fonts are
484 installed. In some \TeX{} installations, the command \texttt{kpsewhich
485 cmr10.pfb} will return the appropriate path if the cmr fonts exist in the
486 binary Type1 format (extension \texttt{pfb}) required by \PyX. If the command
487 does not work but the TeX{} system is TDS compliant
488 (\uaref{q:fontshape_undefined}), a look should be taken at
489 \path{TEXMF/fonts/type1/bluesky/cm} where \texttt{TEXMF} is the root of the
490 \texttt{texmf} tree.
492 If the Type1 fonts do not exist on the system, they may be obtained from
493 the CTAN \uaref{q:ctan} at \ctan{fonts/cm/ps-type1/bluesky}. See the
494 \texttt{README} for information about who produced these fonts and why they
495 are freely available.
497 If the Type1 fonts exist, the next step is to take a look at
498 \texttt{psfonts.map}. There may be several files with this name on the system,
499 so it is important to find out which one TeX is actually using.
500 \texttt{kpsewhich psfonts.map} might give this information.
502 The most likely problem is that this file does not contain a line telling TeX
503 what to do if it encounters a request for font cmr10, i.e. the following line
504 may be missing
505 \begin{progcode}
506 ~~~cmr10~~~~~~~~~~~CMR10~~~~~~~~~~~<cmr10.pfb
507 \end{progcode}
508 It is probable that the required lines (in practice, you do not just need
509 cmr10) are found in a file named \texttt{psfonts.cmz} which resides in
510 \path{TEXMF/dvips/bluesky}. The contents of \texttt{psfonts.cmz} should
511 be inserted into \texttt{psfonts.map}. Probably, \texttt{psfonts.map} recommends
512 not to do this by hand. In this case the instructions should be followed.
513 Otherwise, \texttt{psfonts.cmz} should be copied into \texttt{psfonts.map}
514 while keeping a backup of the old \texttt{psfonts.map} just in case. After
515 these changes \PyX{} most likely will be happy. When inserting
516 \texttt{psfonts.cmz} into \texttt{psfonts.map} it may be a good idea to
517 include \texttt{psfonts.amz} as well. \texttt{psfonts.amz} contains information
518 about some more fonts which might be needed at some point.
520 Making these changes will imply that the \TeX{} system will use the cmr fonts
521 in Type1 format instead of pk format which is actually not a bad thing, in
522 particular if \texttt{latex}~/ \texttt{dvips}~/ \texttt{ps2pdf} is used to
523 generate PDF output. With fonts in pk format this will look ugly and using
524 Type1 fonts solves this problem as well. When \texttt{pdflatex} is used to
525 create PDF files, Type1 fonts will be used anyway.
527 An alternative to changing the file \texttt{psfonts.map} in the \TeX{} system
528 consists in instructing \PyX{} to read other map files like
529 \texttt{psfonts.cmz} as well. This can be achieved by adding map files in the
530 following line of
531 \texttt{pyx/text.py}:
532 \begin{progcode}
533 fontmap = readfontmap(["psfonts.map"])
534 \end{progcode}
536 It may well be that future versions of \PyX{} take care of this problem so that
537 one needs no longer to worry about \texttt{psfonts.map}, at least for the
538 standard cmr fonts.
541 \question{a}{No information for font `xyz7t' found in font mapping file}
543 {After verifying that your problem was not addressed in \uaref{q:no_cmr10},
544 you should switch on virtual font support by using \texttt{text.set(dvicopy=1)}.
545 For those interested in more details: setting this option will cause
546 \texttt{dvicopy} to be run after a \texttt{dvi}-file has been created by a call
547 to \TeX/\LaTeX. \texttt{dvicopy} expands any references to virtual fonts to
548 base fonts and thus produces a modified copy of the original \texttt{dvi}-file.
550 If this does not help, verify the existence of \texttt{xyz7t.vf} in one of the
551 subdirectories of \path{TEXMF/fonts/vf} (again, a TDS compliant \TeX{}
552 system is assumed \uaref{q:fontshape_undefined}). If the
553 virtual font file exists, find out which font it requests. A human readable
554 version of the virtual font file can be obtained with the help of
555 \texttt{vftovp}. A Unix operating system should allow you to obtain the
556 fontname by means of
557 \begin{progcode}
558 vftovp xyz7t.vf|grep FONTNAME
559 \end{progcode}
560 The resulting fontname has to be listed in \texttt{psfonts.map}. Use
561 \begin{progcode}
562 kpsewhich psfonts.map
563 \end{progcode}
564 to find out where this file resides (there may be more than one and it is
565 important to know which one is actually read).
568 \subsection{Fonts}
570 \question{t}{I have Type1 fonts in \texttt{pfa} format. How do I obtain the
571 corresponding \texttt{pfb} files needed by \PyX?}
576 \question{a}{I want to use a font other than computer modern roman}
578 {\label{q:other_font}
579 As long as you have a font in Type1 format available, this should be no
580 problem (even though it may cost you some time to set up things properly).
582 In the simplest case, your \LaTeX{} system contains everything needed.
583 Including the following line into your code will probably work
584 \begin{progcode}
585 text.set(mode="latex")\\
586 text.preamble(r"\cs{usepackage}\cb{mathptmx}")
587 \end{progcode}
588 and give you Times as roman font.
590 If you own one of the more common commercial fonts, take a look at
591 \ctan{fonts} and its subdirectories as well as at the web page
592 \url{http://home.vr-web.de/was/fonts.html} of Walter Schmidt. It is not
593 unlikely that somebody has already done most of the work for you and created
594 the files needed for the font to work properly with \LaTeX. But remember:
595 we are talking about commercial fonts here, so do not expect to find the fonts
596 themselves for free.
598 If none of these cases applies, you should spend some time reading
599 manuals about font installation, e.g.\ \ctan{macros/latex/doc/fntguide.pdf}
600 (of course, I do not expect font wizards to read the last few lines).
603 \question{a}{Can I use a TrueType font with \PyX?}
605 {Not directly as \PyX{} only knows how to handle Type1 fonts (although it is
606 possible to get \LaTeX{} to work with TrueType fonts). However, you may use
607 \texttt{ttf2pt1} (from \url{http://ttf2pt1.sourceforge.net}) to convert a
608 TrueType font into a Type1 font which you then install in your \TeX{} system
609 \uaref{q:other_font}. You will loose hinting information
610 in the conversion process but this should not really matter on output devices
611 with not too low resolution.
614 \end{document}