Table of Contents
LaTeX backend is a configuration file for Stuart Rackham's 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.
Getting a ready-to-print document from an Asciidoc document using the LaTeX backend involves at least two steps:
Try to create a PDF document from the Asciidoc document article.txt
which resides in the doc
directory of Asciidoc:
article.txt
in a directory of your choice, let's call it latex-test
.
article.txt
exist in latex-test
. Brute force approach: Copy the whole images
directory from Asciidoc directory into latex-test
.
Change directory to latex-test
and type following commands:
asciidoc --unsafe --backend=latex article.txt pdflatex article.tex
article.pdf
in the latex-test
directory.
![]() | Important |
---|---|
|
High-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.
Nevertheless 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.
Like 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 here.
Unfortunately 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.
LaTeX backend supports the following special sections and replaces them with corresponding LaTeX commands or environments:
Macros for internal cross references have been extended by the attribute style.
xref:<id>[<caption>, style=<style>]
or
<<<id>,<caption>,<style>>>
The additional attribute style can have following values:
If the style attribute is not set the reference is printed the common way.
LaTeX document generation is influenced by the following attributes:
{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 Unicode support.
*
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.
ISO-8859-1
and UTF-8
are supported.
The following software is necessary for using the LaTeX backend:
LaTeX 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.
Speciality | MiKTeX package name | teTeX package name | TeX Live package name | Description |
---|---|---|---|---|
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{} .
| ||
xcolor.sty | xcolor | Used to produce colored boxes and tables. | ||
colortbl.sty | colortbl | Used to produce colored tables. | ||
type1ec.sty | cm-super | Enables high quality fonts for PDF output. | ||
hyperref.sty | hyperref | Extensive support for hypertext in PDF documents. | ||
enumerate.sty | tools | When latex-use-custom-list-items is defined this package is used for determining the enumeration character. | ||
graphicx.sty | graphics | Used for including images. | ||
longtable.sty | tools | Enables page spanning tables. | ||
ucs.sty | unicode | Enables support for unicode characters. | ||
textcomp | ltxbase | Used for printing various symbols like arrows. Should be already installed. | ||
alltt | ltxbase | Used in literal-like blocks for retaining line and whitespace formatting. Should be already installed. | ||
listings.sty | listings | Used for listing blocks. |
An important note for people who want to adapt the LaTeX backend configuration file to their own needs:
LaTeX 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.
!..backslash..!
instead of \
!..braceleft..!
instead of {
!..braceright..!
instead of }
For more special characters take a look in the [replacements2]
sections. [replacements2]
section is responsible for replacing the symbols with their corresponding special characters.
For creating highlighted code listings I suggest the use of Highlight or GNU Source Highlight. Both are suited for use as Asciidoc filters.