Asciidoctor LaTeX
 1. Introduction
 2. Features
 2.1. Inline and displayed formulas
 2.2. Environments
 2.3. Click blocks
 3. Installation
 3.1. From Rubygems
 3.2. From GitHub
 4. Contributing
 5. Dialects
 6. Macros
 7. Switches
 8. Document format
 9. AsciiDocLaTeX environments
1. Introduction
Asciidoctor LaTeX defines an extended syntax for the AsciiDoc markup language (AsciiDocLaTeX) that closely parallels LaTeX for inline and display mathematical formulas and for environments. Documents written in this extended markup language can be converted into HTML or LaTeX:
 Render as HTML

Use
asciidoctorlatex b html foo.adoc
to producefoo.html
.  Render as LaTeX

Use
asciidoctorlatex foo.adoc
to producefoo.tex
, then usexelatex foo.tex
to createfoo.pdf
.
Below, we describe the main
features of AsciiDocLaTeX. However, since this document
will not render fully in GitHub, you
are encouraged to compile it yourself using
asciidoctorlatex b html README.adoc
or to consult the
README at S3.
There is also an online version hosted at shoobox.io,
a site for editing and distributing AsciiDoc and AsciiDocLaTeX documents.
Asciidoctor LaTeX is developed by James Carlson, Jakub Jirutka, and Dan Allen. Display of mathematical text relies on MathJax.
2. Features
AsciiDocLaTeX renders inline and displayed mathematical, and it supports a construct akin to LaTeX environments for theorems, equations, etc. These and other features are described briefly below and more fully in AsciiDocLaTeX environments.
2.1. Inline and displayed formulas
Imagine that foo.adoc
contains the text below.
The inline and displayed formulas will be correctly rendered as html or tex.
The formula $a^2 + b^2 = c^2$ relates the sides and hypotenuse of a right triangle. The formula \[ \int_0^1 x^n dx = \frac{1}{n+1} \] is something we all learn in Calculus
2.2. Environments
[env.theorem]  The Diophantine equation \[ x^n + y^n = z^n \] for $n > 2$ has only trivial solutions 
2.3. Click blocks
A click block displays its title but not its body. If you click on the title, the body is displayed. Click on the title again to hide the body.
The title of a click block is displayed in blue.
[env.question]  What is the speed of light?  [click.answer]  300,000 km/sec 
3. Installation
3.1. From Rubygems
Run gem install asciidoctorlatex pre
to install from RubyGems.org.
See the change log for a list of updates.
3.2. From GitHub
If you would like to install a development version from the repository, use:
$ git clone https://github.com/asciidoctor/asciidoctorlatex.git $ cd asciidoctorlatex $ gem build asciidoctorlatex.gemspec $ gem install *.gem
4. Contributing
If you wish to contribute to the asciidoctorlatex project, you should set up your environments to use Jakub Jirutka’s asciidoctordoctest. At the moment you will need to use the version which handles dialects using
gem 'asciidoctordoctest', github: 'jxxcarlson/asciidoctordoctest', ref: 'latex'
in your Gemfile. Run all tests with rake doctest
,
or run individual tests with rake doctest:html
or
rake doctest:tex
.
At the moment the tests are for the latex dialect.
5. Dialects
Asciidoctor LaTeX processes three dialects of the core AsciiDoc language:

asciidoc
(the core language) 
manuscript

latex
Asciidoclatex
is the default dialect. Dialects can be set with the :dialect
on the
command line as in this example:
asciidoctorlatex a dialect=manuscript foo.adoc
To set the dialect with the Ruby API, use for example :
Asciidoctor.convert str, { 'dialect' => 'latex' }
6. Macros
Macros can be included in the body of an AsciiDocLaTeX file using the texmacro
environment, as in the example below.
[env.texmacro]  \def\AA{\mathbb{A}} \def\BB{\mathbb{B}} \newcommand{\set}[1]{ \{\,#1\, \} } \newcommand{\sett}[2]{ \{\,#1\, \mid\, #2\, \} } 
To include a LaTeX macro file MACRO_FILE, insert the code
include_latex_macros::MACRO_FILE[]
. Here MACRO_FILE can be a file name or a an absolute or relative path. Included macros work
for both the html and tex backends.
Note

Automatic inclusion of the file macros.tex
has been discontinued.

7. Switches
To generate a tex file with a minimal header, do:
$ asciidoctorlatex a header=no foo.adoc
An alternate css file, data/print.css
is provided
for printing. It features wider margins and a smaller
type size. Copy it to the root of your document
folder and use the command asciidoctorlatex a stylesheet=print.css
or more generally asciidoctorlatex a stylesheet=path_to/print.css
.
AsciidoctorLaTeX’s default form at is :latexmath
.
To use :stem
, put the text :stem:
in your file. To turn the switch
on and set it to latexmath
, say
instead of stem:latexmth
.
8. Document format
Asciidoctor supports two closelyrelated
math formats, AsciiDocLaTeX
and AsciiMath.
In AsciiDocLaTeX,
one can write \$ a^2 + b^2 = c^2 \$
and
\[ e^{2\pi \sqrt{1}} = 1, \]
for inline and display mathematial
text, respectively.
You will need to express dollardenominated
currency using
escaped dollar signs, as
in the sentence, "He paid \$100 for that
theorem." In AsciiMath, one writes
stem:[ a^2 + b^2 = c^2 ]
and
[stem] ++++ e^{2\pi \sqrt{1}} = 1. ++++
9. AsciiDocLaTeX environments
AsciiDoctor LaTeX supports an env
construct that maps to LaTeX environments.
Thus
[env.theorem]  There exist infinitely many prime numbers. 
renders as an automatically numbered theorem. Environments can contain inline and display mathematics, e.g.,
[env.theorem]  A twobytwo matrix is invertible if its determinant is nonzero, i.e., if \[ \left\begin{matrix} a & b \\ c & d \end{matrix}\right \ne 0 \] This result extends to $n\times n$ matrices. 
There is complete freedom in parameter NAME
of [env.NAME]
, Thus,one can write
[env.definition]  An integer $n$ is *prime* if (a) it is not $\pm 1$ and (b) it has no divisors other than $\pm 1$ and $\pm n$. 
or
[env.joke]  A mathematician, a philosopher, and a lawyer met at the local bar for a drink. The lawyer said ... 
One can make cross references by labeling the environment as in
[env.joke#mathjoke1]  A mathematician, a philosopher, and a lawyer met at the local bar for a drink. The lawyer said ... 
then referencing it later as <<mathjoke1>>
Certain environments receive special treatment.
For numbered equations, use [env.equation]
like this
[env.equation]  a^{p1} \equiv 1\ \text{mod}\ p 
An equation number will be displayed only when a label for crossreferencing is provided, e.g.,
[env.equation#littlefermat]  a^{p1} \equiv 1\ \text{mod}\ p 
For sets of equations, use [env,equationalign]
:
[env.equationalign]  A & = 4\pi r^2 \\ V & = \frac{4}{3} \pi r^3 