TeX-my-math 0.201.2.0 → 0.202.0.0
raw patch · 5 files changed
+75/−59 lines, 5 filesdep ~HaTeX
Dependency ranges changed: HaTeX
Files
- Math/LaTeX/Internal/Display.hs +10/−3
- Math/LaTeX/Internal/MathExpr.hs +46/−49
- Math/LaTeX/Prelude.hs +7/−5
- TeX-my-math.cabal +2/−2
- test/PdfSnippets/MkSnippets.hs +10/−0
Math/LaTeX/Internal/Display.hs view
@@ -39,7 +39,9 @@ import Data.String (fromString) import Data.Char (isAlpha) +import GHC.Stack (HasCallStack) + infixl 1 >$ -- | Embed inline maths in a monadic chain of document-components. Space before -- the math is included automatically.@@ -91,7 +93,7 @@ -- referenced with 'LaTeX.ref'. (The label name will /not/ appear in the rendered -- document output; by default it will be just a number but you can tweak it with -- the terminator by including the desired tag in parentheses.)-equations :: (LaTeXC r, LaTeXSymbol σ)+equations :: (LaTeXC r, LaTeXSymbol σ, HasCallStack) => [(LaTeXMath σ, String)] -- ^ Equations to show, with label name. -> String -- ^ “Terminator” – this can include punctuation (when an equation@@ -110,8 +112,13 @@ terminator :: LaTeX (eqnum, terminator) = parseEqnum garnish -asSafeLabel :: String -> LaTeX-asSafeLabel = LaTeX.label . fromString . filter isAlpha+asSafeLabel :: HasCallStack => String -> LaTeX+asSafeLabel lbl+ | all safeChar lbl = LaTeX.label . raw $ fromString lbl+ | otherwise = error $ "Labels can only contain alphabetic characters or “"+ ++safeSpecialChars++"”."+ where safeChar c = isAlpha c || c`elem`safeSpecialChars+ safeSpecialChars = "[]:/._" -- | Include a formula / equation system as a LaTeX display. maths :: (LaTeXC r, LaTeXSymbol σ)
Math/LaTeX/Internal/MathExpr.hs view
@@ -8,18 +8,19 @@ -- Portability : requires GHC>7 extensions -- -{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE RankNTypes #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE UndecidableInstances #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE UnicodeSyntax #-}-{-# LANGUAGE TemplateHaskell #-}-{-# LANGUAGE TupleSections #-}-{-# LANGUAGE ConstraintKinds #-}-{-# LANGUAGE CPP #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE UndecidableInstances #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE UnicodeSyntax #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TupleSections #-}+{-# LANGUAGE ConstraintKinds #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE NoMonomorphismRestriction #-} module Math.LaTeX.Internal.MathExpr where @@ -118,24 +119,29 @@ (∧) = opR 3 $ LaTeX.comm0"wedge" (∨) = opR 3 $ LaTeX.comm0"vee" -(∩), (∪), (-\-) :: MathsInfix+(∩), (∪), (⊎), (-\-), (⧵) :: MathsInfix infixr 3 ∩ (∩) = opR' 3 LaTeX.cap-infixr 2 ∪+infixr 2 ∪, ⊎ (∪) = opR' 2 LaTeX.cup-infixl 2 -\--(-\-) = opL' 2 LaTeX.setminus+(⊎) = opR' 2 LaTeX.uplus+infixl 2 -\-, ⧵+{-# DEPRECATED (-\-) "Use (⧵)" #-}+(-\-) = (⧵)+(⧵) = opL' 2 LaTeX.setminus -infixr 5 ⸪, -→, ↪-(⸪), (-→), (↪) :: MathsInfix+infixr 5 ⸪, -→, ←-, ↪+(⸪), (-→), (←-), (↪) :: MathsInfix (⸪) = opR 5 ":" (-→) = opR 5 LaTeX.to+(←-) = opR 5 LaTeX.leftarrow (↪) = opR 5 $ LaTeX.comm0"hookrightarrow" -infix 2 ∀:, ∃:+infix 2 ∀:, ∃:, ∄: (∀:), (∃:) :: MathsInfix (∀:) = opN 2 $ raw"\\ \\:\\forall{}" (∃:) = opN 2 $ raw"\\ \\:\\exists{}"+(∄:) = opN 2 $ raw"\\ \\:\\nexists{}" infixl 7 ° infixr 9 ◝, ⁀, ◝⁀@@ -234,7 +240,7 @@ -> Integrand γ (Infix l) (Encapsulation l) s⁰ d x f = Integrand $ opR 7 LaTeX.space x f -infixr 8 ∫, ◞∫, ◞∮, ∑, ◞∑, ∏, ◞∏+infixr 8 ∫, ◞∫, ◞∮, ∑, ◞∑, ∏, ◞∏, ⋃, ◞⋃, ⋂, ◞⋂, ⨄, ◞⨄ (∫) :: LaTeXC l => ( CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l)@@ -266,47 +272,32 @@ (encapsulation (raw "\\oint_{") (raw "}\\!\\!\\!") ω) i -(∑) :: LaTeXC l- => ( CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l)- , CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) )- -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l)- -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l)-(l,r)∑m- = Operator (Infix (Hs.Fixity 7 Hs.InfixR) $ raw" ")- (Operator (Infix (Hs.Fixity 9 Hs.InfixN) $ raw "^")- (encapsulation (raw "\\sum_{") (raw "}") l)- (encapsulation (raw "{") (raw "}") r) )- m--(◞∑) :: LaTeXC l- => CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l)- -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l)- -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l)-ω◞∑m- = Operator (Infix (Hs.Fixity 7 Hs.InfixR) $ raw " ")- (encapsulation (raw "\\sum_{") (raw "}") ω)- m--(∏) :: LaTeXC l+(∑), (∏), (⋃), (⋂), (⨄) :: LaTeXC l => ( CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) , CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) ) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l)-(l,r)∏m- = Operator (Infix (Hs.Fixity 7 Hs.InfixR) $ raw" ")+[(∑), (∏), (⋃), (⋂), (⨄)]+ = [ \(l,r) m+ -> Operator (Infix (Hs.Fixity 7 Hs.InfixR) $ raw" ") (Operator (Infix (Hs.Fixity 9 Hs.InfixN) $ raw "^")- (encapsulation (raw "\\prod_{") (raw "}") l)+ (encapsulation (raw ("\\"<>opraw<>"_{")) (raw "}") l) (encapsulation (raw "{") (raw "}") r) ) m+ | opraw <- ["sum", "prod", "bigcup", "bigcap", "biguplus"]+ ] -(◞∏) :: LaTeXC l+(◞∑), (◞∏), (◞⋃), (◞⋂), (◞⨄) :: LaTeXC l => CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l)-ω◞∏m- = Operator (Infix (Hs.Fixity 7 Hs.InfixR) $ raw " ")- (encapsulation (raw "\\prod_{") (raw "}") ω)+[(◞∑), (◞∏), (◞⋃), (◞⋂), (◞⨄)]+ = [ \ω m+ -> Operator (Infix (Hs.Fixity 7 Hs.InfixR) $ raw " ")+ (encapsulation (raw ("\\"<>opraw<>"_{")) (raw "}") ω) m+ | opraw <- ["sum", "prod", "bigcup", "bigcap", "biguplus"]+ ] norm :: LaTeXC l => CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l)@@ -357,6 +348,12 @@ tup = encapsulation (raw"\\left(") (raw"\\right)") intv = encapsulation (raw"\\left[") (raw"\\right]") nobreaks = encapsulation (raw"{") (raw"}")++setCompr :: LaTeXC l+ => CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l)+ -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l)+ -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l)+setCompr elm cnd = set $ opR 0 (raw"\\middle|") elm cnd infix 5 <.<, ≤.<, <.≤, ≤.≤
Math/LaTeX/Prelude.hs view
@@ -34,11 +34,13 @@ , (◝), (◝⁀), (◞), (◞◝), (|◞), (|◝), (|◞◝) , (⩵), (≡), (⩵!), (≠), (⪡), (⪢), (≤), (≥), (≪), (≫), (∝), (⟂), (∥), (₌₌) , (=→), (←=), (≈), (∼), (≃), (≅)- , (⊂), (/⊂), (⊆), (⊃), (⊇), (∋), (∌), (∈), (∉), (∩), (∪), (-\-), (⸪), (⊕)- , (∀:), (∃:)- , (-→), (↦), (↪), (==>), (<==), (<=>), (∧), (∨)- , (∫), (◞∫), (◞∮), d, (∑), (◞∑), (∏), (◞∏), del, nabla- , (<.<), (≤.<), (<.≤), (≤.≤), (±), (∓), set, tup, intv+ , (⊂), (/⊂), (⊆), (⊃), (⊇), (∋), (∌), (∈), (∉), (∩), (∪), (⊎), (-\-), (⧵), (⸪), (⊕)+ , (∀:), (∃:), (∄:)+ , (-→), (←-), (↦), (↪), (==>), (<==), (<=>), (∧), (∨)+ , (∫), (◞∫), (◞∮), d, (∑), (◞∑), (∏), (◞∏)+ , (⋃), (◞⋃), (⋂), (◞⋂), (⨄), (◞⨄)+ , del, nabla+ , (<.<), (≤.<), (<.≤), (≤.≤), (±), (∓), set, setCompr, tup, intv , infty, norm , nobreaks, matrix, cases -- * Algebraic manipulation
TeX-my-math.cabal view
@@ -1,5 +1,5 @@ Name: TeX-my-math-Version: 0.201.2.0+Version: 0.202.0.0 Category: math Synopsis: Render general Haskell math to LaTeX. Or: math typesetting with high signal-to-noise–ratio. Description: For tl;dr: look at <https://github.com/leftaroundabout/Symbolic-math-HaTeX/blob/master/EXAMPLES.md>.@@ -42,7 +42,7 @@ Library Build-Depends: base>=4.8 && <4.14- , HaTeX>3.19+ , HaTeX>3.22.2.0 , vector-space , dumb-cas >= 0.2 && < 0.3 , decimal-literals
test/PdfSnippets/MkSnippets.hs view
@@ -159,6 +159,16 @@ , [mkLaTeXSnip| 𝑚 * ((1+2)<>(3+4)) |] "m{\\cdot}\\left(1+23+4\\right)" ]+ , testGroup "Set-builders"+ [ [mkLaTeXSnip| set(3،4،5) |]+ "\\left\\{3,4,5\\right\\}"+ , [mkLaTeXSnip| setCompr (𝑥◝2) (𝑥∈ℕ) |]+ "\\left\\{x^{2}\\middle|x\\in{}\\mathbb{N}\\right\\}"+ , [mkLaTeXSnip| setCompr (𝑥/𝑦) (𝑥∈ℤ، 𝑦∈ℕ، 𝑦⪢0) |]+ "\\left\\{\\frac{x}{y}\\middle|x\\in{}\\mathbb{Z},y\\in{}\\mathbb{N},y>0\\right\\}"+ , [mkLaTeXSnip| setCompr (𝑥،𝑦) (𝑥∈ℤ، 𝑦∈ℝ) |]+ "\\left\\{\\left(x,y\\right)\\middle|x\\in{}\\mathbb{Z},y\\in{}\\mathbb{R}\\right\\}"+ ] , testGroup "Misc" [ [mkLaTeXSnip| 3*𝑧 - 1 |] "3{\\cdot}z-1"