├── images ├── ex.jpg ├── odot.jpg ├── set1.jpg ├── set2.jpg ├── arrows.jpg ├── cases.jpg ├── frac1.jpg ├── frac2.jpg ├── subpow.jpg ├── xzero.jpg ├── complex.jpg ├── substack.jpg ├── bigexample.jpg ├── fancymatrix.jpg ├── trigtabular.jpg ├── simplematrix.jpg └── numeratedmatrix.jpg ├── LICENSE ├── README.md └── teknote.lua /images/ex.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/punk0x29a/teknote/HEAD/images/ex.jpg -------------------------------------------------------------------------------- /images/odot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/punk0x29a/teknote/HEAD/images/odot.jpg -------------------------------------------------------------------------------- /images/set1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/punk0x29a/teknote/HEAD/images/set1.jpg -------------------------------------------------------------------------------- /images/set2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/punk0x29a/teknote/HEAD/images/set2.jpg -------------------------------------------------------------------------------- /images/arrows.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/punk0x29a/teknote/HEAD/images/arrows.jpg -------------------------------------------------------------------------------- /images/cases.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/punk0x29a/teknote/HEAD/images/cases.jpg -------------------------------------------------------------------------------- /images/frac1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/punk0x29a/teknote/HEAD/images/frac1.jpg -------------------------------------------------------------------------------- /images/frac2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/punk0x29a/teknote/HEAD/images/frac2.jpg -------------------------------------------------------------------------------- /images/subpow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/punk0x29a/teknote/HEAD/images/subpow.jpg -------------------------------------------------------------------------------- /images/xzero.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/punk0x29a/teknote/HEAD/images/xzero.jpg -------------------------------------------------------------------------------- /images/complex.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/punk0x29a/teknote/HEAD/images/complex.jpg -------------------------------------------------------------------------------- /images/substack.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/punk0x29a/teknote/HEAD/images/substack.jpg -------------------------------------------------------------------------------- /images/bigexample.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/punk0x29a/teknote/HEAD/images/bigexample.jpg -------------------------------------------------------------------------------- /images/fancymatrix.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/punk0x29a/teknote/HEAD/images/fancymatrix.jpg -------------------------------------------------------------------------------- /images/trigtabular.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/punk0x29a/teknote/HEAD/images/trigtabular.jpg -------------------------------------------------------------------------------- /images/simplematrix.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/punk0x29a/teknote/HEAD/images/simplematrix.jpg -------------------------------------------------------------------------------- /images/numeratedmatrix.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/punk0x29a/teknote/HEAD/images/numeratedmatrix.jpg -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 punk0x29a 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TekNote 2 | 3 | #### Summary: 4 | 5 | TekNote is a small Lua script designed to render taking quick notes in LaTeX easy and affordable. 6 | Its goal is help people with atrocious handwriting to have beautiful notes on their computers without being distracted. 7 | Taking notes in plain LaTeX is hard and demanding. TekNote language is, by comparison, very simple. 8 | It is great for taking notes on lectures, since there's a lot less rules to rememeber. 9 | Furthermore, it allows one to write very lazy code without worrying about its viability. 10 | 11 | TekNote language won't, of course, give one as much possibilities as plain LaTeX, and it is not designed to be this way. 12 | For serious purposes, like writing a book or a scientific paper, one still needs to learn real LaTeX. 13 | TekNote gets really useful (and powerful) only when it comes to writing quick notes in a fast-paced environment. 14 | 15 | Script translates expression from TekNote micro-language into proper LaTeX code, ready to copy and paste into the renderer. 16 | Because of this nature it's perfectly sane to embed real LaTeX into TekNote's expression, which is extremely useful when one needs some of its rich features. 17 | 18 | TekNote is designed to work with [ZIM](http://zim-wiki.org/) coupled with [Equation Editor Plugin](http://zim-wiki.org/manual/Plugins/Equation_Editor.html) and was thoroughly tested on it. 19 | 20 | #### Usage: 21 | 22 | One needs lua52 to launch TekNote: 23 | 24 | ``` 25 | $ lua52 teknote.lua 26 | ``` 27 | where $ sign indicates command prompt. 28 | 29 | Name in which Lua interpreter is named may vary from system to system, but it's usually `lua52` or just `lua`. 30 | 31 | By default TekNote launches in an interactive mode, but it's very *rudimentary*. 32 | It's highly recommended to make separate function in, for example, ~/.bashrc : 33 | 34 | ``` 35 | function teknote() 36 | { 37 | vim ~/.math_expression && lua52 ~/path/to/teknote.lua < ~/.math_expression 38 | } 39 | ``` 40 | Where `~/path/to/latexnote.lua` must be replaced with TekNote's real location. 41 | `~/.math_expression` must be a name of a real temporary file used for work. 42 | `vim` may be replaced with a text editor of your choice. 43 | 44 | Such a function will 45 | + Enter text editor, where one will edit temporary file 46 | + Redirect resulting file as an input for TekNote 47 | + TekNote will then give back results ready for copy and paste into the renderer. 48 | 49 | #### Command Line Options: 50 | 51 | See 52 | 53 | `$ lua52 teknote.lua --help` 54 | 55 | for a complete list. 56 | It's good to read through it, because most of the functions have some redundant aliases or syntactic sugars worth knowing of. 57 | 58 | #### Basics: 59 | 60 | TekNote expression consists of tokens separated by spaces. 61 | Text editor with a feature of showing hidden symbols is very useful to track them. 62 | 63 | There are three types of special tokens: 64 | 65 | `.` - Line containing only a sigle dot signals end of expression. 66 | 67 | This peculiar type of EOF sign has proven itself to be useful when one made a terrible mistake and wanted to translate only a part of an expression and left the rest for debugging later on. 68 | 69 | Inserting line containing only `.` at the end of expression is mandatory. 70 | 71 | `##` - Double hash sign signals beggining of a comment. TekNote will ignore everything until it'll encounter corresponding `##` 72 | 73 | `expr` or `{{` is used for embedding functions in other functions. See examples below for clarification. 74 | Both can be used interchangeably. 75 | 76 | `end` or `}}` is used for ending functions scope. 77 | Both can be used interchangeably. 78 | 79 | One does not need to end function scope if it's the last function in file. 80 | Similarly - if there are many such opened functions at a very end of expression one does not need to end them at all. 81 | 82 | #### Functions: 83 | 84 | 85 | ##### Matrix: 86 | 87 | Matrix function is used for creating matrices. There are six types of them: 88 | 89 | `matrix` - create plain matrix. 90 | `(matrix` - create matrix with parentheses. 91 | `{matrix` - create matrix with brackets. 92 | `[matrix` - create matrix with square brackets. 93 | `|matrix` - create matrix with vertical bar. 94 | `||matrix` - create matrix with two vertical bars. 95 | 96 | For example: 97 | 98 | ``` 99 | matrix a b c 100 | d e f 101 | g h i 102 | . 103 | ``` 104 | 105 | gives 106 | 107 | 108 | ``` 109 | \begin{matrix} a & b & c \\ d & e & f \\ g & h & i\end{matrix} 110 | ``` 111 | 112 | and, consequently 113 | 114 | ![Matrix](https://raw.githubusercontent.com/punk0x29a/teknote/master/images/simplematrix.jpg?raw=true "Simple Matrix") 115 | 116 | For more complicated example: 117 | 118 | ``` 119 | ||matrix alpha beta gamma 120 | RR ZZ CC 121 | {{ intl a b {{ sin pow 2 (x) }} }} {{ intl a b {{ sum 0 oo ( 1 / n ) }} end expr aleph sub 0 }} 122 | ``` 123 | 124 | will give 125 | 126 | 127 | ``` 128 | \begin{Vmatrix} \alpha & \beta & \gamma \\ \mathbb{R} & \mathbb{Z} & \mathbb{C} \\ \: \int\limits_{a}^{b}\: \: \sin ^{2}\: (x)\: \: & \: \int\limits_{a}^{b}\: \: \sum_{0}^{\infty }\: {{\: 1\: }\over{\: n\: }}\: \: & \: \aleph _{0}\: \end{Vmatrix} 129 | ``` 130 | 131 | and, consequently 132 | 133 | ![Fancy Matrix](https://raw.githubusercontent.com/punk0x29a/teknote/master/images/fancymatrix.jpg?raw=true "Fancy Matrix") 134 | 135 | 136 | `amatrix` is a special type of matrix, because it features element numeration. 137 | `amatrix` must be followed by a matrix type. 138 | 139 | ``` 140 | amatrix matrix a 1 1 a 1 2 ... a 1 n 141 | a 2 1 a 2 2 ... a 2 n 142 | v... v... d... v... 143 | a m 1 a m 2 ... a m n 144 | . 145 | 146 | ``` 147 | 148 | gives 149 | 150 | ``` 151 | \begin{matrix} 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{matrix} 152 | ``` 153 | 154 | which renders to 155 | 156 | ![Element numeration](https://raw.githubusercontent.com/punk0x29a/teknote/master/images/numeratedmatrix.jpg?raw=true "Numerated Matrix") 157 | 158 | 159 | 160 | ##### Tabular: 161 | 162 | `tabular` is used for making tables. It's a shorthand for an array environment. 163 | Altough this function needs some attention in order to make it more viable, it's pretty useful even now. 164 | 165 | ``` 166 | tabular phi {{ 0 pow o }} {{ 30 pow o }} {{ 45 pow o }} {{ 60 pow o }} {{ 90 pow o }} 167 | {{ sin phi }} 0 {{ ( 1 / 2 ) }} {{ ( 1 / sqrt 2 ) }} {{ ( sqrt 3 / 2 ) }} 1 168 | {{ cos phi }} 1 {{ ( sqrt 3 / 2 ) }} {{ ( 1 / sqrt 2 ) }} {{ ( 1 / 2 ) }} 0 169 | . 170 | ``` 171 | 172 | gives 173 | 174 | 175 | ``` 176 | \begin{array}{ c|c|c|c|c|c|c} \phi & \: 0^{\circ }\: & \: 30^{\circ }\: & \: 45^{\circ }\: & \: 60^{\circ }\: & \: 90^{\circ }\: \\ \hline \: \sin \: \phi \: & 0 & \: {{\: 1\: }\over{\: 2\: }}\: & \: {{\: 1\: }\over{\: \sqrt[]{2}\: }}\: & \: {{\: \sqrt[]{3}\: }\over{\: 2\: }}\: & 1 \\ \hline \: \cos \: \phi \: & 1 & \: {{\: \sqrt[]{3}\: }\over{\: 2\: }}\: & \: {{\: 1\: }\over{\: \sqrt[]{2}\: }}\: & \: {{\: 1\: }\over{\: 2\: }}\: & 0 \\ \hline \end{array} 177 | 178 | ``` 179 | 180 | and, consequently 181 | 182 | ![Tabular](https://raw.githubusercontent.com/punk0x29a/teknote/master/images/trigtabular.jpg?raw=true "Tabular for sin and cos") 183 | 184 | 185 | ##### Cases: 186 | 187 | `cases` environment is useful when writing down, in.e., functions definitions: 188 | 189 | 190 | ``` 191 | f(x) = cases 1 if x < 0 192 | 0 if x = 0 193 | -1 if x > 0 194 | . 195 | ``` 196 | 197 | translates to 198 | 199 | ``` 200 | f(x)\: =\: \begin{cases} 1\: \qquad if\: x\: <\: 0 \\ 0\qquad if\: x\: =\: 0 \\ -1\: \qquad if\: x\: >\: 0 \\ \end{cases} 201 | ``` 202 | 203 | that renders to: 204 | 205 | ![Cases](https://raw.githubusercontent.com/punk0x29a/teknote/master/images/cases.jpg?raw=true "Cases Example") 206 | 207 | 208 | ##### Sub, Pow and Substack 209 | 210 | These seem to be self-explanatory. 211 | 212 | ``` 213 | e pow {{ x pow 2 }} 214 | . 215 | ``` 216 | 217 | gives 218 | 219 | ``` 220 | e^{\: x^{2}\: } 221 | ``` 222 | 223 | that renders to 224 | 225 | ![E](https://raw.githubusercontent.com/punk0x29a/teknote/master/images/ex.jpg?raw=true "e to the power of x") 226 | 227 | Similarly, 228 | 229 | ``` 230 | x sub 0 = 1 231 | . 232 | ``` 233 | 234 | gives 235 | 236 | ``` 237 | x_{0}\: =\: 1 238 | ``` 239 | 240 | that renders to 241 | 242 | ![X](https://raw.githubusercontent.com/punk0x29a/teknote/master/images/xzero.jpg?raw=true "Where function meets x-axis") 243 | 244 | 245 | Those can be combined: 246 | 247 | ``` 248 | alpha sub beta pow gamma = gamma pow beta sub alpha 249 | . 250 | ``` 251 | 252 | gives 253 | 254 | ``` 255 | \alpha _{\beta }^{\gamma }\: =\: \gamma ^{\beta }_{\alpha } 256 | ``` 257 | 258 | that renders to 259 | 260 | ![Fancy](https://raw.githubusercontent.com/punk0x29a/teknote/master/images/subpow.jpg?raw=true "Fancy example") 261 | 262 | 263 | Example substack usage: 264 | 265 | ``` 266 | sum substack n=1 267 | k=0 end oo n pow k 268 | . 269 | ``` 270 | 271 | gives 272 | 273 | ``` 274 | \sum_{_{\substack{n=1 \\ k=0}} }^{\infty }\: n^{k} 275 | ``` 276 | 277 | that renders to: 278 | 279 | ![Substack](https://raw.githubusercontent.com/punk0x29a/teknote/master/images/substack.jpg?raw=true "Substack Example") 280 | 281 | 282 | ##### Limit (including Integral with limits), Binomial, Root, Sum, Product and Logarithm 283 | 284 | They all work pretty much the same. One needs to enter a and b factor, followed by an expression. 285 | Here's a big example: 286 | 287 | 288 | ``` 289 | log 2 4 = 2 290 | root 3 27 = 3 291 | () n k = binom n k 292 | lim x oo ( x ^ 2 / x ^ 2 + 1 ) = 1 293 | sum x=0 oo x = oo 294 | prod x=0 -oo x = 0 295 | . 296 | 297 | ``` 298 | 299 | translates to 300 | 301 | ``` 302 | \log_{2}{4}\: =\: 2 \\ \sqrt[3]{27}\: =\: 3 \\ \binom{ n}{k}\: = \binom{ n}{k} \\ \lim_{x\rightarrow \infty }\: {{\: x^{2}\: \: }\over{\: x^{2}\: +\: 1\: }}\: =\: 1 \\ \sum_{x=0}^{\infty }\: x\: =\: \infty \\ \prod_{x=0}^{-\infty}\: x\: =\: 0 \\ 303 | ``` 304 | 305 | which gives 306 | 307 | ![Big](https://raw.githubusercontent.com/punk0x29a/teknote/master/images/bigexample.jpg?raw=true "Big Example") 308 | 309 | 310 | ##### Fractions and parentheses 311 | 312 | Single parentheses are translated into `{` and `}` signs respectively, and are invisible in final image. 313 | To pronounce parentheses, one must use `((` and `))` for left and right parentheses. 314 | 315 | Fractions are abbreviated as follows: 316 | 317 | ``` 318 | ( x / (( x pow 2 + 1 )) pow 2 ) 319 | . 320 | ``` 321 | 322 | gives 323 | 324 | ``` 325 | {{\: x\: }\over{\: (\: x^{2}\: +\: 1\: )^{2}\: }} \\ 326 | ``` 327 | that renders to 328 | 329 | ![Fraction](https://raw.githubusercontent.com/punk0x29a/teknote/master/images/frac1.jpg?raw=true "Example Fraction") 330 | 331 | Such a fraction must be bound by single parentheses in every case. 332 | 333 | As for continous fractions: 334 | 335 | 336 | ``` 337 | // a b + // c d + // e f + // g h 338 | . 339 | ``` 340 | 341 | gives 342 | 343 | ``` 344 | \cfrac{a}{b+\cfrac{c}{d+\cfrac{e}{f+\cfrac{g}{h}}}} 345 | ``` 346 | 347 | that renders to: 348 | 349 | ![Cfrac](https://raw.githubusercontent.com/punk0x29a/teknote/master/images/frac2.jpg?raw=true "Example Fraction") 350 | 351 | 352 | If continous fraction is present in the middle of an expression, one must end it with `endfractions` token. 353 | 354 | 355 | ##### Underbrace and Overbrace: 356 | 357 | ``` 358 | overbrace {{ underbrace x Re + underbrace i*y Im }} {{ Complex Number }} 359 | . 360 | ``` 361 | 362 | gives 363 | 364 | ``` 365 | \overbrace{\underbrace{x}_{\Re }\: +\underbrace{i*y}_{\Im }\: }^{\: Complex\: Number\: } \\ 366 | ``` 367 | 368 | that renders to 369 | 370 | ![Braces](https://raw.githubusercontent.com/punk0x29a/teknote/master/images/complex.jpg?raw=true "Complex Number") 371 | 372 | 373 | ##### Some set theory and math blackboard 374 | 375 | Entering two same capital letters in a row gives back mathbb form: 376 | 377 | ``` 378 | Gamma = { forall x in RR : x > 1 } 379 | . 380 | ``` 381 | gives 382 | ``` 383 | \Gamma \: =\: \{\: \forall \: x\: \in \: \mathbb{R}:\: x\: >\: 1\: \} 384 | ``` 385 | that renders to 386 | 387 | ![Mathbb](https://raw.githubusercontent.com/punk0x29a/teknote/master/images/set1.jpg?raw=true "Such a set...") 388 | 389 | As for sets, there is a set form that automates sets declaration: 390 | 391 | ``` 392 | A = set a b c 393 | 394 | B = set c d e 395 | 396 | A set* B = set c end = (( A set+ B )) \ set a b d e 397 | . 398 | ``` 399 | 400 | gives 401 | 402 | ``` 403 | A\: =\: \{a,b,c\} \\ B\: =\: \{c,d,e\} \\ A\: \cap \: B\: =\: \{c\}\: =\: (\: A\: \cup \: B\: )\: \setminus \: \{a,b,d,e\} \\ 404 | 405 | ``` 406 | 407 | and, conclusively 408 | 409 | ![Set](https://raw.githubusercontent.com/punk0x29a/teknote/master/images/set2.jpg?raw=true "Such a set...") 410 | 411 | 412 | Most of set theory operators, such as arrows, are available in almost ascii-art, straightforward form: 413 | 414 | 415 | ``` 416 | A subset B == x in A => x in B 417 | . 418 | ``` 419 | 420 | gives 421 | 422 | ``` 423 | A\: \subset \: B\: \equiv \: x\: \in \: A\: \Rightarrow \: x\: \in \: B \\ 424 | . 425 | ``` 426 | 427 | that renders to 428 | 429 | ![Arrows](https://raw.githubusercontent.com/punk0x29a/teknote/master/images/arrows.jpg?raw=true "Arrows...") 430 | 431 | 432 | while less and more operators are presented as `>=` and `=<` 433 | 434 | Other, less used operators, are (mostly) straightforward as well: 435 | 436 | ``` 437 | alpha o. beta = a and not b or not a and b 438 | alpha ox beta = a or not b and not a or b 439 | A O. B = A \ B set+ B \ A 440 | A Ox B = A set+ B' set* B set+ A' 441 | . 442 | ``` 443 | 444 | translates to 445 | 446 | 447 | ``` 448 | \alpha \: \odot \: \beta \: =\: a\: \land \: \neg \: b\: \lor \: \neg \: a\: \land \: b \\ \alpha \: \otimes \: \beta \: =\: a\: \lor \: \neg \: b\: \land \: \neg \: a\: \lor \: b \\ A\: \bigodot \: B\: =\: A\: \setminus \: B\: \cup \: B\: \setminus \: A \\ A\: \bigotimes \: \: B\: =\: A\: \cup \: B'\: \cap \: B\: \cup \: A' \\ 449 | ``` 450 | 451 | and gives: 452 | 453 | ![Arrows](https://raw.githubusercontent.com/punk0x29a/teknote/master/images/odot.jpg?raw=true "Weird operators") 454 | 455 | 456 | 457 | #### That's about it 458 | 459 | Have fun using my little script. 460 | For bug reports or questions please contact me at: 461 | punk0x29a@gmail.com 462 | 463 | 464 | -------------------------------------------------------------------------------- /teknote.lua: -------------------------------------------------------------------------------- 1 | function isMember(key, someTable) return someTable[key] ~= nil end 2 | 3 | --[[ 4 | -- teknote.lua 5 | -- translate commands in relatively simple micro-language into LaTeX math functions 6 | -- ]] 7 | 8 | 9 | -- Dictionary 10 | Symbols = { 11 | --Binary Operations 12 | ["+-"] = "\\pm ", 13 | ["-+"] = "\\mp ", 14 | ["pm"] = "\\pm ", 15 | ["mp"] = "\\mp ", 16 | ["**"] = "\\times ", 17 | ["times"] = "\\times ", 18 | ["*"] = "\\ast ", 19 | ["ast"] = "\\ast ", 20 | ["***"] = "\\star ", 21 | ["star"] = "\\star ", 22 | ["::"] = "\\div ", 23 | ["div"] = "\\div ", 24 | ["dagger"] = "\\dagger ", 25 | ["ddagger"] = "\\ddagger ", 26 | ["cap"] = "\\cap ", 27 | ["setand"] = "\\cap ", 28 | ["seta"] = "\\cap ", 29 | ["sand"] = "\\cap ", 30 | ["set*"] = "\\cap ", 31 | ["cup"] = "\\cup ", 32 | ["setor"] = "\\cup ", 33 | ["sor"] = "\\cup ", 34 | ["set+"] = "\\cup ", 35 | ["set"] = "", 36 | ["u+"] = "\\uplus ", 37 | ["uplus"] = "\\uplus", 38 | ["sqcap"] = "\\sqcap ", 39 | ["[setand"] = "\\sqcap ", 40 | ["[sand"] = "\\sqcap ", 41 | ["sqcup"] = "\\sqcup ", 42 | ["[setand"] = "\\sqcup ", 43 | ["[sand"] = "\\sqcup ", 44 | ["vee"] = "\\vee ", 45 | ["Or"] = "\\bigvee ", 46 | ["bigvee"] = "\\bigvee ", 47 | ["or"] = "\\vee ", 48 | ["wedge"] = "\\wedge ", 49 | ["and"] = "\\wedge ", 50 | ["And"] = "\\bigwedge ", 51 | ["bigwedge"] = "\\bigwedge ", 52 | ["diamond"] = "\\diamond ", 53 | ["bigtriangleup"] = "\\bigtriangleup ", 54 | ["/_\\"] = "\\bigtriangleup ", 55 | ["btu"] = "\\bigtriangleup ", 56 | ["bu"] = "\\bigtriangleup ", 57 | ["btd"] = "\\bigtriangledown ", 58 | ["\\-/"] = "\\bigtriangledown ", 59 | ["bd"] = "\\bigtriangledown ", 60 | ["bigtriangledown"] = "\\bigtriangledown ", 61 | ["tl"] = "\\triangleleft ", 62 | ["<|"] = "\\triangleleft ", 63 | ["triangleleft"] = "\\triangleleft ", 64 | ["|>"] = "\\triangleright ", 65 | ["triangleright"] = "\\triangleright ", 66 | ["O"] = "\\bigcirc ", 67 | ["bc"] = "\\bigcirc ", 68 | ["bigcirc"] = "\\bigcirc ", 69 | ["bigcircle"] = "\\bigcircle ", 70 | ["bullet"] = "\\bullet ", 71 | ["wr"] = "\\wr ", 72 | ["o+"] = "\\oplus ", 73 | ["oplus"] = "\\oplus ", 74 | ["o-"] = "\\ominus ", 75 | ["ominus"] = "\\ominus ", 76 | ["o*"] = "\\otimes ", 77 | ["ox"] = "\\otimes ", 78 | ["otimes"] = "\\otimes ", 79 | ["o/"] = "\\oslash ", 80 | ["oslash"] = "\\oslash ", 81 | ["o."] = "\\odot ", 82 | ["odot"] ="\\odot ", 83 | ["circ"] = "\\circ ", 84 | ["circle"] = "\\circ ", 85 | ["o"] = "\\circ ", 86 | ["\\"] = "\\setminus ", 87 | ["set-"] = "\\setminus ", 88 | ["setminus"] = "\\setminus ", 89 | ["ip"] = "\\amalg ", 90 | ["amalg"] = "\\amalg ", 91 | --Logic 92 | ["ex"] = "\\exists ", 93 | ["nex"] = "\\nexist ", 94 | ["!ex"] = "\\nexist ", 95 | ["forall"] = "\\forall ", 96 | ["foreach"] = "\\forall ", 97 | ["fore"] = "\\forall ", 98 | ["fora"] = "\\forall ", 99 | ["not"] = "\\neg ", 100 | ["!"] = "\\neg ", 101 | ["!!"] = " ! ", 102 | ["neg"] = "\\neg ", 103 | ["and"] = "\\land ", 104 | ["land"] = "\\land ", 105 | ["or"] = "\\lor ", 106 | ["lor"] = "\\lor ", 107 | ["->"] = "\\rightarrow ", 108 | ["rightarrow"] = "\\rightarrow", 109 | ["<-"] = "\\leftarrow ", 110 | ["<="] = "\\Leftarrow ", 111 | ["leftarrow"] = "\\leftarrow", 112 | ["|->"] = "\\mapsto ", 113 | ["mapsto"] = "\\mapsto ", 114 | ["=>"] = "\\Rightarrow ", 115 | ["Rightarrow"] = "\\Rightarrow ", 116 | ["<->"] = "\\leftrightarrow ", 117 | ["leftrightarrow"] = "\\leftrightarrow ", 118 | ["<=>"] = "\\Leftrightarrow ", 119 | ["Leftrightarrow"] = "\\Leftrightarrow ", 120 | ["top"] = "\\top ", 121 | ["true"] = "\\top ", 122 | ["bot"] = "\\bot ", 123 | ["false"] = "\\bot ", 124 | ["bottom"] = "\\bot ", 125 | ["emptyset"] = "\\emptyset ", 126 | ["nilset"] = "\\emptyset ", 127 | ["nil"] = "\\varnothing ", 128 | ["varnothing"] = "\\varnothing", 129 | --Delimiters 130 | ["/\\"] = "\\uparrow ", 131 | ["uparrow"] ="\\uparrow", 132 | ["/|\\"] = "\\Uparrow ", 133 | ["/||\\"] = "\\Uparrow ", 134 | ["Uparrow"] = "\\Uparrow ", 135 | ["\\/"] = "\\downarrow ", 136 | ["downarrow"] = "\\downarrow ", 137 | ["\\||/"] = "\\Downarrow ", 138 | ["\\|/"] = "\\Downarrow ", 139 | ["Downarrow"] = "\\Downarrow ", 140 | ["((("] = "\\left( ", 141 | ["left("] = "\\left( ", 142 | ["(("] = "(", 143 | ["))"] = ")", 144 | [")))"] = "\\right) ", 145 | ["right)"] = "\\right)", 146 | ["[["] = "\\left[ ", 147 | ["left["] = "\\left[ ", 148 | ["]]"] = "\\right] ", 149 | ["right"] = "\\right] ", 150 | ["l|"] = "\\left| ", 151 | ["left|"] = "\\left| ", 152 | ["r|"] = "\\right| ", 153 | ["right|"] = "\\right| ", 154 | ["m|"] = "\\middle| ", 155 | ["middle|"] = "\\middle| ", 156 | ["lceil"] = "\\lceil ", 157 | ["rceil"] = "\\rceil ", 158 | ["lfloor"] = "\\lfloor ", 159 | ["rfloor"] = "\\rfloor ", 160 | --TrigonometricFunctions 161 | ["sin"] = "\\sin ", 162 | ["cos"] = "\\cos ", 163 | ["tan"] = "\\tan ", 164 | ["cot"] = "\\cot ", 165 | ["arcsin"] = "\\arcsin ", 166 | ["asin"] = "\\arcsin ", 167 | ["arccos"] = "\\arccos ", 168 | ["acos"] = "\\arccos ", 169 | ["arctan"] = "\\arctan ", 170 | ["atan"] = "\\arctan ", 171 | ["arccot"] = "\\arccot ", 172 | ["acot"] = "\\arccot ", 173 | ["sinh"] = "\\sinh ", 174 | ["cosh"] = "\\cosh ", 175 | ["tanh"] = "\\tanh ", 176 | ["coth"] = "\\coth ", 177 | ["sec"] = "\\sec ", 178 | ["csc"] = "\\csc ", 179 | --Relations 180 | ["=<"] = "\\leq ", 181 | ["leq"] = "\\leq ", 182 | [">="] = "\\geq ", 183 | ["geq"] = "\\geq ", 184 | ["<<"] = "\\ll ", 185 | ["ll"] = "\\ll ", 186 | [">>"] = "\\gg ", 187 | ["gg"] = "\\gg ", 188 | ["=="] = "\\equiv ", 189 | ["eq"] = "\\equiv ", 190 | ["equiv"] = "\\equiv ", 191 | ["||"] = "\\parallel ", 192 | ["parallel"] = "\\parallel ", 193 | ["!||"] = "\\nparallel ", 194 | ["nparallel"] = "\\nparallel ", 195 | [".=="] = "\\doteq ", 196 | ["doteq"] = "\\doteq ", 197 | ["asymp"] = "\\asymp ", 198 | ["bowtie"] = "\\bowtie ", 199 | ["vdash"] = "\\vdash ", 200 | ["outputs"] = "\\vdash ", 201 | ["outs"] = "\\vdash ", 202 | ["svp"] = "\\dashv ", 203 | ["dashv"] = "\\dashv ", 204 | ["subset"] = "\\subset ", 205 | ["supset"] = "\\supset ", 206 | ["superset"] = "\\supset ", 207 | ["~~"] = "\\approx ", 208 | ["approx"] = "\\approx ", 209 | ["in"] = "\\in ", 210 | ["ni"] = "\\ni ", 211 | ["=subset"] = "\\subseteq ", 212 | ["subset="] = "\\subseteq ", 213 | ["subseteq"] = "\\subseteq ", 214 | ["=supset"] = "\\supseteq ", 215 | ["=superset"] = "\\supseteq ", 216 | ["supset="] ="\\supseteq ", 217 | ["superset="] = "\\supseteq ", 218 | ["supseteq"] = "\\supseteq ", 219 | ["superseteq"] = "\\supseteq ", 220 | ["~=="] = "\\cong ", 221 | ["cong"] = "\\cong ", 222 | ["smile"] = "\\smile ", 223 | ["frown"] = "\\frown ", 224 | ["!=subset"] = "\\nsubseteq ", 225 | ["nsubseteq"] = "\\nsubseteq ", 226 | ["subset!="] = "\\nsubseteq ", 227 | ["!=supset"] = "\\nsupseteq ", 228 | ["!subset"] = "\\nsubset ", 229 | ["!=superset"] = "\\nsupseteq ", 230 | ["nsupseteq"] = "\\nsupseteq ", 231 | ["nsuperseteq"] = "\\nsupseteq ", 232 | ["supset!="] = "\\nsupseteq ", 233 | ["~="] = "\\simeq ", 234 | ["simeq"] = "\\simeq ", 235 | ["models"] = "\\models ", 236 | ["scon"] = "\\models ", 237 | ["syntactic_consequence"] = "\\models ", 238 | ["notin"] = "\\notin ", 239 | ["!in"] = "\\notin ", 240 | ["sqsubset"] = "\\sqsubset ", 241 | ["[subset"] = "\\sqsubset ", 242 | ["sqsupset"] = "\\sqsupset ", 243 | ["sqsuperset"] = "\\sqsupset ", 244 | ["[supset"] = "\\sqsupset ", 245 | ["[superset"] = "\\sqsupset ", 246 | ["~"] = "\\sim ", 247 | ["sim"] = "\\sim ", 248 | ["perp"] = "\\perp ", 249 | ["|"] = "\\mid ", 250 | ["=sqsubset"] = "\\sqsubseteq ", 251 | ["=[subset"] = "\\sqsubseteq ", 252 | ["=sqsupset"] = "\\sqsupseteq ", 253 | ["=[superset"] = "\\sqsupseteq ", 254 | ["=[supset"] = "\\sqsupseteq ", 255 | ["propto"] = "\\propto ", 256 | ["prec"] = "\\prec ", 257 | ["succ"] = "\\succ ", 258 | ["preceq"] = "\\preceq ", 259 | ["succeq"] = "\\succeq ", 260 | ["!="] = "\\neq ", 261 | ["neq"] = "\\neq ", 262 | --GreekLetters 263 | ["alpha"] = "\\alpha ", 264 | ["beta"] = "\\beta ", 265 | ["Beta"] = "\\beta ", 266 | ["Gamma"] = "\\Gamma ", 267 | ["gamma"] ="\\gamma ", 268 | ["Delta"] ="\\Delta ", 269 | ["delta"] = "\\delta ", 270 | ["epsilon"] = "\\epsilon ", 271 | ["vepsilon"] = "\\varepsilon ", 272 | ["varepsion"] = "\\varepsilon ", 273 | ["zeta"] = "\\zeta ", 274 | ["eta"] = "\\eta ", 275 | ["Theta"] = "\\Theta ", 276 | ["theta"] = "\\theta ", 277 | ["vtheta"] = "\\vartheta ", 278 | ["iota"] = "\\iota ", 279 | ["kappa"] = "\\kappa ", 280 | ["vkappa"] = "\\varkappa ", 281 | ["varkappa"] ="\\varkappa ", 282 | ["Lambda"] = "\\Lambda ", 283 | ["lambda"] = "\\lambda ", 284 | ["micro"] = "\\mu ", 285 | ["mu"] = "\\mu ", 286 | ["nu"] = "\\nu ", 287 | ["Xi"] = "\\Xi ", 288 | ["xi"] = "\\xi ", 289 | ["omicron"] = "o ", 290 | ["Pi"] = "\\Pi ", 291 | ["pi"] = "\\pi ", 292 | ["vpi"] = "\\varpi ", 293 | ["varpi"] = "\\varpi ", 294 | ["ro"] = "\\rho ", 295 | ["rho"] = "\\rho ", 296 | ["vrho"] = "\\varrho ", 297 | ["vro"] = "\\varrho ", 298 | ["varrho"] = "\\varrho ", 299 | ["Sigma"] = "\\Sigma ", 300 | ["sigma"] = "\\sigma ", 301 | ["vsigma"] = "\\varsigma ", 302 | ["varsigma"] = "\\varsigma ", 303 | ["tau"] = "\\tau ", 304 | ["Ypsilon"] = "\\Upsilon ", 305 | ["Upsilon"] = "\\Upsilon ", 306 | ["ypsilon"] = "\\upsilon ", 307 | ["upsilon"] = "\\upsilon ", 308 | ["Fi"] = "\\Phi ", 309 | ["fi"] = "\\phi ", 310 | ["Phi"] = "\\Phi ", 311 | ["phi"] = "\\phi ", 312 | ["vphi"] = "\\varphi ", 313 | ["varphi"] = "\\varphi ", 314 | ["chi"] = "\\chi ", 315 | ["Psi"] = "\\Psi ", 316 | ["psi"] = "\\psi ", 317 | ["Omega"] = "\\Omega ", 318 | ["omega"] = "\\omega ", 319 | --OtherSymbols 320 | ["partial"] = "\\partial ", 321 | ["eth"] = "\\eth ", 322 | ["imath"] = "\\imath ", 323 | ["jmath"] = "\\jmath ", 324 | ["ell"] = "\\ell ", 325 | ["Re"] = "\\Re ", 326 | ["re"] = "\\Re ", 327 | ["Im"] = "\\Im ", 328 | ["im"] = "\\Im ", 329 | ["wp"] = "\\wp ", 330 | ["nabla"] = "\\nabla ", 331 | ["box"] = "\\Box ", 332 | ["Box"] = "\\Box ", 333 | ["oo"] = "\\infty ", 334 | ["infty"] = "\\infty ", 335 | ["-oo"] = "-\\infty", 336 | ["-infty"] = "-\\infty", 337 | [",,"] = "\\: ", 338 | ["[]"] = " ", 339 | ["aleph"] = "\\aleph ", 340 | ["beth"] = "\\beth ", 341 | ["gimel"] = "\\gimel ", 342 | ["."] = "\\cdot ", 343 | ["..."] = "\\cdots ", 344 | ["cdots"] = "\\cdots ", 345 | ["dots"] = "\\dots ", 346 | ["v..."] = "\\vdots ", 347 | ["vdots"] = "\\vdots ", 348 | ["ddots"] = "\\ddots ", 349 | ["d..."] = "\\ddots ", 350 | ["ln"] = "\\ln ", 351 | ["max"] = "\\max", 352 | ["min"] = "\\min", 353 | ["sup"] = "\\sup", 354 | ["inf"] = "\\inf ", 355 | ["ker"] = "\\ker ", 356 | --BigCommands 357 | ["int"] = "\\int ", 358 | ["iint"] = "\\iint", 359 | ["iiint"] = "\\iiint", 360 | ["iiiint"] = "\\iiiint", 361 | ["int...int"] = "\\idotsint ", 362 | ["integral"] = "\\int ", 363 | ["oint"] = "\\oint ", 364 | ["level"] = " \\\\ ", 365 | ["wlevel"] = " \\\\ \\color{white}", 366 | ["wlvl"] = " \\\\ \\color{white}", 367 | ["endsubstack"] = "}} ", 368 | ["sum"] = "\\sum ", 369 | ["O+"] = "\\bigoplus ", 370 | ["bigoplus"] = "\\bigoplus ", 371 | ["O."] = "\\bigodot ", 372 | ["bigodot"] = "\\bigodot ", 373 | ["Ox"] = "\\bigotimes ", 374 | ["bigotimes"] = "\\bigotimes ", 375 | ["O*"] = "\\bigotimes ", 376 | ["bigcup"] = "\\bigcup ", 377 | ["bigsor"] = "\\bigcup ", 378 | ["bigsetor"] = "\\bigcup ", 379 | ["U"] = "\\bigcup ", 380 | ["Setor"] = "\\bigcup ", 381 | ["Set+"] = "\\bigcup ", 382 | ["Seta"] = "\\bigcap", 383 | ["Set*"]= "\\bigcap", 384 | ["bigsqcup"] = "\\bigsqcup ", 385 | ["big[setor"] = "\\bigsqcup ", 386 | ["big[sor"] = "\\bigsqcup ", 387 | ["coprod"] = "\\coprod ", 388 | ["bigwedge"] = "\\bigwedge ", 389 | ["endf"] = "", 390 | ["endfractions"] = "", 391 | ["}}"] = "", 392 | ["textrm"] = "\\textrm{", 393 | ["exp"] = "\\exp", 394 | ["("] = "{{", 395 | [")"] = "}}", 396 | ["{"] = "\\{", 397 | ["}"] = "\\}", 398 | ["over"] = "\\over ", 399 | ["/"] = "}\\over{", 400 | ["endtabular"] = "\\end{array} ", 401 | ["hline"] = " \\\\ \\hline ", 402 | ["hbar"] = "\\hbar ", 403 | ["matrix_separator"] = " & ", 404 | ["endmatrix"] = "\\end{matrix}", 405 | ["end(matrix"] = "\\end{pmatrix}", 406 | ["end[matrix"] = "\\end{bmatrix}", 407 | ["end{matrix"] = "\\end{Bmatrix}", 408 | ["end|matrix"] = "\\end{vmatrix}", 409 | ["end||matrix"] = "\\end{Vmatrix}", 410 | ["lvl"] = " \\\\ ", 411 | ["tab"] = "\\qquad ", 412 | ["qquad"] = "\\qquad ", 413 | ["arg"] = "\\arg", 414 | ["set"] = "\\{", 415 | [";"] = "; ", 416 | [";;"] = "", 417 | ["##"] = " ", 418 | ["txt"] = "", 419 | ["text"] = "", 420 | ["boxed"] = "\\boxed{", 421 | ["substack"] = "_{\\substack{", 422 | ["root"] = "\\sqrt[", 423 | ["sqrt"] = "\\sqrt[", 424 | ["fraction"] = "\\cfrac{", 425 | ["//"] = "\\cfrac{", 426 | ["cfrac"] = "\\cfrac{", 427 | ["amatrix"] = " ", 428 | ["tabular"] = "\\begin{array}{ ", 429 | ["cases"] = "\\begin{cases} ", 430 | ["expr"] = "", 431 | ["{{"] = "", 432 | ["obrace"] = "\\overbrace{", 433 | ["overb"] = "\\overbrace{", 434 | ["overbrace"] = "\\overbrace{", 435 | ["o{"] = "\\overbrace{", 436 | ["ubrace"] = "\\underbrace{", 437 | ["underb"] = "\\underbrace{", 438 | ["underbrace"] = "\\underbrace{", 439 | ["u{"] = "\\underbrace{", 440 | ["hat"] = "\\hat{", 441 | ["overline"] = "\\overline{", 442 | ["vec"] = "\\vec{", 443 | ["vector"] = "\\vec{", 444 | ["bar"] = "\\bar{", 445 | ["bigvector"] = "\\overrightarrow{", 446 | ["overrightarrow"] = "\\overrightarrow{", 447 | ["bvector"] = "\\overrightarrow{", 448 | ["bigvec"] = "\\overrightarrow{", 449 | ["bvec"] = "\\overrightarrow{", 450 | ["oline"] = "\\overline{", 451 | ["overl"] = "\\overline{", 452 | ["uline"] = "\\underline{", 453 | ["underl"] = "\\underline{", 454 | ["underline"] = "\\underline{", 455 | ["pow"] = "^{", 456 | ["^"] = "^{", 457 | ["power"] = "^{", 458 | ["sub"] = "_{", 459 | ["matrix"] = "\\begin{matrix} ", 460 | ["(matrix"] = "\\begin{pmatrix} ", 461 | ["pmatrix"] = "\\begin{pmatrix} ", 462 | ["[matrix"] = "\\begin{bmatrix} ", 463 | ["bmatrix"] = "\\begin{bmatrix} ", 464 | ["{matrix"] = "\\begin{Bmatrix} ", 465 | ["Bmatrix"] = "\\begin{Bmatrix} ", 466 | ["|matrix"] = "\\begin{vmatrix} ", 467 | ["vmatrix"] = "\\begin{vmatrix} ", 468 | ["||matrix"] = "\\begin{Vmatrix} ", 469 | ["Vmatrix"] = "\\begin{Vmatrix} ", 470 | ["intlimits"] = "\\int\\limits_{", 471 | ["intl"] = "\\int\\limits_{", 472 | ["ointl"] = "\\oint\\limits_{", 473 | ["ointlimits"] = "\\oint\\limits_{", 474 | ["sum"] = "\\sum_{", 475 | ["O+i"] = "\\bigoplus_{ ", 476 | ["product"] = "\\prod_{", 477 | ["prod"] = "\\prod_{", 478 | ["Ui"] = "\\bigcup_{ ", 479 | ["Setori"] = "\\bigcup_{", 480 | ["Set+i"] = "\\bigcup_{", 481 | ["Setai"] = "\\bigcap_{", 482 | ["Set*i"]= "\\bigcap_{", 483 | ["limits"] = "\\limits_{", 484 | ["O.i"] = "\\bigodot_{ ", 485 | ["O*i"] = "\\bigotimes_{ ", 486 | ["Oxi"] = "\\bigotimes_{ ", 487 | ["limit"] = "\\lim_{", 488 | ["lim"] = "\\lim_{", 489 | ["limes"] = "\\lim_{", 490 | ["liminf"] = "\\liminf_{", 491 | ["limsup"] = "\\limsup_{", 492 | ["log"] = "\\log_{", 493 | ["()"] = "\\binom{ ", 494 | ["binom"] =" \\binom{ ", 495 | } 496 | 497 | dots = { 498 | ["..."] = "\\cdots ", 499 | ["cdots"] = "\\cdots ", 500 | ["dots"] = "\\dots ", 501 | ["v..."] = "\\vdots ", 502 | ["vdots"] = "\\vdots ", 503 | ["ddots"] = "\\ddots ", 504 | ["d..."] = "\\ddots ", 505 | } 506 | 507 | miscAliases = { 508 | ["set"] = "\\{", 509 | [";"] = "; ", 510 | [";;"] = "", 511 | ["##"] = " ", 512 | ["txt"] = "", 513 | ["text"] = "", 514 | ["boxed"] = "\\boxed{", 515 | ["substack"] = "_{\\substack{", 516 | ["root"] = "\\sqrt[", 517 | ["sqrt"] = "\\sqrt[", 518 | ["fraction"] = "\\cfrac{", 519 | ["//"] = "\\cfrac{", 520 | ["cfrac"] = "\\cfrac{", 521 | ["amatrix"] = " ", 522 | ["tabular"] = "\\begin{array}{ ", 523 | ["cases"] = "\\begin{cases} ", 524 | ["expr"] = "", 525 | ["{{"] = "", 526 | ["level"] = " \\\\ ", 527 | } 528 | 529 | overbraceAliases = { 530 | ["obrace"] = "\\overbrace{", 531 | ["overb"] = "\\overbrace{", 532 | ["overbrace"] = "\\overbrace{", 533 | ["o{"] = "\\overbrace{", 534 | } 535 | 536 | underbraceAliases = { 537 | ["ubrace"] = "\\underbrace{", 538 | ["underb"] = "\\underbrace{", 539 | ["underbrace"] = "\\underbrace{", 540 | ["u{"] = "\\underbrace{", 541 | } 542 | 543 | decoratorAliases = { 544 | ["hat"] = "\\hat{", 545 | ["overline"] = "\\overline{", 546 | ["vec"] = "\\vec{", 547 | ["vector"] = "\\vec{", 548 | ["bar"] = "\\bar{", 549 | ["bigvector"] = "\\overrightarrow{", 550 | ["overrightarrow"] = "\\overrightarrow{", 551 | ["bvector"] = "\\overrightarrow{", 552 | ["bigvec"] = "\\overrightarrow{", 553 | ["bvec"] = "\\overrightarrow{", 554 | ["oline"] = "\\overline{", 555 | ["overl"] = "\\overline{", 556 | ["uline"] = "\\underline{", 557 | ["underl"] = "\\underline{", 558 | ["underline"] = "\\underline{", 559 | ["pow"] = "^{", 560 | ["^"] = "^{", 561 | ["power"] = "^{", 562 | ["sub"] = "_{", 563 | } 564 | 565 | matrixAliases = { 566 | ["matrix"] = "\\begin{matrix} ", 567 | ["(matrix"] = "\\begin{pmatrix} ", 568 | ["pmatrix"] = "\\begin{pmatrix} ", 569 | ["[matrix"] = "\\begin{bmatrix} ", 570 | ["bmatrix"] = "\\begin{bmatrix} ", 571 | ["{matrix"] = "\\begin{Bmatrix} ", 572 | ["Bmatrix"] = "\\begin{Bmatrix} ", 573 | ["|matrix"] = "\\begin{vmatrix} ", 574 | ["vmatrix"] = "\\begin{vmatrix} ", 575 | ["||matrix"] = "\\begin{Vmatrix} ", 576 | ["Vmatrix"] = "\\begin{Vmatrix} ", 577 | } 578 | 579 | 580 | sigmaAliases = { 581 | ["intlimits"] = "\\int\\limits_{", 582 | ["intl"] = "\\int\\limits_{", 583 | ["ointl"] = "\\oint\\limits_{", 584 | ["ointlimits"] = "\\oint\\limits_{", 585 | ["sum"] = "\\sum_{", 586 | ["O+i"] = "\\bigoplus_{ ", 587 | ["product"] = "\\prod_{", 588 | ["prod"] = "\\prod_{", 589 | ["Ui"] = "\\bigcup_{ ", 590 | ["Setori"] = "\\bigcup_{", 591 | ["Set+i"] = "\\bigcup_{", 592 | ["Setai"] = "\\bigcap_{", 593 | ["Set*i"]= "\\bigcap_{", 594 | ["limits"] = "\\limits_{", 595 | ["O.i"] = "\\bigodot_{ ", 596 | ["O*i"] = "\\bigotimes_{ ", 597 | ["Oxi"] = "\\bigotimes_{ ", 598 | } 599 | 600 | limitAliases = { 601 | ["limit"] = "\\lim_{", 602 | ["lim"] = "\\lim_{", 603 | ["limes"] = "\\lim_{", 604 | } 605 | 606 | coefAliases = { 607 | ["liminf"] = "\\liminf_{", 608 | ["limsup"] = "\\limsup_{", 609 | ["log"] = "\\log_{", 610 | ["()"] = "\\binom{ ", 611 | ["binom"] =" \\binom{ ", 612 | } 613 | 614 | --FUNCTIONS: 615 | 616 | function dictionary() 617 | for i,v in pairs(Symbols) do 618 | print("Token: " .. i .. "\t Symbol: " .. v) 619 | end 620 | end 621 | 622 | 623 | --remove all preceding whitespaces, good when autospace is on 624 | -- 625 | function checkForPrecedingSpace() 626 | if spaces or tabs then 627 | local h = #result 628 | if result[h] == "\\: " or result[h] == "\\qquad " then 629 | while result[h] == "\\: " or result[h] == "\\qquad " do 630 | result[h] = "" 631 | h = h - 1 632 | end 633 | end 634 | end 635 | end 636 | 637 | 638 | 639 | function nextToken() 640 | _ = _ + 1 641 | currentToken = tokens[_] 642 | end 643 | 644 | function isFunction(command) 645 | return isMember(command,sigmaAliases) or isMember(command,miscAliases) or isMember(command,coefAliases) or isMember(command,limitAliases) or isMember(command,decoratorAliases) or isMember(command,matrixAliases) or isMember(command,underbraceAliases) or isMember(command,overbraceAliases) 646 | end 647 | 648 | 649 | --skip spaces until token is encountered, good when autospace is on 650 | -- 651 | function skipSpaces() 652 | if spaces and currentToken == ",," then 653 | while _ <= #tokens do 654 | nextToken() 655 | if currentToken ~= ",," then 656 | break 657 | end 658 | end 659 | end 660 | end 661 | 662 | function isEndSign(offset) 663 | return tokens[_+offset] == "end" or tokens[_+offset] == "}}" 664 | end 665 | 666 | function isNewLevel(offset) 667 | return tokens[_+offset] == "level" or tokens[_+offset] == "lvl" or tokens[_+offset] == "\\\\" 668 | end 669 | 670 | --this launches different functions, invoked by addSymbol 671 | -- 672 | function FunctionsCentral() 673 | if isMember(currentToken,overbraceAliases) then 674 | overbrace() 675 | elseif isMember(currentToken,underbraceAliases) then 676 | underbrace() 677 | elseif isMember(currentToken,sigmaAliases) then 678 | sigmaNotation() 679 | elseif isMember(currentToken,decoratorAliases) then 680 | decorate() 681 | elseif isMember(currentToken,matrixAliases) then 682 | matrix() 683 | elseif isMember(currentToken,limitAliases) then 684 | limit() 685 | elseif isMember(currentToken, coefAliases) then 686 | coefSymbol() 687 | elseif currentToken == "txt" or currentToken == "text" then 688 | textrm() 689 | elseif currentToken == "boxed" then 690 | boxed() 691 | elseif currentToken == "substack" then 692 | substack() 693 | elseif currentToken == "root" then 694 | root() 695 | elseif currentToken == "sqrt" then 696 | sqrt() 697 | elseif currentToken == "amatrix" then 698 | amatrix() 699 | elseif currentToken == "tabular" then 700 | tabular() 701 | elseif currentToken == "set" then 702 | set() 703 | elseif currentToken == "cases" then 704 | cases() 705 | elseif currentToken == "//" or currentToken == "fraction" or currentToken == "cfrac" then 706 | fraction() 707 | elseif currentToken == "endf" or currentToken == "endfractions" then 708 | endfractions() 709 | elseif currentToken == "expr" or currentToken == "{{" then 710 | expr() 711 | elseif currentToken == "level" or currentToken == "lvl" then 712 | level() 713 | elseif currentToken == "##" then 714 | comment() 715 | else 716 | table.insert(result, Symbols[currentToken]) 717 | end 718 | end 719 | 720 | function twoMajorLetters() 721 | return string.len(currentToken) == 2 and string.find(currentToken:sub(1,1), "%u") and currentToken:sub(1,1) == currentToken:sub(2,2) 722 | end 723 | 724 | function addSymbol() 725 | if isFunction(currentToken) then 726 | FunctionsCentral() 727 | elseif isMember(currentToken,Symbols) then 728 | table.insert(result, Symbols[currentToken]) 729 | elseif currentToken ~= nil then 730 | if twoMajorLetters() then 731 | mathbb() 732 | else 733 | table.insert(result, currentToken) 734 | end 735 | end 736 | end 737 | 738 | --put a box around text 739 | function boxed() 740 | table.insert(result, Symbols[currentToken]) 741 | while _ <= #tokens do 742 | nextToken() 743 | if isEndSign(0) or isNewLevel(0) then 744 | break 745 | else 746 | skipSpaces() 747 | addSymbol() 748 | end 749 | end 750 | table.insert(result, "}") 751 | end 752 | 753 | --this wraps tokens between { and } inserting , in between 754 | function set() 755 | waslevel = 0; 756 | table.insert(result, Symbols[currentToken]) 757 | while _ <= #tokens do 758 | nextToken() 759 | if isEndSign(0) or isNewLevel(0) then 760 | if currentToken == "level" then 761 | waslevel=1; 762 | break; 763 | else 764 | break 765 | end 766 | else 767 | skipSpaces() 768 | addSymbol() 769 | if _+2 <= #tokens then 770 | skipSpaces() 771 | if isEndSign(2) or isNewLevel(2) then 772 | nextToken() 773 | else 774 | table.insert(result, ",") 775 | nextToken() 776 | end 777 | end 778 | end 779 | end 780 | table.insert(result, "\\}") 781 | if waslevel == 1 then 782 | table.insert(result, Symbols["level"]); 783 | end 784 | end 785 | 786 | --overbrace/underbrace tokens and put text above it : overbrace {{ expression }} {{ text }} 787 | function overbrace() 788 | checkForPrecedingSpace() 789 | insertThree(Symbols[currentToken],"}^{","}") 790 | end 791 | 792 | function underbrace() 793 | checkForPrecedingSpace() 794 | insertThree(Symbols[currentToken],"}^{","}") 795 | end 796 | 797 | --insert newline, useful when autonewline is off 798 | function level() 799 | if color then 800 | table.insert(result, " \\\\ " .. color .. " ") 801 | else 802 | table.insert(result, " \\\\ ") 803 | end 804 | end 805 | 806 | 807 | --determine matrix type 808 | function setMatrixEndSign() 809 | if currentToken == "(matrix" or currentToken == "pmatrix" then 810 | matrixEndSign = "end(matrix" 811 | elseif currentToken == "[matrix" or currentToken == "bmatrix" then 812 | matrixEndSign = "end[matrix" 813 | elseif currentToken == "{matrix" or currentToken == "Bmatrix" then 814 | matrixEndSign = "end{matrix" 815 | elseif currentToken == "|matrix" or currentToken == "vmatrix" then 816 | matrixEndSign = "end|matrix" 817 | elseif currentToken == "||matrix" or currentToken == "Vmatrix" then 818 | matrixEndSign = "end||matrix" 819 | else 820 | matrixEndSign = "endmatrix" 821 | end 822 | end 823 | 824 | --generate matrix from tokens 825 | function matrix() 826 | setMatrixEndSign() 827 | table.insert(result, Symbols[currentToken]) 828 | while _ <= #tokens do 829 | nextToken() 830 | if isEndSign(0) or _ == #tokens then 831 | break 832 | end 833 | if isNewLevel(0) then 834 | table.insert(result, Symbols["level"]) 835 | elseif currentToken ~= ",," then 836 | addSymbol() 837 | if _+1 <= #tokens then 838 | if not isNewLevel(1) and not isEndSign(1) then 839 | table.insert(result, Symbols["matrix_separator"]) 840 | end 841 | end 842 | end 843 | end 844 | closematrix() 845 | end 846 | 847 | --generate matrix with element numeration 848 | function amatrix() 849 | nextToken() 850 | skipSpaces() 851 | setMatrixEndSign() 852 | table.insert(result, Symbols[currentToken]) 853 | while _ <= #tokens do 854 | nextToken() 855 | skipSpaces() 856 | if isEndSign(0) or _ == #tokens then 857 | break 858 | elseif isNewLevel(0) then 859 | table.insert(result, Symbols["level"]) 860 | elseif isMember(currentToken,dots) then 861 | table.insert(result, Symbols[currentToken] ) 862 | if _+1 <= #tokens then 863 | if not isNewLevel(1) and not isEndSign(1) then 864 | table.insert(result, Symbols["matrix_separator"]) 865 | end 866 | end 867 | else 868 | skipSpaces() 869 | addSymbol() 870 | checkForPrecedingSpace() 871 | insertThree("_{",",","}") 872 | if _+1 <= #tokens then 873 | if not isNewLevel(1) then 874 | skipSpaces() 875 | table.insert(result, Symbols["matrix_separator"]) 876 | end 877 | end 878 | end 879 | end 880 | closematrix() 881 | end 882 | 883 | --end matrices accordingly to they type 884 | function closematrix() 885 | table.insert(result,Symbols[matrixEndSign]) 886 | end 887 | 888 | 889 | --generate tabular [needs overhaul] 890 | function tabular() 891 | table.insert(result, Symbols[currentToken]) 892 | skipSpaces() 893 | columns = 0 894 | iterator = _ 895 | while Symbols[tokens[iterator]] ~= Symbols["level"] do 896 | if tokens[iterator] == "{{" or tokens[iterator] == "expr" then 897 | while tokens[iterator] ~= "end" and tokens[iterator] ~= "}}" do 898 | iterator = iterator + 1 899 | end 900 | columns = columns + 1 901 | iterator = iterator + 1 902 | elseif spaces == true and tokens[iterator] == ",," then 903 | iterator = iterator + 1 904 | else 905 | columns = columns + 1 906 | iterator = iterator + 1 907 | end 908 | end 909 | for i=2, columns do 910 | result[#result] = result[#result] .. "c|" 911 | end 912 | result[#result] = result[#result] .. "c} " 913 | while _ <= #tokens do 914 | nextToken() 915 | if isEndSign(0) or currentToken == "endtabular" then 916 | break 917 | end 918 | if isNewLevel(0) then 919 | table.insert(result, Symbols["hline"] ) 920 | elseif currentToken ~= ",," then 921 | addSymbol() 922 | if _+1 <= #tokens then 923 | if not isNewLevel(1) and not isEndSign(1) then 924 | table.insert(result, Symbols["matrix_separator"]) 925 | end 926 | end 927 | end 928 | end 929 | table.insert(result, Symbols["endtabular"]) 930 | end 931 | 932 | function expr() 933 | while _ <= #tokens do 934 | nextToken() 935 | if isEndSign(0) then 936 | break 937 | else 938 | addSymbol() 939 | end 940 | end 941 | end 942 | 943 | function textrm() 944 | table.insert(result,Symbols["textrm"]) 945 | while _ <= #tokens do 946 | nextToken() 947 | if currentToken == "<" then 948 | table.insert(result, "\\textless ") 949 | elseif currentToken == ">" then 950 | table.insert(result, "\\textgreater ") 951 | elseif currentToken == "|" then 952 | table.insert(result, "\\textbar ") 953 | elseif isEndSign(0) or isNewLevel(0) then 954 | break 955 | else 956 | addSymbol() 957 | table.insert(result, " ") 958 | end 959 | end 960 | table.insert(result, "}") 961 | end 962 | 963 | function cases() 964 | table.insert(result, Symbols[currentToken]) 965 | while _ <= #tokens do 966 | nextToken() 967 | if isEndSign(0) then 968 | break 969 | elseif isNewLevel(0) then 970 | table.insert(result, Symbols["level"]) 971 | elseif currentToken == "expr" or currentToken == "{{" then 972 | expr() 973 | elseif currentToken == "txt" or currentToken == "text" then 974 | textrm() 975 | else 976 | addSymbol() 977 | end 978 | end 979 | table.insert(result, "\\end{cases}") 980 | end 981 | 982 | 983 | function substack() 984 | table.insert(result, Symbols[currentToken]) 985 | while _ <= #tokens do 986 | nextToken() 987 | if isEndSign(0) then 988 | break 989 | elseif isNewLevel(0) then 990 | table.insert(result, Symbols["level"]) 991 | else 992 | checkForPrecedingSpace() 993 | addSymbol() 994 | end 995 | end 996 | checkForPrecedingSpace() 997 | table.insert(result, Symbols["endsubstack"]) 998 | end 999 | 1000 | function comment() 1001 | while _ <= #tokens do 1002 | nextToken() 1003 | if currentToken == "##" then 1004 | nextToken() 1005 | break 1006 | end 1007 | end 1008 | end 1009 | 1010 | function insertThree(charleft,charmid,charright) 1011 | table.insert(result,charleft) 1012 | nextToken() 1013 | skipSpaces() 1014 | addSymbol() 1015 | table.insert(result,charmid) 1016 | nextToken() 1017 | skipSpaces() 1018 | addSymbol() 1019 | table.insert(result,charright) 1020 | end 1021 | 1022 | 1023 | function sigmaNotation() 1024 | insertThree(Symbols[currentToken],"}^{","}") 1025 | end 1026 | 1027 | 1028 | function root() 1029 | insertThree(Symbols[currentToken],"]{","}") 1030 | end 1031 | 1032 | function sqrt() 1033 | table.insert(result, Symbols[currentToken]) 1034 | table.insert(result, "]{") 1035 | nextToken() 1036 | skipSpaces() 1037 | addSymbol() 1038 | table.insert(result, "}") 1039 | end 1040 | 1041 | -- Continous fractions block 1042 | function fraction() 1043 | fracn = fracn + 1 1044 | confrac = true 1045 | checkForPrecedingSpace() 1046 | table.insert(result, Symbols["fraction"]) 1047 | nextToken() 1048 | skipSpaces() 1049 | addSymbol() 1050 | table.insert(result, "}") 1051 | table.insert(result, "{") 1052 | skipSpaces() 1053 | end 1054 | 1055 | function endfractions() 1056 | while fracn > 0 do 1057 | fracn = fracn - 1 1058 | table.insert(result, "}") 1059 | end 1060 | confrac = false 1061 | end 1062 | -- End of continous fractions block 1063 | 1064 | function decorate() 1065 | checkForPrecedingSpace() 1066 | table.insert(result, Symbols[currentToken]) 1067 | nextToken() 1068 | skipSpaces() 1069 | addSymbol() 1070 | table.insert(result, "}") 1071 | end 1072 | 1073 | function coefSymbol() 1074 | checkForPrecedingSpace() 1075 | skipSpaces() 1076 | insertThree(Symbols[currentToken],"}{","}") 1077 | end 1078 | 1079 | function limit() 1080 | checkForPrecedingSpace() 1081 | skipSpaces() 1082 | insertThree(Symbols[currentToken],Symbols["->"],"}") 1083 | end 1084 | 1085 | function mathbb() 1086 | table.insert(result, "\\mathbb{") 1087 | table.insert(result,currentToken:sub(1,1)) 1088 | table.insert(result, "}") 1089 | end 1090 | 1091 | 1092 | 1093 | --PROGRAM INIT 1094 | color = nil 1095 | spaces = true 1096 | tabs = true 1097 | newlines = true 1098 | silent=false 1099 | local i = 1 1100 | while i <= #arg do 1101 | if arg[i] == "-c" or arg[i] == "--color" then 1102 | color = "\\color{" .. arg[i+1] .. "}" 1103 | elseif arg[i] == "--nospaces" or arg[i] == "-ns" then 1104 | spaces = false 1105 | ns = true 1106 | elseif arg[i] == "--notabs" or arg[i] == "-nt" then 1107 | tabs = false 1108 | nt = true 1109 | elseif arg[i] == "--nonewlines" or arg[i] == "-nn" then 1110 | newlines = false 1111 | elseif arg[i] == "-h" or arg[i] == "--help" then 1112 | print("-c, --color\n\tChoose color, followed by color name, for example \"white\"\n-nn, --nonewlines\n\tDisable automatic adding of \\\\. Use \"lvl\", \"level\" or manually insert \\\\ instead.\n-nt, --notabs\n\t Disable automatic adding of \\qquad. Use \"tab\", or manually insert \\qquad instead.\n-ns, --nospaces\n\tDisable automatic adding of \\:, use \"[]\" \"txt\",\"text\" or manually insert \\: instead. \n-h, --help\n\tDisplay this help message. \n-us, --usage\n\tPrint usage guide.\n-dy, --dictionary\n\tPrint list defined symbols.") 1113 | os.exit(0) 1114 | elseif arg[i] == "-us" or arg[i] == "--usage" then 1115 | print("Special tokens: \n . - line containing only a single dot signals end of expression.\n ## - signals a beginning, as well as end of a comment. \n expr,{{ - place function as an argument for other function.\n end,}} - end last opened function. \nFunctions:\nmatrix rows end -- generate matrices.\nMatrix types: matrix, (matrix, {matrix, [matrix, |matrix, ||matrix\namatrix matrix_type element number_a number_b end - generate matrices with element numeration\ncases lines end - generate cases\nsub token, substack lines end - adds sub-value to the token\npow, ^ - rises token to the power of value\nlog a b - generates log\nroot a b - generates root\nbinom a b, () a b - generates binomial\nlim a b - generates limit\nsum start upperbound, prod start upperbound - generates sum or product\n// a b endfractions, fraction a b endf, cfrac a b endf - generates continous fractions\ntxt tokens end ,text tokens end - generates plain text\nboxed tokens end - puts a box around text\nunderbrace token text end, overbrace token text end - puts underbrace/overbrace above/beneath token. Text as expr ... end") 1116 | os.exit(0) 1117 | elseif arg[i] == "-dy" or arg[i] == "--dictionary" then 1118 | dictionary() 1119 | os.exit(0) 1120 | elseif arg[i] == "-s" or arg[i] == "--silent" then 1121 | silent=true 1122 | end 1123 | i = i + 1 1124 | end 1125 | 1126 | -- ENV variables 1127 | 1128 | if color then 1129 | Answer = color 1130 | else 1131 | Answer = "" 1132 | end 1133 | 1134 | -- Global variables 1135 | -- 1136 | tokens = {}; -- User input tokens 1137 | result = {}; -- Resulting answer tokens 1138 | fracn = 0; -- Number of continous fractions. 1139 | confrac = false; -- Are there any opened continous fractions? 1140 | matrixEndSign = "" -- Matrix type 1141 | _ = 0; -- MOST IMPORTANT VARIABLE 1142 | End_Of_Expression = "." 1143 | 1144 | if(not silent) then 1145 | print("Insert expression: \n\n"); 1146 | end 1147 | 1148 | local lines = {} 1149 | while true do 1150 | expression = io.read("*l"); 1151 | if expression == End_Of_Expression then 1152 | break 1153 | else 1154 | table.insert(lines, expression) 1155 | end 1156 | end 1157 | 1158 | 1159 | 1160 | 1161 | --Building table of tokens from input provided by user 1162 | local delimiter; 1163 | for j,v in ipairs(lines) do 1164 | delimiter = 1 1165 | i = 1 1166 | while i <= v:len() do 1167 | if i == v:len() then 1168 | if v:sub(i,i) == " " then 1169 | table.insert(tokens,v:sub(delimiter, i-1)) 1170 | nextToken() 1171 | else 1172 | table.insert(tokens,v:sub(delimiter, i)) 1173 | nextToken() 1174 | end 1175 | nextToken() 1176 | elseif v:sub(i,i) == " " or v:sub(i,i) == "\t" then 1177 | table.insert(tokens, v:sub(delimiter, i-1)) 1178 | nextToken() 1179 | delimiter = i+1 1180 | if v:sub(i,i) == " " and spaces then 1181 | if _ > 0 and currentToken == "substack" or currentToken == "cases" or isMember(currentToken,matrixAliases) then 1182 | -- do nothing 1183 | elseif i + 2 <= v:len() then 1184 | if v:sub(i+1, i+2) == "}}" then 1185 | --do nothing 1186 | else 1187 | table.insert(tokens, ",,") 1188 | end 1189 | elseif i + 3 <= v:len() then 1190 | if v:sub(i+1, i+3) == "end" then 1191 | --do nothing 1192 | else 1193 | table.insert(tokens, ",,") 1194 | end 1195 | else 1196 | table.insert(tokens, ",,") 1197 | end 1198 | nextToken() 1199 | elseif v:sub(i,i) == "\t" and tabs then 1200 | table.insert(tokens, "tab") 1201 | nextToken() 1202 | end 1203 | end 1204 | ::continue:: 1205 | i = i + 1 1206 | end 1207 | if newlines then 1208 | if currentToken == "tabular" or currentToken == "substack" or currentToken == "cases" or isMember(currentToken,matrixAliases) then 1209 | -- do nothing 1210 | else 1211 | table.insert(tokens, "level") 1212 | end 1213 | end 1214 | end 1215 | 1216 | _ = 0 1217 | 1218 | 1219 | while _ <= #tokens do 1220 | nextToken() 1221 | if confrac then 1222 | skipSpaces() 1223 | if currentToken == "level" then 1224 | nextToken() 1225 | end 1226 | end 1227 | addSymbol() 1228 | end 1229 | 1230 | if confrac == true then 1231 | endfractions() 1232 | end 1233 | 1234 | Answer = Answer .. table.concat(result) 1235 | if (not silent) then 1236 | print("Resulting expression: \n\n") 1237 | end 1238 | print(Answer) 1239 | --------------------------------------------------------------------------------