pandoc-reference 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <!--
  2. The following file is not included in the output and is just included in the
  3. repository as a quick reference how things are formatted with pandoc-markdown
  4. -->
  5. # Code examples {#sec:codeexamples}
  6. In @sec:codeexamples we show some code examples.
  7. ```{#lst:mypython .python .numberLines caption="Python"}
  8. def foo():
  9. return 1;
  10. ```
  11. With some Python code in @lst:mypython
  12. ```{#lst:myruby .ruby .numberLines caption="Ruby"}
  13. def foo
  14. 1
  15. end
  16. ```
  17. With some Ruby code in @lst:myruby
  18. ``` {#lst:myc .c .numberLines caption="C"}
  19. int
  20. foo() {
  21. return 1;
  22. }
  23. ```
  24. and Some C code in @lst:myc.
  25. Aaah, and some `C++`:
  26. ``` {#mycpp .cpp .numberLines caption="C++"}
  27. template <typename T>
  28. std::tuple<T, T> mymodule::hassome::foo()
  29. {
  30. return std::make_tuple<T, T>(1, 1);
  31. } // I don't even know whether this works
  32. ```
  33. And, of course, because pandoc:
  34. ~~~~ {#mycode .haskell .numberLines startFrom="100" caption="Haskell"}
  35. qsort [] = []
  36. qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++
  37. qsort (filter (>= x) xs)
  38. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  39. # Table examples
  40. Pandoc has several extensions for tables, we have them all here:
  41. ## Simple tables
  42. This is an example for simple tables (@tbl:simple).
  43. Right Left Center Default
  44. ------- ------ ---------- -------
  45. 12 12 12 12
  46. 123 123 123 123
  47. 1 1 1 1
  48. Table: Demonstration of simple table syntax. {#tbl:simple}
  49. ------- ------ ---------- -------
  50. 12 12 12 12
  51. 123 123 123 123
  52. 1 1 1 1
  53. ------- ------ ---------- -------
  54. And some more go here (in @tbl:more):
  55. -------------------------------------------------------------
  56. Centered Default Right Left
  57. Header Aligned Aligned Aligned
  58. ----------- ------- --------------- -------------------------
  59. First row 12.0 Example of a row that
  60. spans multiple lines.
  61. Second row 5.0 Here's another one. Note
  62. the blank line between
  63. rows.
  64. -------------------------------------------------------------
  65. Table: Here's the caption. It, too, may span
  66. multiple lines. {#tbl:more}
  67. ## Grid tables
  68. : Sample grid table.
  69. +---------------+---------------+--------------------+
  70. | Fruit | Price | Advantages |
  71. +===============+===============+====================+
  72. | Bananas | $1.34 | - built-in wrapper |
  73. | | | - bright color |
  74. +---------------+---------------+--------------------+
  75. | Oranges | $2.10 | - cures scurvy |
  76. | | | - tasty |
  77. +---------------+---------------+--------------------+
  78. ## Pipe tables
  79. | Right | Left | Default | Center |
  80. |------:|:-----|---------|:------:|
  81. | 12 | 12 | 12 | 12 |
  82. | 123 | 123 | 123 | 123 |
  83. | 1 | 1 | 1 | 1 |
  84. : Demonstration of pipe table syntax.
  85. # Some maths
  86. This is simply embedded tex. It renders both in the PDF version
  87. and the HTML version of the output.
  88. Greek letters are not supported by this setup, though.
  89. <!-- This way, the equation is numbered, but does not appear in the HTML -->
  90. \begin{equation}
  91. i_{a} = 15
  92. \end{equation}
  93. ---
  94. <!-- This way, the equation is not numbered, but appears in both pdf and HTML -->
  95. $$ \forall x \in X, \quad \exists y \leq \epsilon $$ {#eq:foo}
  96. In @eq:foo we show something.
  97. ---
  98. $$ \frac{n!}{k!(n-k)!} = \binom{n}{k} $$ {#eq:bar}
  99. ---
  100. $$ \displaystyle\sum_{i=1}^{10} t_i $$ {#eq:barbar}
  101. ---
  102. $$ \sum_{\substack{
  103. 0<i<m \\
  104. 0<j<n
  105. }}
  106. P(i,j) $$ {#eq:foofoo}
  107. ---
  108. $$ P\left(A=2\middle|\frac{A^2}{B}>4\right) $$ {#eq:somethingelse}
  109. ---
  110. $$ A_{m,n} =
  111. \begin{pmatrix}
  112. a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\
  113. a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\
  114. \vdots & \vdots & \ddots & \vdots \\
  115. a_{m,1} & a_{m,2} & \cdots & a_{m,n}
  116. \end{pmatrix} $$ {#eq:somethingelseagain}