7 :Author: Günter Milde <milde@users.berlios.de>
10 This sandbox project is a place to try out and discuss
11 `latex2e writer extensions`_ and `alternative latex writers`_
16 ``latex2e`` writer extensions
17 *****************************
22 #. Which `default font`_ do you prefer for the output?
24 #. Did you experience problems with a missing ``aeguill.sty`` package?
26 Did you have problems with Find or Export of words with
27 non-ASCII chars (e.g. Umlauts) in the PDF reader (Acrobat, xpdf, ...)
29 Which `font encoding`_ do you prefer for the output?
31 #. Would you use/configure a `configurable transition element`_?
33 #. Does the latex2e writer need a `--stylesheet-path option`_?
35 #. Feature wishes or ideas of improvement for the `latex2e` writer.
38 Users of ``rst2latex2.py`` are encouraged to respond by mail to the
45 http://docutils.sourceforge.net/docs/user/latex.html#problems
50 Which default font do you prefer for the output?
53 By default, PDFLaTeX uses embedded computer modern family, which look good
54 on paper but poor on LCDs (even if outlined, due to suboptimal hinting),
55 and result in large PDFs. rst2pdf uses the "standard" PDF fonts by
56 default (Times, Helvetica, Courier) which IMO look reasonable both on
57 screen and on paper. Because they aren't embedded, it also results in a
60 Using different fonts (e.g. standard postscript fonts) can be achieved
61 easily by selecting a font package with the ``--stylesheet`` command line
62 option or in a custom style-sheet.
64 Font embedding must be configured in the LaTeX installation.
69 Use one of the Postscript default fonts supported by standard LaTeX (pages
70 10 and 11 of the `PSNFSS documentation`_)
77 New Century Schoolbook
80 +1 recommended by font experts
81 +1 good LaTeX support including matching math fonts, small caps, old-style figures
83 +1 'de facto standard'
85 -1 narrow (devised for multi-column layouts)
87 +1 recommended by font experts
88 -1 no `Base35` font, no required part of LaTeX any more.
90 Implement as default stylesheet option, so it can be easily overridden.
92 My vote is for Palatino.
100 TeXlive is a large download, and in addition to the base package rst2latex
101 also requires a bunch of extra ``*.sty`` packages, even if they aren't
102 used in the current document.
105 include only package loading commands and definitions that are
106 needed in the current document.
109 `fallback definitions`_ for Docutils-specific constructs.
112 A similar ``LaTeXTranslator.latex_requirements`` dictionary for additions
113 needed *before* the custom style sheet (required packages and their
117 Configurable transition element
118 -------------------------------
120 By default, the `transition element`_ is rendered as a horizontal line.
122 In novels, ofte the form of three stars or some ornamental is used.
123 A simple vertical space is also common.
127 Use semantic markup with a ``\DUtransition`` command that can be
128 customised in a style sheet.
134 Currently, table export uses a logic based on the relative width of the
135 columns in the input to set the column width in the output.
137 Formal (booktabs) vs. standard (fully bordered) tables can be chosen in the
138 configuration settings (only document wide).
140 Tables without borders are possible with the ``borderless`` class argument
143 The following Unicode characters may also precede inline markup:
145 .. class:: borderless
147 === ==========================================================
148 ‘ (U+2018, left single-quote)
149 “ (U+201C, left double-quote)
150 ’ (U+2019, apostrophe)
151 « (U+00AB, left guillemet, or double angle quotation mark)
152 ¡ (U+00A1, inverted exclamation mark)
153 ¿ (U+00BF, inverted question mark)
154 === ==========================================================
159 Add more classes e.g. for column width set by latex, horizontal aligment.
162 --stylesheet-path option
163 ------------------------
165 There are 2 use cases:
167 1. files in the TEXINPUTS path ("installed", site-wide style files (standard
170 * specify only the filename
173 2. files outside the TEXINPUTS path (not installed, local style files)
175 * a relative path should be rewritten if the output document is in a
176 different dir than the pwd
178 Currently, 1) is done with --stylesheet and 2) with --stylesheet-path.
182 -1 having both ``--stylesheet`` and ``stylesheet-path`` makes things complicated:
184 Explaining the two options and their interaction to the user is
187 This holds even more if you take into account the third related
188 option, ``--embed-stylesheet``.
190 -1 it is impossible to have some paths rewritten and some not, as in e.g. ::
192 --stylesheet=mathpazo -stylesheet-path=mystyle.tex
194 "mystyle.tex" would overwrite "mathpazo".
199 Instead of two options, do "the right thing" based on simple rules, e.g:
201 a) Use the "package" vs. "custom style sheet" distinction:
203 Rewrite, if there is an filename extension and it is not ``.sty`` ::
205 --stylesheet='mathpazo,mystyle.tex'
207 will use 'mathpazo' verbatim and rewrite 'mystyle.tex'.
209 -1 will not work for latex packages in the pwd or outside the TEXINPUTS
212 b) rewrite paths that have a directory part::
214 --stylesheet='mathpazo,./mystyle.sty'
216 will use 'mathpazo' verbatim and rewrite './mystyle.sty'.
218 +1 explicite and flexible
220 +1 the common case (files in the TEXINPUTS path) is the most simple
222 -1 need to document/learn special syntax
224 c) rewrite path if this prevents errors:
226 * Check for a given file (or relative path) relative to pwd and output dir.
227 * If it is available relative to pwd but not relative to the output dir,
230 +1 no need to explain any additional syntax
232 +1 does "the right thing" in most usual cases
234 -1 hidden automatism might lead to problems in corner cases
236 -1 mechanism depends on the availability of files at the time of the run,
237 which is harder to explain and less predictable than b)
241 A project with rst documents sorted into a hierarchy of sub-directories
242 and a common style file in the base dir or a sub dir::
257 stylesheet-path: style.tex
259 in docutils.conf, all documents will get a valid link to the style file,
260 if the conversion is started from the base dir.
263 Image and figure directives
264 ---------------------------
266 * Document graphics peculiarities, e.g. accepted formats.
268 * should start a new paragraph.
270 .. compare the functional test result:
271 /home/milde/Code/Python/docutils-svn/docutils/test/functional/input/data/standard.txt
272 and /home/milde/Code/Python/docutils-svn/docutils/test/functional/output/standalone_rst_latex.tex
274 * centered and aligned images with ``\centerline``, ``\flushleft``,
277 * aligning a figure also aligns the legend *but not the caption*
279 What should be aligned?
281 Should the surrounding text wrap around the figure?
287 #. add default unit if none given (to prevent LaTeX error)
288 a poll on docutils-users favoured ``bp`` (Big Point: 1 bp = 1/72 in)
290 #. Do not change ``px`` to ``pt``.
292 * ``px`` is a valid unit in pdftex since version 1.3.0 released on
295 1px defaults to 1bp (or 72dpi), but can be changed with the \pdfpxdimen
298 \pdfpxdimen=1in % 1 dpi
299 \divide\pdfpxdimen by 96 % 96 dpi
301 -- http://www.tug.org/applications/pdftex/NEWS
303 * Modern TeX distributions use pdftex also for dvi generation
304 (i.e. ``latex`` actually calls ``pdftex`` with some options).
306 * Users of legacy TeX versions can be advised to strip the ``px``: while
307 HTML will default to pixels, LaTeX will use points (1/72 in) which
308 conforms to the ``pdftex`` default.
310 Backwards compatibility
311 ~~~~~~~~~~~~~~~~~~~~~~~
313 Images with width specification in ``px`` come out slightly larger:
315 1 bp = 1/72 in > 1 pt = 1/72.25 in
318 if this is an issue, add ``\pdfpxdimen=1pt`` to the style-sheet or as
325 Changes to the latex2e writer in the SVN version since docutils version 0.5.
327 Also see the `Docutils Release Notes`_ and the `Docutils History`_
329 .. Steps for uploading Changes:
331 * provide patch to latex2e/__init__.py
332 * get approvement from the latex writer maintainer (Engelbert Gruber)
334 * (add and) run functional tests::
336 ../../docutils/test/test_functional.py
338 + if output changed: test-compile and approve new output in
339 ../../docutils/test/functional/output/
341 * fix documentation in ../../docutils/docs/user/latex.txt
343 * add changes to ../../docutils/HISTORY.txt
345 * add backwards-incompatible changes to ../../docutils/RELEASE-NOTES.txt
350 New Feature: failsave implementation
351 As with classes to HTML objects, class arguments are silently ignored if
352 there is no styling rule for this class in a custom style sheet.
354 TODO: Custom roles based on standard roles.
356 Backwards compatibility
357 ~~~~~~~~~~~~~~~~~~~~~~~
359 SVN versions 5742 to 5861 contained an implementation that
360 did not work with commands expecting an argument.
361 The implementation from version 5862 is fully backwards compatible.
367 LaTeX packages can be used as ``--stylesheet`` argument without
371 Use ``\usepackage`` if style sheet ends with ``.sty`` or has no
372 extension and ``\input`` else.
375 while ``\input`` works with extension as well as without extension,
376 ``\usepackage`` expects the package name without extension. (The latex2e
377 writer will strip a ``.sty`` extension.)
380 Backwards compatibility
381 ~~~~~~~~~~~~~~~~~~~~~~~
383 Up to Docutils 0.5, if no filename extension is given in the ``stylesheet``
384 argument, ``.tex`` is assumed (by latex).
386 Since Docutils 0.6, a stylesheet without filename extension is assumed to be
387 a LaTeX package (``*.sty``) and referenced with the ``\usepackage`` command.
390 Always specify the extension if you want the style sheet to be
397 Include only definitions that are needed in the
402 The ``LaTeXTranslator.visit<node>`` functions store needed definitions and
403 commands in the dictionary ``LaTeXTranslator.latex_fallbacks``.
405 The fallbacks are defined with ``\providecommand``.
407 The content of ``LaTeXTranslator.latex_fallbacks`` is written to the
408 preamble *after* the custom stylesheet reference/inclusion. Customising
409 in a style sheet is possible with ``\newcommand``.
415 - Add ``bp`` to lenghts without unit (prevents LaTeX errors)
417 - Do not convert ``px`` to ``pt`` (``px`` is supported by pdfTeX since
418 2005-02-04 as a configurable length unit)
420 Backwards compatibility
421 ~~~~~~~~~~~~~~~~~~~~~~~
423 If a length without unit is recognised by latex, it reports an error and add
424 ``pt``. The new default unit is ``bp`` (big points) which is slightly bigger,
427 The unit ``px`` is not defined in "pure" LaTeX, but introduced by the
428 `pdfTeX` converter on 2005-02-04. `pdfTeX` is used in all modern LaTeX
429 distributions (since ca. 2006) also for conversion into DVI.
432 If updating LaTeX is not an option, just remove the ``px`` from the lengh
433 specification. HTML/CSS will default to ``px`` while the `latexe2` writer
434 will add the fallback unit ``bp``.
439 Do not mix font-encoding and font settings: do not load `ae` and `aeguill`
440 unless explicitely required via the ``--stylesheet`` option.
444 ``--font-encoding=LGR,T1`` becomes ``\usepackage[LGR,T1]{fontenc}``
445 (Latin, Latin-1 Supplement, and Greek)
448 Backwards compatibility
449 ~~~~~~~~~~~~~~~~~~~~~~~
451 The following behaviour is new:
453 :font-encoding = '': do not load `ae` and `aeguill` packages, i.e.
455 * do not change font settings,
456 * do not use the fontenc package
457 (implicitely loaded via `ae`),
458 * use LaTeX default font encoding (OT1)
460 :font-encoding = OT1: load `fontenc` with ``\usepackage[OT1]{fontenc}``
463 You get the old behaviour with ``--stylesheet=ae,aeguill``.
465 However, using `ae` is not recommended. A similar look (but better
466 implementation) can be achieved with the packages `lmodern`, `cmsuper`, or
467 `cmlgr` all providing Computer Modern look-alikes in vector format and T1
468 encoding, e.g. ``--font-encoding=T1 --stylesheet=lmodern``.
472 Alternative latex writers
473 *************************
475 Browse the `SVN repository at berlios.de`__
477 __ http://svn.berlios.de/viewvc/docutils/trunk/sandbox/latex-variants/
479 * The `docs` dir contains generic documentation and discussion.
481 Writer specific documentation is placed in the respective "literate"
487 Mainly of historic interest. The experiences gained with the alternative
488 writers will go into the main latex2e writer.
490 * `latex2e_external_stylesheet` replaces most of the generated preamble by
493 * `latex2e_headings_as_multi_line_strings.py` tries to make the latex2e
494 writer source more readable by the use of raw literal strings
495 instead of escaped backslashes.
497 * `latex2e_listings` provides an alternative implementation of the new
498 ``--literal-env`` option to select the environment for
499 typesetting literal blocks.
501 This options allows e.g. to choose `lstlisting` from the ``listings.sty``
502 LaTeX package. See also `<docs/syntax-highlight-with-listings.html>`_
505 =========================
512 Test documents and unit tests highlighting problems with the LaTeX
513 export and testing alternatives.
518 Related sandbox projects
519 ************************
521 * `<../dkuhlman/Docs>`__,
522 * `<../docpy-writer>`__,
523 * `<../jensj/latex_math>`__,
524 * `<../latex_directive>`__, and
525 * `<../verse-writer>`__.
530 .. _PSNFSS documentation:
531 http://dante.ctan.org/CTAN/macros/latex/required/psnfss/psnfss2e.pdf
532 .. _transition element:
533 http://docutils.sourceforge.net/docs/user/rst/quickref.html#transitions
534 .. _Docutils Release Notes:
535 http://docutils.sourceforge.net/RELEASE-NOTES.html
536 .. _Docutils History:
537 http://docutils.sourceforge.net/HISTORY.html