imag/doc/src/pandoc-reference

171 lines
4 KiB
Text
Raw Normal View History

2016-01-07 21:25:17 +00:00
<!--
The following file is not included in the output and is just included in the
repository as a quick reference how things are formatted with pandoc-markdown
-->
# Code examples {#sec:codeexamples}
In @sec:codeexamples we show some code examples.
```{#lst:mypython .python .numberLines caption="Python"}
def foo():
return 1;
```
With some Python code in @lst:mypython
```{#lst:myruby .ruby .numberLines caption="Ruby"}
def foo
1
end
```
With some Ruby code in @lst:myruby
``` {#lst:myc .c .numberLines caption="C"}
int
foo() {
return 1;
}
```
and Some C code in @lst:myc.
Aaah, and some `C++`:
``` {#mycpp .cpp .numberLines caption="C++"}
template <typename T>
std::tuple<T, T> mymodule::hassome::foo()
{
return std::make_tuple<T, T>(1, 1);
} // I don't even know whether this works
```
And, of course, because pandoc:
~~~~ {#mycode .haskell .numberLines startFrom="100" caption="Haskell"}
qsort [] = []
qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++
qsort (filter (>= x) xs)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Table examples
Pandoc has several extensions for tables, we have them all here:
## Simple tables
This is an example for simple tables (@tbl:simple).
Right Left Center Default
------- ------ ---------- -------
12 12 12 12
123 123 123 123
1 1 1 1
Table: Demonstration of simple table syntax. {#tbl:simple}
------- ------ ---------- -------
12 12 12 12
123 123 123 123
1 1 1 1
------- ------ ---------- -------
And some more go here (in @tbl:more):
-------------------------------------------------------------
Centered Default Right Left
Header Aligned Aligned Aligned
----------- ------- --------------- -------------------------
First row 12.0 Example of a row that
spans multiple lines.
Second row 5.0 Here's another one. Note
the blank line between
rows.
-------------------------------------------------------------
Table: Here's the caption. It, too, may span
multiple lines. {#tbl:more}
## Grid tables
: Sample grid table.
+---------------+---------------+--------------------+
| Fruit | Price | Advantages |
+===============+===============+====================+
| Bananas | $1.34 | - built-in wrapper |
| | | - bright color |
+---------------+---------------+--------------------+
| Oranges | $2.10 | - cures scurvy |
| | | - tasty |
+---------------+---------------+--------------------+
## Pipe tables
| Right | Left | Default | Center |
|------:|:-----|---------|:------:|
| 12 | 12 | 12 | 12 |
| 123 | 123 | 123 | 123 |
| 1 | 1 | 1 | 1 |
: Demonstration of pipe table syntax.
# Some maths
This is simply embedded tex. It renders both in the PDF version
and the HTML version of the output.
Greek letters are not supported by this setup, though.
<!-- This way, the equation is numbered, but does not appear in the HTML -->
\begin{equation}
i_{a} = 15
\end{equation}
---
<!-- This way, the equation is not numbered, but appears in both pdf and HTML -->
$$ \forall x \in X, \quad \exists y \leq \epsilon $$ {#eq:foo}
In @eq:foo we show something.
---
$$ \frac{n!}{k!(n-k)!} = \binom{n}{k} $$ {#eq:bar}
---
$$ \displaystyle\sum_{i=1}^{10} t_i $$ {#eq:barbar}
---
$$ \sum_{\substack{
0<i<m \\
0<j<n
}}
P(i,j) $$ {#eq:foofoo}
---
$$ P\left(A=2\middle|\frac{A^2}{B}>4\right) $$ {#eq:somethingelse}
---
$$ A_{m,n} =
\begin{pmatrix}
a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\
a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\
\vdots & \vdots & \ddots & \vdots \\
a_{m,1} & a_{m,2} & \cdots & a_{m,n}
\end{pmatrix} $$ {#eq:somethingelseagain}