~ubuntu-branches/ubuntu/jaunty/python-docutils/jaunty

« back to all changes in this revision

Viewing changes to docs/user/latex.txt

  • Committer: Bazaar Package Importer
  • Author(s): Simon McVittie
  • Date: 2008-07-24 10:39:53 UTC
  • mfrom: (1.1.4 upstream) (3.1.7 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080724103953-8gh4uezg17g9ysgy
Tags: 0.5-2
* Upload docutils 0.5 to unstable
* Update rst.el to upstream Subversion r5596, which apparently fixes
  all its performance problems (17_speed_up_rst_el.dpatch, closes: #474941)

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
:Author: Engelbert Gruber
6
6
:Contact: grubert@users.sourceforge.net
7
 
:Revision: $Revision: 3415 $
8
 
:Date: $Date: 2005-06-01 02:56:39 +0200 (Wed, 01 Jun 2005) $
 
7
:Revision: $Revision: 5575 $
 
8
:Date: $Date: 2008-06-23 11:33:43 +0200 (Mon, 23 Jun 2008) $
9
9
:Copyright: This document has been placed in the public domain.
10
10
 
11
11
.. contents::
14
14
Introduction
15
15
============
16
16
 
17
 
Producing LaTeX code from reST input could be done in at least two ways:
18
 
 
19
 
a. Transform the internal markup into corresponding LaTeX markup e.g.
20
 
   a section title would be written as ```\section{this section ...}``.
21
 
b. Using LaTeX as a typesetting system to produce desired paperwork
22
 
   without caring about loosing document structure information.
23
 
 
24
 
The former might be preferable, but limits to LaTeXs capabilities, so 
25
 
in reality it is a mix. The reality is that LaTeX has a titlepage with
26
 
title, author and date, by default only title is used. Author and date
27
 
are shown in the docutils docinfo table and set to blank for LaTeX.
28
 
To get author and date set by LaTeX specify option "use-LaTeX-docinfo".
 
17
Producing LaTeX code from reST input can be done in at least two ways:
 
18
 
 
19
a. Transform the internal markup into corresponding LaTeX markup.
 
20
   For example, a section title would be written with the LaTeX section
 
21
   command: ``\section{this section title}``.
 
22
 
 
23
   This can be constrained by the LaTeX document class
 
24
   and may require hacking around bugs/features in LaTeX,
 
25
   but it produces a readable LaTeX file.
 
26
 
 
27
   If you prefer this approach, try ``rst2latex``.
 
28
 
 
29
b. Use LaTeX as a typesetting system to produce the desired document structure
 
30
   without bothering with the usual LaTeX idioms for representing
 
31
   document structure information.
 
32
 
 
33
   This is not constrained by a particular LaTeX document class
 
34
   and therefore requires hacking around bugs/features in LaTeX.
 
35
   But it produces a hard to read LaTeX file.
 
36
 
 
37
   ``rst2newlatex`` adds a lot of LaTeX macros and uses LaTeX as a typesetter
 
38
   without caring about producing readable LaTeX files.
 
39
 
29
40
 
30
41
Options
31
42
=======
32
43
 
33
 
Configuration can be done in two ways (again):
 
44
Configuration can be done in two ways:
34
45
 
35
46
1. Options to the docutils tool: e.g. language selection.
36
 
2. Options to LaTeX via the stylesheet file.
 
47
2. Options to LaTeX via a stylesheet file.
37
48
 
38
49
The generated LaTeX documents should be kept processable by a standard
39
50
LaTeX installation (if such a thing exists), therefore the document
41
52
is included at last.
42
53
 
43
54
Run ``rst2latex.py --help`` to see the command-line options, or have look in
44
 
config documentytion.
 
55
config documentation.
45
56
 
46
57
 
47
58
=====================  ================================================
62
73
 
63
74
                         \geometry{a5paper,landscape}
64
75
---------------------  ------------------------------------------------
65
 
paragraph indent       By default LaTeX indents the forst line in a
66
 
                       paragraph. The following lines set indentation 
67
 
                       to zero but add a vertical space between 
68
 
                       paragraphs.::
 
76
paragraph indent       The default LaTeX behavior in most document classes
 
77
                       is the following: indent the first line in 
 
78
                       a paragraph unless it is the first line of 
 
79
                       a chapter, section, subsection, or 
 
80
                       subsubsection.
 
81
 
 
82
                       This is configurable.  For example, you could 
 
83
                       use the following lines to set paragraph 
 
84
                       indentation to zero but add a vertical space 
 
85
                       between paragraphs.::
69
86
 
70
87
                         \setlength{\parindent}{0pt}
71
88
                         \setlength{\parskip}{6pt plus 2pt minus 1pt}
110
127
 
111
128
                       for bigger linespacing.
112
129
---------------------  ------------------------------------------------
 
130
use verbatim when      When possibile, use verbatim for literal-blocks.
 
131
possible               Compatibility alias for "--literal-env=verbatim".
 
132
 
 
133
                       A literal-block element, when processed by a
 
134
                       docutils-writer might have it's origin in a
 
135
                       markup with "::" syntax or a 
 
136
                       ".. parsed-literal::" directive.
 
137
 
 
138
                       A LaTeX verbatim environment is only useable if
 
139
                       there are no elements contained in the 
 
140
                       literal-block.
 
141
---------------------  ------------------------------------------------
113
142
font selection         see below
114
143
=====================  ================================================
115
144
 
 
145
PDF generation
 
146
--------------
 
147
 
 
148
LaTeX offers three ways
 
149
 
 
150
pdflatex :
 
151
  Generates a PDF document directly from the LaTeX file. As always one
 
152
  might need to call it twice (thrice) to get internal references correct.
 
153
 
 
154
latex dvipdfm :
 
155
  Use ``latex`` to generate a dvi file and ``dvipdfm`` to produce a pdf file.
 
156
  If you will take this approach, specify ``documentoptions=dvipdfm``.
 
157
 
 
158
latex dvips ps2pdf :
 
159
  Produce a dvi file with ``latex``, postscript with ``dvips`` and pdf with
 
160
  ``ps2pdf``.
 
161
 
 
162
see next section for font selection.
 
163
 
116
164
 
117
165
Font selection
118
166
--------------
154
202
Unicode
155
203
-------
156
204
 
157
 
The generated LaTeX documents are in latin1 encoding per default, if unicode
158
 
characters are required one must set ``--output-encoding=utf-8`` install
159
 
`LaTeX unicode`_ support and add::
160
 
 
161
 
    \usepackage{ucs}
162
 
    \usepackage[utf8]{inputenc}
163
 
 
164
 
to the stylesheet. If LaTeX issues a Warning about unloaded/known characters
165
 
adding ::
 
205
The generated LaTeX documents are in the input encoding per default. 
 
206
 
 
207
* If the source document is in utf-8 encoding (or
 
208
  ``--output-encoding=utf-8`` is set), LaTeX needs unicode support
 
209
  (the ``ucs`` package). If this is not available, specify
 
210
  a different output-encoding, e.g. ``latin1``.
 
211
 
 
212
* If LaTeX issues a Warning about unloaded/known characters adding ::
166
213
 
167
214
    \PreloadUnicodePage{n}
168
215
 
169
 
where *n* is the unicode pagenumber, might help.
170
 
 
171
 
.. _LaTeX unicode: http://www.unruh.de/DniQ/latex/unicode/
 
216
  where *n* is the unicode pagenumber, might help.
 
217
 
 
218
  .. _LaTeX unicode: http://www.unruh.de/DniQ/latex/unicode/
 
219
 
 
220
* Unicode box drawing characters
 
221
 
 
222
  - generate LaTeX code with ``--output-encoding=utf-8:strict``.
 
223
 
 
224
  - In the latex file, edit the preamble to load "ucs" with "postscript"
 
225
    option and also load the pstricks package::
 
226
  
 
227
        \usepackage{shortvrb}
 
228
      - \usepackage{ucs}
 
229
      + \usepackage[postscript]{ucs}
 
230
      + \usepackage{pstricks}
 
231
        \usepackage[utf8x]{inputenc}
 
232
 
 
233
  - Convert to PDF with ``latex``, ``dvips``, and ``ps2pdf``.
172
234
 
173
235
Table of figures
174
236
----------------
175
237
 
176
238
A table of figures can be generated by a command directly to LaTeX::
177
239
 
178
 
  .. raw:: LaTeX
 
240
  .. raw:: latex
179
241
 
180
242
     \listoffigures
181
243
 
184
246
Section numbering
185
247
-----------------
186
248
 
187
 
If section numbering and LaTeX table of contents is used LaTeX and 
188
 
docutils will number sections. To switch off displaying of LaTeX's
189
 
numbers one has to add following lines to the stylesheet ::
190
 
 
191
 
  % no section number display
192
 
  \makeatletter
193
 
  \def\@seccntformat#1{}
194
 
  \makeatother
195
 
  % no numbers in toc
196
 
  \renewcommand{\numberline}[1]{}
197
 
 
 
249
The options ``--section-numbering`` and ``--use-latex-toc``, both 
 
250
influence section numbering.
 
251
 
 
252
* If ``--use-latex-toc`` is specified the latex-writer generates 
 
253
  LaTeX output, so that LaTeX generates a table of contents and
 
254
  generates section numbers. Usually one does not want to have 
 
255
  section numbers generated by docutils in this case, therefore
 
256
  ``--no-section-numbering`` should be specified.
 
257
 
 
258
  The advantage is that LaTeX does put page numbers into the
 
259
  table of contents, but the section depth is limited by the 
 
260
  used LaTeX-documentclass, usually to three levels.
 
261
 
 
262
* If section numbering and LaTeX table of contents is used LaTeX and 
 
263
  docutils will number sections. To switch off displaying of LaTeX's
 
264
  numbers one has to add following lines to the stylesheet ::
 
265
 
 
266
    % no section number display
 
267
    \makeatletter
 
268
    \def\@seccntformat#1{}
 
269
    \makeatother
 
270
    % no numbers in toc
 
271
    \renewcommand{\numberline}[1]{}
 
272
 
 
273
  This enables to have the same section numbers as in other docutils-
 
274
  writers and page numbers in the table of contents.
198
275
 
199
276
Number pages by chapter
200
277
-----------------------
222
299
If pdf-image inclusion in pdf files fails, specify
223
300
``--graphicx-option=pdftex`` or ``--graphicx-option=auto``.
224
301
 
 
302
Wrapping text around images requires the wrapfig package.
225
303
 
226
304
Commands directly to LaTeX
227
305
==========================
229
307
By means of the reST-raw directive one can give commands directly to 
230
308
LaTeX, e.g. forcing a page break::
231
309
 
232
 
  .. raw:: LaTeX
 
310
  .. raw:: latex
233
311
 
234
312
     \newpage
235
313
 
236
314
 
237
315
Or setting formulas in LaTeX::
238
316
 
239
 
  .. raw:: LaTeX
 
317
  .. raw:: latex
240
318
 
241
319
     $$x^3 + 3x^2a + 3xa^2 + a^3,$$
242
320
 
249
327
  Nobody expects the spanish inquisition.
250
328
  |endcolorbox|
251
329
 
252
 
  .. |begincolorbox| raw:: LaTeX
 
330
  .. |begincolorbox| raw:: latex
253
331
 
254
332
     \\begin{center}
255
333
     \\colorbox{bg}{
256
334
     \\parbox{0.985\\linewidth}{
257
335
 
258
 
  .. |endcolorbox| raw:: LaTeX
 
336
  .. |endcolorbox| raw:: latex
259
337
 
260
338
     }}
261
339
     \\end{center}
286
364
 
287
365
Open to be fixed or open to discussion.
288
366
 
 
367
Lists
 
368
-----
 
369
 
 
370
Definitions in definition lists start on the same line as the term. Putting 
 
371
``\leavevmode`` after the term results in a new newline if the definition
 
372
starts with a item list or similar.
 
373
 
289
374
footnotes and citations
290
375
-----------------------
291
376
 
335
420
    uses raggedright. 
336
421
  - Ragged right fails on followup paragraphs as the vertical space would be
337
422
    missing.
 
423
* Use tabularx column type ``X`` and let latex decide width.
 
424
* csv-tables do not have a colwidth.
 
425
 
338
426
 
339
427
Notes
340
428
~~~~~
341
429
 
342
430
* table-style booktabs: booktabs.sty 1.00 does not work with longtable.
 
431
* If default table-style is not booktabs, but the document contains a table 
 
432
  with class booktabs, one has to add the latex package booktabs. That means
 
433
  put the line ::
 
434
 
 
435
    \usepackage{booktabs}
 
436
 
 
437
  into your latex-style.
343
438
 
344
439
Miscellaneous
345
440
-------------
347
442
* Selection of LaTeX fontsize configurable.
348
443
* Assumed reST linelength for table width setting configurable.
349
444
* literal-block indentation configurable.
350
 
* recongize LaTeX and replace by ``\LaTeX``.
 
445
* recognize LaTeX and replace by ``\LaTeX``.
351
446
* Support embed-stylesheet.
352
447
* Sidebar handling.
353
 
* Maybe add end of line after term in definition list. see
354
 
    http://roundup.sf.net/doc-0.5/features.pdf
355
448
* Pdfbookmark level 4 (and greater) does not work (might be settable but OTOH).
356
449
* center subsection{Abstract} gives a LaTeX error here.
357
450
  ``! LaTeX Error: Something's wrong--perhaps a missing \item.``
376
469
* No link to system errors.
377
470
* Hyperlinks are not hyphenated; this leads to bad spacing. See
378
471
  docs/user/rst/demo.txt 2.14 directives.
379
 
* Meta keywords into pdf ?
 
472
* Meta keywords into PDF ?
380
473
* Pagestyle headings does not work, when sections are starred.
381
474
* For additional docinfo items: the field_body is inserted as text, i.e. no
382
475
  markup is done.