omtex
aien-dev/omtex
Brought by drakestapleton
omtex / examples / listings / paper.om
| 1 | note omtex feature tour: Omega listings checked by the pinned compiler, math, a table, a figure, citations. |
| 2 | note Build: tools/build.sh examples/listings/paper.om (the listing check runs as part of the build) |
| 3 | text cls "article" |
| 4 | text clso "11pt" |
| 5 | text pfont "fontenc" |
| 6 | text pfonto "T1" |
| 7 | text pgeo "geometry" |
| 8 | text pgeoo "margin=1in" |
| 9 | text pams "amsmath" |
| 10 | text pgfx "graphicx" |
| 11 | text phyp "hyperref" |
| 12 | text phypo "hidelinks" |
| 13 | text ttl "Writing papers in Omega with omtex" |
| 14 | text who "omtex examples" |
| 15 | text when "October 2026" |
| 16 | text abs "This paper is an Omega program. Every byte of its LaTeX was written by checked Omega code, every special character was escaped or refused, and every Omega listing below was compiled by the pinned seeded compiler while the paper was built." |
| 17 | text s1 "Listings that must compile" |
| 18 | text l1 "sec:listings" |
| 19 | text p1 "An `omlisting` is compiled with the pinned `omc` when the paper is built with `check`. Listing[#lst:add3] must compile; the build fails otherwise." |
| 20 | text c1 "Adding three" |
| 21 | text k1 "lst:add3" |
| 22 | text b1 "note add three to a number\nfn add3 x ulong to ulong\nret add x 3\nend\nfn main to int\nret int sub add3 4 7\nend\n" |
| 23 | text p2 "A listing can also state that the compiler must *refuse* it, and with which error. Listing[#lst:dead] has a statement after `ret`, which is error 17." |
| 24 | text c2 "Refused: a line after `ret` (error 17)" |
| 25 | text k2 "lst:dead" |
| 26 | text b2 "fn main to int\nret 0\nret 1\nend\n" |
| 27 | text p3 "A fragment is shown but explicitly not compiled; the check reports it as NOT_CHECKED." |
| 28 | text c3 "A fragment" |
| 29 | text k3 "lst:frag" |
| 30 | text b3 "i = add i 1\n" |
| 31 | text p4 "Other languages use `codelang` and `listing`:" |
| 32 | text sh "sh" |
| 33 | text c4 "Building this paper" |
| 34 | text k4 "lst:build" |
| 35 | text b4 "tools/build.sh examples/listings/paper.om\n" |
| 36 | text s2 "Mathematics" |
| 37 | text l2 "sec:math" |
| 38 | text l3 "sec:more" |
| 39 | text p5 "Inline math such as $e^{i\\pi} + 1 = 0$ is checked: braces must balance, and $\\%$, $\\$$ and $\\#$ only appear escaped. Display math:" |
| 40 | text m1 "\\int_0^1 x^2 \\, dx = \\frac{1}{3}" |
| 41 | text k5 "eq:int" |
| 42 | text p6 "Equation[#eq:int] was checked with Wolfram Language (`Integrate[x^2,{x,0,1}]` gives 1/3). An aligned pair:" |
| 43 | text m2 "(a+b)^2 &= a^2 + 2ab + b^2 \\\\\n(a-b)^2 &= a^2 - 2ab + b^2" |
| 44 | text s3 "Tables, figures and citations" |
| 45 | text p7 "Table[#tab:esc] lists what prose characters become. Figure[#fig:ex] is a stock image. Information theory begins with Shannon[@shannon48]; the listing style follows the `listings` manual[@listings]." |
| 46 | text tc "Prose characters and their LaTeX" |
| 47 | text tk "tab:esc" |
| 48 | text ts "ll" |
| 49 | text h1 "Prose" |
| 50 | text h2 "LaTeX" |
| 51 | text r1a "`50% & 3_x #1 {a}`" |
| 52 | text r1b "`50\\% \\& 3\\_x \\#1 \\{a\\}`" |
| 53 | text r2a "`*word*` and `**word**`" |
| 54 | text r2b "`\\emph{word}` and `\\textbf{word}`" |
| 55 | text r3a "`[@key]` and `[#label]`" |
| 56 | text r3b "`~\\cite{key}` and `~\\ref{label}`" |
| 57 | text fp "example-image" |
| 58 | text fc "A stock image from the `mwe` package." |
| 59 | text fk "fig:ex" |
| 60 | text e1 "shannon48" |
| 61 | text e1t "C. E. Shannon. A mathematical theory of communication. *Bell System Technical Journal*, 27(3):379--423, 1948." |
| 62 | text e2 "listings" |
| 63 | text e2t "C. Heinz, B. Moses and J. Hoffmann. *The Listings Package*. CTAN, 2024." |
| 64 | fn main to int |
| 65 | docclass clso cls |
| 66 | usepkgo pfonto pfont |
| 67 | usepkgo pgeoo pgeo |
| 68 | usepkg pams |
| 69 | usepkg pgfx |
| 70 | usepkgo phypo phyp |
| 71 | omlang |
| 72 | title ttl |
| 73 | author who |
| 74 | date when |
| 75 | begindoc |
| 76 | maketitle |
| 77 | docabstract abs |
| 78 | sectionl s1 l1 |
| 79 | para p1 |
| 80 | omlisting c1 k1 b1 |
| 81 | para p2 |
| 82 | omrefuse 17 |
| 83 | omlisting c2 k2 b2 |
| 84 | para p3 |
| 85 | omfragment c3 k3 b3 |
| 86 | para p4 |
| 87 | codelang sh |
| 88 | listing c4 k4 b4 |
| 89 | sectionl s2 l2 |
| 90 | prose p5 |
| 91 | equationl k5 m1 |
| 92 | parbreak |
| 93 | prose p6 |
| 94 | align m2 |
| 95 | sectionl s3 l3 |
| 96 | para p7 |
| 97 | table tc tk ts |
| 98 | hline |
| 99 | cell h1 |
| 100 | cell h2 |
| 101 | row |
| 102 | hline |
| 103 | cell r1a |
| 104 | cell r1b |
| 105 | row |
| 106 | cell r2a |
| 107 | cell r2b |
| 108 | row |
| 109 | cell r3a |
| 110 | cell r3b |
| 111 | row |
| 112 | hline |
| 113 | endtable |
| 114 | figure fp fc fk |
| 115 | bibbegin |
| 116 | bibitem e1 e1t |
| 117 | bibitem e2 e2t |
| 118 | endlist |
| 119 | enddoc |
| 120 | ret 0 |
| 121 | end |