• Stars
    star
    106
  • Rank 314,687 (Top 7 %)
  • Language
    Ruby
  • License
    Other
  • Created over 9 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

📐 Add LaTeX features to AsciiDoc & convert AsciiDoc to LaTeX

Asciidoctor LaTeX

1. Introduction

Asciidoctor LaTeX defines an extended syntax for the AsciiDoc markup language (AsciiDoc-LaTeX) 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 asciidoctor-latex -b html foo.adoc to produce foo.html.

Render as LaTeX

Use asciidoctor-latex foo.adoc to produce foo.tex, then use xelatex foo.tex to create foo.pdf.

Below, we describe the main features of AsciiDoc-LaTeX. However, since this document will not render fully in GitHub, you are encouraged to compile it yourself using asciidoctor-latex -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 AsciiDoc-LaTeX documents.

Asciidoctor LaTeX is developed by James Carlson, Jakub Jirutka, and Dan Allen. Display of mathematical text relies on MathJax.

2. Features

AsciiDoc-LaTeX 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 AsciiDoc-LaTeX environments.

2.1. Inline and displayed formulas

Example

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

Example
  [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.

Example
  [env.question]
  --
  What is the speed of light?
  --

  [click.answer]
  --
  300,000 km/sec
  --

3. Installation

3.1. From Rubygems

Run gem install asciidoctor-latex --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/asciidoctor-latex.git
$ cd asciidoctor-latex
$ gem build asciidoctor-latex.gemspec
$ gem install *.gem

4. Contributing

If you wish to contribute to the asciidoctor-latex project, you should set up your environments to use Jakub Jirutka’s asciidoctor-doctest. At the moment you will need to use the version which handles dialects using

gem 'asciidoctor-doctest', github: 'jxxcarlson/asciidoctor-doctest', 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

Asciidoc-latex is the default dialect. Dialects can be set with the :dialect on the command line as in this example:

   asciidoctor-latex -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 AsciiDoc-LaTeX 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

Tex header

To generate a tex file with a minimal header, do:

$ asciidoctor-latex -a header=no foo.adoc
Print style

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 asciidoctor-latex -a stylesheet=print.css or more generally asciidoctor-latex -a stylesheet=path_to/print.css.

Asciidoctor-LaTeX’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 closely-related math formats, AsciiDoc-LaTeX and AsciiMath. In AsciiDoc-LaTeX, one can write \$ a^2 + b^2 = c^2 \$ and

 \[
    e^{2\pi \sqrt{-1}} = 1,
 \]

for in-line and display mathematial text, respectively. You will need to express dollar-denominated 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. AsciiDoc-LaTeX 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 in-line and display mathematics, e.g.,

 [env.theorem]
 --
 A two-by-two 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^{p-1} \equiv 1\ \text{mod}\ p
--

An equation number will be displayed only when a label for cross-referencing is provided, e.g.,

[env.equation#little-fermat]
--
a^{p-1} \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
--

More Repositories

1

asciidoctor

💎 A fast, open source text processor and publishing toolchain, written in Ruby, for converting AsciiDoc content to HTML 5, DocBook 5, and other formats.
Ruby
4,437
star
2

asciidoctor-pdf

📃 Asciidoctor PDF: A native PDF converter for AsciiDoc based on Asciidoctor and Prawn, written entirely in Ruby.
Ruby
1,089
star
3

asciidoctor.js

📜 A JavaScript port of Asciidoctor, a modern implementation of AsciiDoc
JavaScript
664
star
4

asciidoctorj

☕ Java bindings for Asciidoctor. Asciidoctor on the JVM!
Java
593
star
5

asciidoctor-diagram

↔️ Asciidoctor diagram extension, with support for AsciiToSVG, BlockDiag (BlockDiag, SeqDiag, ActDiag, NwDiag), Ditaa, Erd, GraphViz, Mermaid, Msc, PlantUML, Shaape, SvgBob, Syntrax, UMLet, Vega, Vega-Lite and WaveDrom.
Ruby
419
star
6

asciidoctor-intellij-plugin

AsciiDoc plugin for products on the IntelliJ platform (IDEA, RubyMine, etc)
Java
324
star
7

asciidoctor.org

🌐 Asciidoctor project site. Composed in AsciiDoc. Baked with Awestruct.
SCSS
308
star
8

asciidoctor-maven-plugin

A Maven plugin that uses Asciidoctor via JRuby to process AsciiDoc source files within the project.
Java
298
star
9

jekyll-asciidoc

💉 A Jekyll plugin that converts AsciiDoc source files in your site to HTML pages using Asciidoctor.
Ruby
298
star
10

docker-asciidoctor

🚢 A Docker image for using the Asciidoctor toolchain to process AsciiDoc content
Shell
294
star
11

asciidoctor-vscode

AsciiDoc support for Visual Studio Code using Asciidoctor
TypeScript
281
star
12

asciidoctor-gradle-plugin

A Gradle plugin that uses Asciidoctor via JRuby to process AsciiDoc source files within the project.
Groovy
272
star
13

asciidoctor-reveal.js

🔮 A reveal.js converter for Asciidoctor and Asciidoctor.js. Write your slides in AsciiDoc!
HTML
270
star
14

asciidoctor-epub3

📘 Asciidoctor EPUB3 is a set of Asciidoctor extensions for converting AsciiDoc to EPUB3 & KF8/MOBI
Ruby
203
star
15

asciidoctor-browser-extension

⚪ An extension for web browsers that converts AsciiDoc files to HTML using Asciidoctor.js.
CSS
202
star
16

asciidoctor-maven-examples

A collection of example projects that demonstrates how to use the Asciidoctor Maven plugin.
Java
187
star
17

asciidoctor-stylesheet-factory

!DEPRECATED! This was the utility project for producing the default stylesheet for the HTML converter in Asciidoctor. The source of the default stylesheet now lives in the main Asciidoctor repository.
SCSS
178
star
18

kramdown-asciidoc

A kramdown extension for converting Markdown documents to AsciiDoc.
Ruby
174
star
19

asciidoctor-gradle-examples

A collection of example projects that demonstrates how to use the Asciidoctor Gradle plugin
Java
145
star
20

atom-asciidoc-preview

⚛ AsciiDoc preview for the Atom editor.
CoffeeScript
142
star
21

asciidoctor-kroki

Asciidoctor.js extension to convert diagrams to images using Kroki!
JavaScript
124
star
22

asciidoclet

📋 A Javadoc Doclet based on Asciidoctor that lets you write Javadoc in the AsciiDoc syntax.
Java
120
star
23

asciidoctor-fopub

A portable DocBook-to-PDF build command that wraps DocBook XSL and Apache FOP
Java
111
star
24

jekyll-asciidoc-quickstart

A template project for creating AsciiDoc-based websites using Jekyll.
CSS
105
star
25

asciidoctor-extensions-lab

A lab for testing and demonstrating Asciidoctor extensions. Please do not use this code in production. If you want to use one of these extensions in your application, create a new project, import the code, and distribute it as a RubyGem. You can then request to make it a top-level project under the Asciidoctor organization.
Ruby
97
star
26

asciidoctor-confluence

Push Asciidoctor file to Confluence
Ruby
80
star
27

asciidoctor-backends

Backends (i.e., templates) for Asciidoctor, a Ruby port of AsciiDoc.
HTML
66
star
28

asciidoctor-bibtex

Add bibtex citation support for asciidoc documents
Ruby
59
star
29

docgist

Render AsciiDoc documents from Gists, GitHub, DropBox and other remote sources in the browser.
CSS
56
star
30

asciidoc-docs

The source files in this repository served as the initial contribution for the AsciiDoc Language specification project at Eclipse. This repository is now archived.
55
star
31

brackets-asciidoc-preview

Live Preview of AsciiDoc for Adobe Brackets
JavaScript
51
star
32

asciidoctor-bespoke

🅱️ An Asciidoctor converter that generates the HTML component of a Bespoke.js presentation from AsciiDoc.
Slim
49
star
33

sublimetext-asciidoc

AsciiDoc Package for SublimeText 3
Python
49
star
34

asciidoctor-mathematical

An extension for Asciidoctor that converts the content of STEM blocks and inline macros using Mathematical.
Ruby
44
star
35

atom-language-asciidoc

⚛ AsciiDoc language package for the Atom editor.
CoffeeScript
42
star
36

asciidoctorj-pdf

AsciidoctorJ PDF bundles the Asciidoctor PDF RubyGem (asciidoctor-pdf) so it can be loaded into the JVM using JRuby.
Java
33
star
37

asciidoctorj-screenshot

A set of AsciidoctorJ extensions for adding automated screenshots to an AsciiDoc document.
Groovy
32
star
38

asciidoctor-firefox-addon

🐺 An add-on for Mozilla Firefox that converts AsciiDoc files to HTML directly in the browser using Asciidoctor.js.
JavaScript
32
star
39

asciidoctor-tabs

An extension for Asciidoctor that adds a tabs block to the AsciiDoc syntax.
Ruby
29
star
40

asciidoctor-lein-plugin

A Leiningen plugin for generating documentation using Asciidoctor
Clojure
26
star
41

asciidoctor-chart

A set of Asciidoctor extensions that add a chart block and block macro to AsciiDoc for including charts in your AsciiDoc document.
Ruby
25
star
42

asciidoctor-reducer

⚗️ A tool to generate a single AsciiDoc document by expanding all the include directives reachable from the parent document.
Ruby
24
star
43

asciimath

Asciimath parser
Ruby
23
star
44

docbookrx

(An early version of) a DocBook to AsciiDoc converter written in Ruby.
Ruby
22
star
45

gitbucket-asciidoctor-plugin

A GitBucket plug-in that provided AsciiDoc rendering capabilities
Scala
18
star
46

asciidoctor-leanpub-converter

A backend for AsciidoctorJ to generate Leanpub-flavoured Markdown
Groovy
16
star
47

codemirror-asciidoc

AsciiDoc mode for CodeMirror
JavaScript
16
star
48

asciidoc-grammar-prototype

⛔ ARCHIVED: An experiment to create of a formal grammar for the AsciiDoc markup language. Work is being continued at https://github.com/Mogztter/asciidoctor-inline-parser.
Java
16
star
49

asciidoctor-cli.js

The Command Line Interface (CLI) for Asciidoctor.js
JavaScript
15
star
50

asciidoctor-documentation-planning

⛔ ARCHIVED: Planning for the documentation that covers the AsciiDoc syntax, the Asciidoctor processor, and various projects in the Asciidoctor ecosystem.
15
star
51

asciidoctorj-groovy-dsl

A Groovy DSL that allows for easy definition of Asciidoctor extensions
Groovy
14
star
52

gulp-asciidoctor

gulp-asciidoctor
JavaScript
14
star
53

asciidoctor-docs-ui

The project that produces the UI (theme & user interactions) for docs.asciidoctor.org.
CSS
12
star
54

docs.asciidoctor.org

The Antora playbook project (i.e., site manifest) for the Asciidoctor documentation site.
JavaScript
11
star
55

asciidoctor-deck.js

⛔ ARCHIVED: deck.js converter templates for Asciidoctor, implemented in Haml
HTML
11
star
56

asciidoctor-doctest

🔨 Test suite for Asciidoctor backends
Ruby
10
star
57

asciidoctorj-reveal.js

AsciidoctorJ Reveal.js bundles the Asciidoctor Reveal.js RubyGem (asciidoctor-revealjs) so it can be loaded into the JVM using JRuby
Java
10
star
58

asciidoctor-ant

🐜 Ant task to render Asciidoc documentation
Ruby
9
star
59

asciidoctor-diagram-java

Java
9
star
60

asciidoctorj-diagram

AsciidoctorJ Diagram bundles the Asciidoctor Diagram RubyGem (asciidoctor-diagram) so it can be loaded into the JVM using JRuby.
Java
9
star
61

atom-asciidoc-image-helper

⚛ Tool to make insertion of images into AsciiDocs easier in the Atom editor.
CoffeeScript
9
star
62

atom-asciidoc-assistant

⚛ AsciiDoc Assistant package for the Atom editor.
Shell
9
star
63

asciidoctor-chrome-editor

⛔ ARCHIVED: AsciiDoc Editor inside Chrome!
JavaScript
8
star
64

guard-asciidoc

Guard::AsciiDoc monitors and automatically renders your AsciiDoc documents using Asciidoctor
Ruby
8
star
65

atom-autocomplete-asciidoc

⚛ AsciiDoc language autocompletions
CoffeeScript
7
star
66

asciidoctor-docbook.js

DocBook converter for Asciidoctor.js
JavaScript
7
star
67

asciidoctor-mallard

A Mallard 1.0 converter for Asciidoctor
Ruby
6
star
68

asciidoctor-lazybones

Lazybones templates for Asciidoctor projects
Groovy
5
star
69

asciidoctor-fb2

📕 Asciidoctor FB2 is an Asciidoctor extension for converting AsciiDoc to FB2
Ruby
5
star
70

html-pipeline-asciidoc_filter

⛔ ARCHIVED: An AsciiDoc processing filter for html-pipeline based on Asciidoctor.
Ruby
5
star
71

brand

Brand assets and visual identity for the Asciidoctor project
Shell
4
star
72

opal-node-runtime

⚡️ Opal Runtime specifically designed for Asciidoctor
JavaScript
4
star
73

asciidoctor-template.js

⛔️ DEPRECATED: Generic template backend for Asciidoctor.js
JavaScript
4
star
74

asciidoctor-deb-mirror

A mirror of the asciidoctor deb (Debian) package build in the pkg-ruby-extras package group. DO NOT PUSH CHANGES TO THIS MIRROR.
Ruby
3
star
75

asciidoctor-community-docs

Process, policy, and other shared documentation for the Asciidoctor community of projects.
3
star
76

docker-asciidoctorj

Ensure that AsciidoctorJ can be used by apps into a Java Application Server (WildFly AS for now)
Java
3
star
77

asciidoctorj-chart

AsciidoctorJ Chart bundles the Asciidoctor Chart RubyGem (asciidoctor-chart) so it can be loaded into the JVM using JRuby.
HTML
3
star
78

asciidoctor-grunt-plugin

A Grunt plugin that uses Asciidoctor via Asciidoctor.js to process AsciiDoc source files within the project.
HTML
2
star
79

asciidoctor-rpm-mirror

A mirror of the package spec for the rubygem-asciidoctor (alias: asciidoctor) rpm. DO NOT PUSH CHANGES TO THIS MIRROR.
Ruby
2
star
80

default-to-asciidoc-chrome-extension

You love AsciiDoc and you want it to be the default option, this extension is for you!
JavaScript
2
star
81

asciidoctorj-epub3

AsciidoctorJ EPUB3 bundles the Asciidoctor EPUB3 RubyGem (asciidoctor-epub3) so it can be loaded into the JVM using JRuby.
Java
1
star
82

asciidoctor-docbook45

!DEPRECATED! An Asciidoctor converter that converts AsciiDoc to DocBook 4.5. This converter is community maintained and will not be released. Use the built-in DocBook 5 converter instead.
Ruby
1
star