AsciiDoc is currently the most supported formatting language within Courses.
In addition to extensive formatting options, it allows for the use of variables, conditional rendering blocks, and more.
This page lists the basic and most commonly used elements.
The complete syntax can be found in the official documentation.
AsciiDoc files are saved with the .adoc extension.
The page title in the navigation bar is specified using the title element (see point 1 of the Metadata and attributes section).
Metadata and attributes
Each page can define various variables (attributes) that you can use to affect, for example, the page title, appearance, and so on.
A sample page may look as follows:
= Annotation 1:toc:2:imagesdir: ./media/ 3:course-guarantor: doc. Kevin Flynn 4
The course covers the fundamental principles of life.
The course guarantor is link:{course-guarantor}[]. 5
Page title. Each page must have exactly one title. This title is also displayed in the navigation bar.
Enable Table of Contents (can be disabled by omitting this line).
Path to the image directory (optional). For more information, see Images.
Headings are an integral part of the page.
Among other things, they are used to automatically generate content. More on this is shown in Metadata and attributes.
Formatting name
Input text
Resulting text
Heading level 1
== Heading level 1
Heading level 1
Heading level 2
=== Heading level 2
Heading level 2
Heading level 3
==== Heading level 3
Heading level 3
Heading level 4
===== Heading level 4
Heading level 4
You can assign any ID to headings.
This will then appear in the URL when you click on the heading.
It also makes it easy to link to it; see the example.
Example of using a heading ID
I will create a heading with the custom ID video.
[#video]== Lecture recordings
On this page you will find a list of lecture recordings.
Later on the page I can conveniently reference the section marked this way.
See Links for more.
All lectures within this course are <<+++video+++, recorded>>.
Store images in the designated folder[1]. Otherwise, the image would be automatically added as a separate page in the side navigation.
Optional[2] – In the page header, specify the folder in which AsciiDoc should look for images.
Do this using :imagesdir: <relative path to the folder>.
See point 3 of the Metadata and attributes section.
Examples of inserting images:
Example name
Input text
Regular image
image::image.jpg[Alternative text]
Image with caption
.This is a caption that will be displayed together with the image
image::image.jpg[Alternative text]
Image with alignment
image::image.jpg[Alternative text, align=left]
Other attributes that can be used to modify image rendering include:
Code can be written on a single line – for example, `text` will be rendered as text.
For multi-line code, see the following example:
[source, c]----
airplane_t *strip = NULL;
strip = (airplane_t *) malloc(n * sizeof(*strip));
long int j = 0;
for (long int i = 0; i < n; i++)
if (abs(P[i].x - midPoint.x) < d)
strip[j] = P[i], j++;
----
It will be rendered as:
airplane_t *strip = NULL;
strip = (airplane_t *) malloc(n * sizeof(*strip));
longint j = 0;
for (longint i = 0; i < n; i++)
if (abs(P[i].x - midPoint.x) < d)
strip[j] = P[i], j++;
The [source, <language>] line handles syntax highlighting. Any language can be substituted for <language>.
Omitting this line will disable syntax highlighting for the code.
The following code can be used to create a tabbed navigation bar.
[tabbed] 1Arch Linux:: 2+
The first line of the Arch Linux tab.
+
The second line.
3Debian / Ubuntu::
+
The first line of the Debian / Ubuntu tab.
+
The second line.
Fedora::
+
The first line of the Fedora tab, which also contains source code:
+
[source, c]----
airplane_t *strip = NULL;
strip = (airplane_t *) malloc(n * sizeof(*strip));
----openSUSE::
+
The first line of the openSUSE tab.
+
The second line.
The block with tabbed navigation must be marked [tabbed].
The tab name can be anything, but it must end with ::, e.g. Arch Linux::.
Individual tabs are separated by a blank line.
It will be rendered as:
Arch Linux
The first line of the Arch Linux tab.
The second line.
Debian / Ubuntu
The first line of the Debian / Ubuntu tab.
The second line.
Fedora
The first line of the Fedora tab, which also contains source code:
A special use case for tabbed navigation is inside a list, see the following example.
. Fill in the following fields:
+
[tabbed]
Incoming mail server::
* Protocol: `IMAP`
* Server: `{mail-imap}`
* Port: `{mail-port-imap}`
* Connection security: `SSL/TLS`
* Authentication method: `OAuth2`
Outgoing mail server::
* Protocol: `SMTP`
* Server: `{mail-smtp}`
* Port: `{mail-port-smtp}`
* Connection security: `STARTTLS`
* Authentication method: `OAuth2`
+
If the authentication method menu does not include `OAuth2`, first click btn:[Retest].
Then continue with btn:[Done].
. In the pop-up window, log in with `<username>@**cvut.cz**` and xref:../../accounts/index.adoc[the CTU password].
Blocks (admonitions)
Important:
This is a block containing important information. The block name is IMPORTANT.
Caution:
This is a block containing information that should be read carefully. The block name is CAUTION.
Warning:
This is a block containing a strong warning about imminent danger. The block name is WARNING.
Below is an example of a single-line block. Instead of NOTE, you can substitute any block type, see the names above.
Source code
NOTE: This is a block containing a note. The block name is `NOTE`.
Result
Blocks can also be multi-line; instead of IMPORTANT, you can substitute any block type, see the names above.
Source code
[IMPORTANT]
====
This is a block containing important information.
- the block name is `IMPORTANT`
- it is multi-line
- and it can also contain more complex structures (such as this list)
====
Result
Important:
This is a block containing important information.
the block name is IMPORTANT
it is multi-line
and it can also contain more complex structures (such as this list)
Likewise, a block can have its own title.
Source code
[TIP].This is a block with a title
====
Additional block text.
====
A specific footnote can be referenced multiple times.
Create a footnote using footnote:<footnote-id>[<footnote-text>].
You can reference an existing footnote using footnote:<footnote-id>[].
Replace <footnote-id> with any footnote identifier.
Optional: List of attributes. The %header" attribute marks the first row as the table header. cols="1,1,2" specifies three columns, where the third is twice as wide.
Required: The table must be enclosed by the string |===.
Individual table rows in the source code are separated by a blank line.
To use mathematical expressions and formulas entered using La/TeX syntax on the page, we must correctly set the document’s stem attribute to latexmath.
This can be easily done as follows:
= Page with mathematical expressions 1:stem: latexmath 2
Document/page title.
Set the stem attribute to latexmath.
Courses use KaTeX to render mathematical expressions in the final output.
This is a tool that allows mathematical expressions written in La/TeX syntax to be displayed on the web.
It was originally created for Khan Academy.
KaTeX does not support absolutely all mathematical features and packages known from La/TeX or AMSTeX, but its capabilities are fully sufficient for most users and problems.
The exact list of supported macros and environments is given in the KaTeX documentation.
Equations in text
To create mathematical expressions appearing directly in the text (inline math), you can use the stem macro.
For example, we might want to discuss the properties of the function f(x)=sin(x) or talk about the sequence (n+1)n=1∞.
The source code of such a sentence with mathematical expressions looks like this:
For example, we might want to discuss the properties of the function stem:[f(x) = \sin(x)]
or talk about the sequence stem:[(n+1)_{n=1}^\infty].
The stem macro is therefore practically equivalent to LaTeX math mode enclosed in two $ symbols.
However, we must pay attention to the closing square bracket that marks the optional parameters of some LaTeX macros; for example, the cube root of two, 32, is written correctly using
stem:[\sqrt[3\]{2}] 1
Notice \] instead of ].
Standalone equations
To typeset a larger equation that needs to stand on its own line, we use a block enclosed by four + symbols (the content of this block is not modified in any way and is sent directly to KaTeX; passthrough block) with the stem style.
For example, the equation
k=1∑∞k=−121,
was created using the code
[stem] 1++++ 2 \sum_{k=1}^\infty k = -\frac{1}{12}\,, 3++++ 4
stem style.
Start of the block.
Content of the block with mathematical LaTeX notation.
End of the block.
Such a block therefore corresponds to the standard unnumbered LaTeX equation* environment, or to LaTeX math mode enclosed by \[ and \].
Often, however, we need to typeset several equations at once and want to align them nicely.
For that, we can use the aligned environment.
The following system of two equations in two variables
Use of the aligned macro to align multiple equations.
We use the & symbol to align equations and \\ to separate them.
In KaTeX, besides the aligned macro, there is another macro known from AMSTeX, gathered, which allows typesetting of multi-line centered equations without alignment, for example
Use of the gathered macro to center a multi-line equation.
We use \\ to break the equation.
More math tips and tricks
References to equations
In mathematical text, it is customary to refer to some (numbered) equations.
However, KaTeX/AsciiDoc/Course Pages do not directly support the LaTeX macros label and eqref, respectively ref.
We can, however, work around this quite easily because KaTeX supports the tag macro.
We mark the relevant block containing the equation we want to reference with an ID, add a tag to the equation, and use the AsciiDoc xref macro in the reference.
For example, the following equation
In equation (1) (reference created using xref:eq1[(1)]), the attentive reader will surely recognize Newton’s formula.
Highlighting parts of equations
To draw attention to important parts of an equation, we can use braces (the underbrace macro) or even colors (the color macro), for example in the equation
△(acbd)−1=ad−bc1(d−c−ba).
we marked the matrix on the left side with a triangle (△) and the expression in the denominator on the right side in red.
The code used is as follows:
[stem]
++++
\underbrace{ 1
\begin{pmatrix}
a & b \\
c & d
\end{pmatrix}^{-1}
}_{\triangle}
=
\frac{1}{\color{red}ad-bc} \begin{pmatrix} 2
d & -b \\
-c & a
\end{pmatrix}.
++++
The underbrace macro.
The color macro.
Definitions, theorems and proofs
In more formal mathematical texts, it is customary to typographically separate important parts such as Definitions, Theorems, and so on.
In LaTeX, the well-known amsthm package exists for this purpose.
In AsciiDoc/Courses, we can use, for example, a named block intended for a quotation to create such a typographical separation.
Below is one specific example of this approach.
Fundamental Theorem of Algebra
Every polynomial of degree n∈N has at most n complex roots.
The code used to create this highlighted section is as follows:
.Fundamental Theorem of Algebra 1
[#Veta1] 2____3
Every polynomial of degree stem:[n \in \mathbb{N}] has at most stem:[n] complex roots.
____
Title.
id used to reference the theorem in the text.
Block enclosed by four underscores.
For the ceremonial marking of the end of a proof, mathematical literature usually uses the Halmos tombstone□, or a square.
This can be created with KaTeX using the code stem:[\square].
Alternatively, of course, a plain text abbreviation Q.E.D. can be used.
Diagrams
The course-pages generator integrates the Kroki diagram generator.
This allows it to render many different kinds of diagrams, such as WaveDrom, Graphviz, and many others.
Just as with source code, the diagram code must be placed in a block, and the diagram type must be placed in square brackets above the block.
By default, this is the media or files folder, but the name may vary depending on the configuration of the given project. ↩
If you do not specify the :imagesdir: attribute, you will need to provide the full path for each image. ↩
Microsoft OneDrive also provides advanced methods for access management and permission assignment. ↩
Outside paths that are hidden by settings – the hiddenFiles and excludedFiles settings in the configuration file. Typically the media or files folders. ↩
Alternatively, you can number in reverse order using the %reversed flag ↩
Instead of // <1>, you can use for example # <1>, ;; <1>, <!--1-->. The marker should be a valid comment in the given language. ↩