interplane.Get Omega
Read in your language

omtex

aien-dev/omtex

Brought by drakestapleton

branch main Branches Tags History

omtex / examples / listings / paper.om

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