source: rtems-tools/doc/asciidoc/doc/latex-backend.txt @ f91e023

4.104.115
Last change on this file since f91e023 was f91e023, checked in by Chris Johns <chrisj@…>, on 02/17/14 at 07:04:46

Add the documentation.

  • Property mode set to 100644
File size: 11.3 KB
Line 
1LaTeX backend for Asciidoc
2==========================
3Benjamin Klum <benjamin.klum@gmail.com>
4v1.0, June 2006
5
6== Introduction
7
8
9LaTeX backend is a configuration file for Stuart Rackham's http://www.methods.co.nz/asciidoc/[Asciidoc]. It generates high-level LaTeX markup from Asciidoc documents. LaTeX is a document preparation system for TeX which in turn is a popular typesetting system. It is well known for producing excellently typesetted high quality printouts, especially suited for scientific text.
10
11== Tutorial
12Getting a ready-to-print document from an Asciidoc document using the LaTeX backend involves at least two steps:
13
141. Conversion of the Asciidoc document into a LaTeX document (this is done by Asciidoc using the LaTeX backend)
152. Conversion of the LaTeX document into a PDF document (this is done by the TeX system)
16
17Try to create a PDF document from the Asciidoc document `article.txt` which resides in the `doc` directory of Asciidoc:
18
19.. Make a copy of `article.txt` in a directory of your choice, let's call it `latex-test`.
20.. Make sure that all images referenced in `article.txt` exist in `latex-test`. Brute force approach: Copy the whole `images` directory from Asciidoc directory into `latex-test`.
21.. Change directory to `latex-test` and type following commands:
22+
23  asciidoc --unsafe --backend=latex article.txt
24  pdflatex article.tex
25+
26.. Now there should be a file `article.pdf` in the `latex-test` directory.
27
28[IMPORTANT]
29==============================
30- Asciidoc has to be started in 'unsafe mode' when using LaTeX backend.
31- Note that some special LaTeX packages are necessary, see <<packageRequirements,here>>.
32==============================
33
34== General notes
35
36=== Quality of LaTeX output
37High-level LaTeX is not very straightforward to generate. Therefore there's no guarantee that the generated output is valid and compiles successfully. At all, this backend should be considered as rather experimental.  You should have been already in touch with LaTeX in order to use the backend effectively because LaTeX compilation errors can be really nasty.
38
39Nevertheless good results can be achieved by using LaTeX backend. Try for example to compile Stuart Rackham's Asciidoc documentation, a rather large document. It should compile without problems. However, the code filter might have to be reconfigured for the code filter example to work.
40
41=== Configuration file customization
42Like every other Asciidoc backend the LaTeX backend can be customized easily to fit the user's needs. Actually it is very important to have this option since LaTeX doesn't have a companion language like CSS which allows to put styling information in a separate file. Read more about the LaTeX backend configuration file <<configurationFile,here>>.
43
44=== Output optimization
45The LaTeX output is optimized for creating PDF documents using 'pdflatex'.
46
47[[unicodeSupport]]
48=== Unicode support
49Unfortunately TeX/LaTeX does not have native unicode support. The package 'ucs' adds elementary unicode support by introducing UTF-8 input encoding recognition and by defining lookup tables which contain the corresponding LaTeX commands for unicode characters. But these lookup tables are far from being complete. When a unicode character is found which is not defined in the lookup tables an error is raised by the TeX/LaTeX compiler. Note that TeX/LaTeX compilation errors caused by missing unicode character definitions are not fatal, that means the result is probably readable but undefined unicode characters are replaced with `[U+...]`. You may (de)activate the recognition of escaped unicode characters. See the <<latex-recognize-escaped-unicode>> backend option.
50
51== Backend specific features
52
53=== Special sections
54
55LaTeX backend supports the following special sections and replaces them with corresponding LaTeX commands or environments:
56
57- Abstract (only for document type 'article')
58- Dedication (only for document type 'book')
59- Index
60- Bibliography (only when the attribute 'latex-use-bibliography-environment' is set)
61- Appendix
62- Contents
63
64[[internalCrossReferences]]
65=== Internal cross references
66
67Macros for internal cross references have been extended by the attribute 'style'.
68
69  xref:<id>[<caption>, style=<style>]
70
71or
72
73  <<<id>,<caption>,<style>>>
74
75 
76The additional attribute 'style' can have following values:
77
78page::
79Let's LaTeX print the page number of the referenced anchor.
80
81ref::
82Let's LaTeX print the number of the section, subsection, figure, table or theorem the referenced anchor resides.
83
84autoref::
85Let's LaTeX print the number of the section, subsection, figure, table or theorem the referenced anchor resides preceded with a contextual label.
86
87cite::
88Let's LaTeX interprete this reference as a reference to a bibliography entry. If the attribute 'latex-use-bibliography-environment' is set, references with 'cite' style as well as their corresponding bibliography anchors are presented as automatically generated numbers.
89
90If the 'style' attribute is not set the reference is printed the common way.
91
92
93=== Options
94LaTeX document generation is influenced by the following attributes:
95
96latex-table-rowlimit::
97The maximum number of rows for typesetting tables using the 'tabular' environment. If a table has more rows than 'latex-table-rowlimit', 'longtable' environment is used instead of 'tabular' environment. 'longtable' environment supports tables spanning over several pages.
98
99latex-use-bibliography-environment::
100If 'latex-use-bibliography-environment' is defined, 'thebibliography' environment is used for the bibliography section. As a result bibliography entries are automatically numbered. Note that this works only if the bibliography section contains exclusively bibliography list items which start with a bibliography entry ([[[...]]]). Otherwise a TeX/LaTeX compilation error will occur. In order to display bibliography references correctly their 'style' attribute must be set to 'cite'. For more information see <<internalCrossReferences,Internal cross references>>.
101
102latex-indent-paragraphs::
103If 'latex-indent-paragraphs' is defined, the first line of paragraphs will be indented. By default LaTeX backend prevents paragraph indentation and prints paragraphs with preceding vertical space.
104
105[[latex-recognize-escaped-unicode]] latex-recognize-escaped-unicode::
106If 'latex-recognize-escaped-unicode' is defined, escaped unicode
107characters (e.g. `\$${amp}#960;$$` or `\$${amp}#x3C0;$$`) will be recognized. This can lead to LaTeX compilation errors since LaTeX unicode support is only rudimentary. For more information see <<unicodeSupport, Unicode support>>.
108
109latex-use-custom-list-items::
110If 'latex-use-custom-list-items' is defined, lists will be bulleted or enumerated the way you have typed them in the original Asciidoc document. That means, `*` turns into a circle bullet, `-` turns into a dash, `.` turns into a number and `..` turns into a letter. Otherwise LaTeX will use different bullets and enumeration characters depending on the level of nesting.
111
112latex-use-colored-tables::
113If 'latex-use-colored-tables' is defined, tables will be printed colored.
114
115latex-use-running-title-headings::
116If 'latex-use-running-title-headings' is defined, 'pagestyle' will be set to 'headings' which results in running titles in the head.
117
118latex-use-colored-sidebar-blocks::
119If 'latex-use-colored-sidebar-blocks' is defined, sidebar block content will be put in a color box instead of being indented by a vertical bar.
120
121icons::
122Link admonition paragraph and admonition block icon images and badge images. By default icons is undefined and text is used in place of icon images.
123
124encoding::
125Set the input and output document character set encoding. Currently `ISO-8859-1` and `UTF-8` are supported.
126
127== Requirements
128
129=== General
130
131The following software is necessary for using the LaTeX backend:
132
133- An up-to-date version of http://www.methods.co.nz/asciidoc/[Asciidoc]
134- An up-to-date TeX distribution, e.g.:
135  * http://www.miktex.org/[MiKTeX] for Windows
136  * http://www.tug.org/tetex/[teTeX] for Linux
137
138[[packageRequirements]]
139=== TeX/LaTeX Package requirements
140
141LaTeX backend makes use of some LaTeX specialities which don't belong to a minimal TeX/LaTeX distribution. However, I took special care not to employ exotic packages. Hence the following packages should be available in most package repositories. The table is not complete yet because I don't know the package names for all TeX distributions.
142
143[cols="4*,4",options="header"]
144|====================================================================
145|Speciality | MiKTeX package name | teTeX package name | TeX Live package name | Description
146|KOMA-Script | koma-script | | | LaTeX backend uses the document classes 'scrartcl' and 'scrbook' as well as some other specialities defined in the 'KOMA-Script' package, e.g. the commands `\addmargin{}` and `\minisec{}`.
147|xcolor.sty | xcolor | | | Used to produce colored boxes and tables.
148|colortbl.sty | colortbl | | | Used to produce colored tables.
149|type1ec.sty | cm-super | | | Enables high quality fonts for PDF output.
150|hyperref.sty | hyperref | | | Extensive support for hypertext in PDF documents.
151|enumerate.sty | tools | | | When 'latex-use-custom-list-items' is defined this package is used for determining the enumeration character.
152|graphicx.sty | graphics | | | Used for including images.
153|longtable.sty | tools | | | Enables page spanning tables.
154|ucs.sty | unicode | | | Enables support for unicode characters.
155|textcomp | ltxbase | | | Used for printing various symbols like arrows. Should be already installed.
156|alltt | ltxbase | | | Used in literal-like blocks for retaining line and whitespace formatting. Should be already installed.
157|listings.sty | listings | | | Used for listing blocks.
158|====================================================================
159
160[[configurationFile]]
161== About the LaTeX backend configuration file
162An important note for people who want to adapt the LaTeX backend configuration file to their own needs:
163
164LaTeX markup has a lot of special characters, most importantly ``, `{`, `}`. In order to make things less complicated, I changed the default substitution order (see entry 'subsnormal' in the `[miscellaneous]` section). In contrast to the backends 'docbook' and 'xhtml11', the 'specialcharacters' substitution is applied very late. As a result all special characters produced by 'quotes', 'specialwords', 'replacements', 'attributes' and 'macros' become escaped at the end. If you don't want special characters in the corresponding sections to get escaped, you've to use following symbols instead of the special characters.
165
166- `\$$!..backslash..!$$` instead of ``
167- `\$$!..braceleft..!$$` instead of `{`
168- `\$$!..braceright..!$$` instead of `}`
169
170 
171For more special characters take a look in the `[replacements2]` sections. `[replacements2]` section is responsible for replacing the symbols with their corresponding special characters.
172
173
174== Ideas
175
176=== Code listing block
177
178For creating highlighted code listings I suggest the use of http://www.andre-simon.de/[Highlight] or http://www.gnu.org/software/src-highlite/[GNU Source Highlight]. Both are suited for use as Asciidoc filters.
179
180== Known Bugs
181
182- Sometimes LaTeX backend handles things differently from the default backends
183- A lot of little bugs
184
185== Todo List
186
187- Remove bugs
188- Support for 'grid' attribute in tables
189- Better looking tables
190- Option for squeezing output (smaller lists)
191- Support for different languages (That would be a nice feature for Asciidoc in general)
192- Option for switching titlepage on and off
Note: See TracBrowser for help on using the repository browser.