# 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 std::tuple mymodule::hassome::foo() { return std::make_tuple(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. \begin{equation} i_{a} = 15 \end{equation} --- $$ \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{ 04\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}