|
| 1 | +/************************************************************* |
| 2 | + * |
| 3 | + * Copyright (c) 2018 The MathJax Consortium |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | + |
| 19 | +/** |
| 20 | + * @fileoverview Mappings for TeX parsing of the physics package. |
| 21 | + * |
| 22 | + * @author [email protected] (Volker Sorge) |
| 23 | + */ |
| 24 | + |
| 25 | +import {CommandMap, MacroMap} from '../SymbolMap.js'; |
| 26 | +import PhysicsMethods from './PhysicsMethods.js'; |
| 27 | +import {TexConstant} from '../TexConstants.js'; |
| 28 | + |
| 29 | + |
| 30 | +/** |
| 31 | + * Macros for physics package. |
| 32 | + */ |
| 33 | +new CommandMap('Physics-automatic-bracing-macros', { |
| 34 | + 'quantity': 'Quantity', |
| 35 | + 'qty': 'Quantity', |
| 36 | + 'pqty': ['Quantity', '(', ')', true], |
| 37 | + 'bqty': ['Quantity', '[', ']', true], |
| 38 | + 'vqty': ['Quantity', '|', '|', true], |
| 39 | + 'Bqty': ['Quantity', '{', '}', true], |
| 40 | + 'absolutevalue': ['Quantity', '|', '|', true], |
| 41 | + 'abs': ['Quantity', '|', '|', true], |
| 42 | + 'norm': ['Quantity', '\\|', '\\|', true], |
| 43 | + 'evaluated': 'Eval', |
| 44 | + 'eval': 'Eval', |
| 45 | + 'order': ['Quantity', '(', ')', true, 'O', |
| 46 | + TexConstant.Variant.CALIGRAPHIC], |
| 47 | + 'commutator': 'Commutator', |
| 48 | + 'comm': 'Commutator', |
| 49 | + 'anticommutator': ['Commutator', '\\{', '\\}'], |
| 50 | + 'acomm': ['Commutator', '\\{', '\\}'], |
| 51 | + 'poissonbracket': ['Commutator', '\\{', '\\}'], |
| 52 | + 'pb': ['Commutator', '\\{', '\\}'] |
| 53 | +}, PhysicsMethods); |
| 54 | + |
| 55 | + |
| 56 | +new CommandMap('Physics-expressions-macros', { |
| 57 | + 'sin': 'Expression', |
| 58 | + 'sinh': 'Expression', |
| 59 | + 'arcsin': 'Expression', |
| 60 | + 'asin': 'Expression', |
| 61 | + 'cos': 'Expression', |
| 62 | + 'cosh': 'Expression', |
| 63 | + 'arccos': 'Expression', |
| 64 | + 'acos': 'Expression', |
| 65 | + 'tan': 'Expression', |
| 66 | + 'tanh': 'Expression', |
| 67 | + 'arctan': 'Expression', |
| 68 | + 'atan': 'Expression', |
| 69 | + 'csc': 'Expression', |
| 70 | + 'csch': 'Expression', |
| 71 | + 'arccsc': 'Expression', |
| 72 | + 'acsc': 'Expression', |
| 73 | + 'sec': 'Expression', |
| 74 | + 'sech': 'Expression', |
| 75 | + 'arcsec': 'Expression', |
| 76 | + 'asec': 'Expression', |
| 77 | + 'cot': 'Expression', |
| 78 | + 'coth': 'Expression', |
| 79 | + 'arccot': 'Expression', |
| 80 | + 'acot': 'Expression', |
| 81 | + 'exp': ['Expression', false], |
| 82 | + 'log': 'Expression', |
| 83 | + 'ln': 'Expression', |
| 84 | + 'det': ['Expression', false], |
| 85 | + 'Pr': ['Expression', false], |
| 86 | + // New expressions. |
| 87 | + 'tr': ['Expression', false], |
| 88 | + 'trace': ['Expression', false, 'tr'], |
| 89 | + 'Tr': ['Expression', false], |
| 90 | + 'Trace': ['Expression', false, 'Tr'], |
| 91 | + 'rank': 'NamedFn', |
| 92 | + 'erf': ['Expression', false], |
| 93 | + // Old named functions. |
| 94 | + 'sine': ['NamedFn', 'sin'], |
| 95 | + 'hypsine': ['NamedFn', 'sinh'], |
| 96 | + 'arcsine': ['NamedFn', 'arcsin'], |
| 97 | + 'asine': ['NamedFn', 'asin'], |
| 98 | + 'cosine': ['NamedFn', 'cos'], |
| 99 | + 'hypcosine': ['NamedFn', 'cosh'], |
| 100 | + 'arccosine': ['NamedFn', 'arccos'], |
| 101 | + 'acosine': ['NamedFn', 'acos'], |
| 102 | + 'tangent': ['NamedFn', 'tan'], |
| 103 | + 'hyptangent': ['NamedFn', 'tanh'], |
| 104 | + 'arctangent': ['NamedFn', 'arctan'], |
| 105 | + 'atangent': ['NamedFn', 'atan'], |
| 106 | + 'cosecant': ['NamedFn', 'csc'], |
| 107 | + 'hypcosecant': ['NamedFn', 'csch'], |
| 108 | + 'arccosecant': ['NamedFn', 'arccsc'], |
| 109 | + 'acosecant': ['NamedFn', 'acsc'], |
| 110 | + 'secant': ['NamedFn', 'sec'], |
| 111 | + 'hypsecant': ['NamedFn', 'sech'], |
| 112 | + 'arcsecant': ['NamedFn', 'arcsec'], |
| 113 | + 'asecant': ['NamedFn', 'asec'], |
| 114 | + 'cotangent': ['NamedFn', 'cot'], |
| 115 | + 'hypcotangent': ['NamedFn', 'coth'], |
| 116 | + 'arccotangent': ['NamedFn', 'arccot'], |
| 117 | + 'acotangent': ['NamedFn', 'acot'], |
| 118 | + 'exponential': ['NamedFn', 'exp'], |
| 119 | + 'logarithm': ['NamedFn', 'log'], |
| 120 | + 'naturallogarithm': ['NamedFn', 'ln'], |
| 121 | + 'determinant': ['NamedFn', 'det'], |
| 122 | + 'Probability': ['NamedFn', 'Pr'], |
| 123 | +}, PhysicsMethods); |
| 124 | + |
| 125 | + |
| 126 | +new CommandMap('Physics-quick-quad-macros', { |
| 127 | + 'qqtext': 'Qqtext', |
| 128 | + 'qq': 'Qqtext', |
| 129 | + 'qcomma': ['Macro', '\\qqtext*{,}'], |
| 130 | + 'qc': ['Macro', '\\qqtext*{,}'], |
| 131 | + 'qcc': ['Qqtext', 'c.c.'], |
| 132 | + 'qif': ['Qqtext', 'if'], |
| 133 | + 'qthen': ['Qqtext', 'then'], |
| 134 | + 'qelse': ['Qqtext', 'else'], |
| 135 | + 'qotherwise': ['Qqtext', 'otherwise'], |
| 136 | + 'qunless': ['Qqtext', 'unless'], |
| 137 | + 'qgiven': ['Qqtext', 'given'], |
| 138 | + 'qusing': ['Qqtext', 'using'], |
| 139 | + 'qassume': ['Qqtext', 'assume'], |
| 140 | + 'qsince,': ['Qqtext', 'since,'], |
| 141 | + 'qlet': ['Qqtext', 'let'], |
| 142 | + 'qfor': ['Qqtext', 'for'], |
| 143 | + 'qall': ['Qqtext', 'all'], |
| 144 | + 'qeven': ['Qqtext', 'even'], |
| 145 | + 'qodd': ['Qqtext', 'odd'], |
| 146 | + 'qinteger': ['Qqtext', 'integer'], |
| 147 | + 'qand': ['Qqtext', 'and'], |
| 148 | + 'qor': ['Qqtext', 'or'], |
| 149 | + 'qas': ['Qqtext', 'as'], |
| 150 | + 'qin': ['Qqtext', 'in'], |
| 151 | +}, PhysicsMethods); |
0 commit comments