TeX-my-math-0.202.1.0: Render general Haskell math to LaTeX. Or: math typesetting with high signal-to-noise–ratio.

Copyright(c) Justus Sagemüller 2017
LicenseGPL v3
Maintainer(@) jsag $ hvl.no
Stabilityexperimental
Portabilityrequires GHC>7 extensions
Safe HaskellNone
LanguageHaskell2010

Math.LaTeX.Prelude

Contents

Description

 

Synopsis

Documentation

type LaTeXMath σ = CAS (Infix LaTeX) (Encapsulation LaTeX) (SymbolD σ LaTeX) Source #

Mathematical expressions to be typeset in LaTeX. Most of the functions in this library have more generic signatures, but all can be used with this type.

The σ parameter specifies how single-symbol “literals” are used in your Haskell code.

Primitive symbols

type LaTeXSymbol σ = (SymbolClass σ, SCConstraint σ LaTeX) Source #

The CAS.Dumb.Symbols.Unicode.* modules offer symbols that can be rendered in LaTeX.

Unicode literals

This module offers a “WYSiWYG” style, with italic Unicode math symbols (U+1d44e 𝑎 - U+1d467 𝑧) coming out as standard italic symbols \(a\) - \(z\), bold Unicode math symbols (U+1d41a 𝐚 - U+1d433 𝐳) coming out as bold \(\mathbf{a}\) - \(\mathbf{z}\) and so on. Greek letters can be used from the standard block (U+3b1 α → \(\alpha\) - U+3c9 ω → \(\omega\)). All of this also works for uppercase letters (it circumvents Haskell syntax restrictions by using the PatternSynonyms extension).

Upright (roman) symbols are not directly supported, but if you import Math.LaTeX.StringLiterals they can be written as strings.

Example: 𝑎 + 𝐛 + 𝐶 + "D" + ε + Φ ∈ ℝ is rendered as \(a + \mathbf{b} + C + \text{D} + \varepsilon + \Phi \in \mathbb{R}\).

The Bopomofo symbols here are not exported for use in documents but for Algebraic manipulation.

Custom symbol-literals

If you prefer using instead e.g. ASCII letters A - z for simple symbols \(A\) - \(z\), use this import list:

import Math.LaTeX.Prelude hiding ((>$), (<>$))
import Math.LaTeX.Internal.Display ((>$), (<>$))
import CAS.Dumb.Symbols.ASCII

We give no guarantee that this will work without name clashes or type ambiguities.

Symbol modifiers

(%$>) :: (SymbolClass σ, SCConstraint σ c) => (c -> c') -> CAS' γ s² s¹ (SymbolD σ c) -> CAS' γ s² s¹ (SymbolD σ c') infixl 4 #

Transform the symbols of an expression, in their underlying representation.

(map succ%$> 𝑎+𝑝) * 𝑥  ≡  (𝑏+𝑞) * 𝑥

Note that this can not be used with number literals.

prime :: LaTeXC l => l -> l Source #

dot :: LaTeXC l => l -> l Source #

Add a dot accent above a symbol, as used to denote a derivative, like \(\dot{x}\).

ddot :: LaTeXC l => l -> l Source #

Add a dot accent above a symbol, as used to denote a second derivative, like \(\ddot{y}\)

bar :: LaTeXC l => l -> l Source #

Add a bar accent above a symbol, like \(\bar{z}\).

hat :: LaTeXC l => l -> l Source #

Add a hat accent above a symbol, like \(\hat{x}\).

vec :: LaTeXC l => l -> l Source #

Add a vector arrow accent above a symbol, like \(\vec{v}\).

underline :: LaTeXC l => l -> l Source #

tilde :: LaTeXC l => l -> l Source #

Add a tilde accent above a symbol, like \(\tilde{y}\).

Maths operators

(°) :: MathsInfix infixl 7 Source #

(⁀) :: MathsInfix infixr 9 Source #

(...) :: MathsInfix infixr 0 Source #

(،) :: MathsInfix infixr 0 Source #

(␣) :: MathsInfix infixr 0 Source #

(×) :: MathsInfix infixl 7 Source #

(∗) :: LaTeXC l => CAS' γ (Infix l) (Encapsulation l) s⁰ -> CAS' γ (Infix l) (Encapsulation l) s⁰ -> CAS' γ (Infix l) (Encapsulation l) s⁰ Source #

(⋆) :: LaTeXC l => CAS' γ (Infix l) (Encapsulation l) s⁰ -> CAS' γ (Infix l) (Encapsulation l) s⁰ -> CAS' γ (Infix l) (Encapsulation l) s⁰ Source #

(⊗) :: MathsInfix infixl 7 Source #

(∘) :: MathsInfix infixl 7 Source #

factorial :: LaTeXC l => CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) Source #

(◝) :: MathsInfix infixr 9 Source #

(◞) :: MathsInfix infixr 9 Source #

(◞◝) :: LaTeXC s => CAS' γ (Infix s) (Encapsulation s) (SymbolD σ s) -> (CAS' γ (Infix s) (Encapsulation s) (SymbolD σ s), CAS' γ (Infix s) (Encapsulation s) (SymbolD σ s)) -> CAS' γ (Infix s) (Encapsulation s) (SymbolD σ s) infixl 8 Source #

(|◝) :: LaTeXC s => CAS' γ (Infix s) (Encapsulation s) (SymbolD σ s) -> CAS' γ (Infix s) (Encapsulation s) (SymbolD σ s) -> CAS' γ (Infix s) (Encapsulation s) (SymbolD σ s) infixl 8 Source #

(|◞◝) :: LaTeXC s => CAS' γ (Infix s) (Encapsulation s) (SymbolD σ s) -> (CAS' γ (Infix s) (Encapsulation s) (SymbolD σ s), CAS' γ (Infix s) (Encapsulation s) (SymbolD σ s)) -> CAS' γ (Infix s) (Encapsulation s) (SymbolD σ s) infixl 8 Source #

(⩵) :: MathsInfix infixl 4 Source #

(≡) :: MathsInfix infixl 4 Source #

(≠) :: MathsInfix infixl 4 Source #

(⪡) :: MathsInfix infixl 4 Source #

(⪢) :: MathsInfix infixl 4 Source #

(≤) :: MathsInfix infixl 4 Source #

(≥) :: MathsInfix infixl 4 Source #

(≪) :: MathsInfix infixl 4 Source #

(≫) :: MathsInfix infixl 4 Source #

(∝) :: MathsInfix infixl 4 Source #

(⟂) :: MathsInfix infixl 4 Source #

(∥) :: MathsInfix infixl 4 Source #

(≈) :: MathsInfix infixl 4 Source #

(∼) :: MathsInfix infixl 4 Source #

(≃) :: MathsInfix infixl 4 Source #

(≅) :: MathsInfix infixl 4 Source #

(⊂) :: MathsInfix infixl 4 Source #

(⊆) :: MathsInfix infixl 4 Source #

(⊃) :: MathsInfix infixl 4 Source #

(⊇) :: MathsInfix infixl 4 Source #

(∋) :: MathsInfix infixl 4 Source #

(∌) :: MathsInfix infixl 4 Source #

(∈) :: MathsInfix infixl 4 Source #

(∉) :: MathsInfix infixl 4 Source #

(∩) :: MathsInfix infixr 3 Source #

(∪) :: MathsInfix infixr 2 Source #

(⊎) :: MathsInfix infixr 2 Source #

(∖) :: LaTeXC l => CAS' γ (Infix l) (Encapsulation l) s⁰ -> CAS' γ (Infix l) (Encapsulation l) s⁰ -> CAS' γ (Infix l) (Encapsulation l) s⁰ infixl 2 Source #

(-\-) :: MathsInfix infixl 2 Source #

Deprecated: Use (∖), i.e. U+2216 SET MINUS

(⧵) :: MathsInfix infixl 2 Source #

Deprecated: Use (∖), i.e. U+2216 SET MINUS. (You used U+29F5 REVERSE SOLIDUS OPERATOR)

(⸪) :: MathsInfix infixr 5 Source #

(⊕) :: MathsInfix infixl 6 Source #

(∄:) :: LaTeXC l => CAS' γ (Infix l) (Encapsulation l) s⁰ -> CAS' γ (Infix l) (Encapsulation l) s⁰ -> CAS' γ (Infix l) (Encapsulation l) s⁰ infix 2 Source #

(↦) :: MathsInfix infixl 4 Source #

(↪) :: MathsInfix infixr 5 Source #

(==>) :: MathsInfix infixl 1 Source #

(<==) :: MathsInfix infixl 1 Source #

(<=>) :: MathsInfix infixl 1 Source #

(∧) :: MathsInfix infixr 3 Source #

(∨) :: MathsInfix infixr 3 Source #

(∫) :: LaTeXC l => (CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l), CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l)) -> Integrand γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) infixr 8 Source #

(◞∫) :: LaTeXC l => CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) -> Integrand γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) infixr 8 Source #

(◞∮) :: LaTeXC l => CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) -> Integrand γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) infixr 8 Source #

d :: LaTeXC l => CAS' γ (Infix l) (Encapsulation l) s⁰ -> CAS' γ (Infix l) (Encapsulation l) s⁰ -> Integrand γ (Infix l) (Encapsulation l) s⁰ Source #

(∑) :: 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) infixr 8 Source #

(◞∑) :: LaTeXC l => CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) infixr 8 Source #

(∏) :: 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) infixr 8 Source #

(◞∏) :: LaTeXC l => CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) infixr 8 Source #

(⋃) :: 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) infixr 8 Source #

(◞⋃) :: LaTeXC l => CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) infixr 8 Source #

(⋂) :: 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) infixr 8 Source #

(◞⋂) :: LaTeXC l => CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) infixr 8 Source #

(⨄) :: 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) infixr 8 Source #

(◞⨄) :: LaTeXC l => CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) infixr 8 Source #

del :: (SymbolClass σ, SCConstraint σ LaTeX) => CAS' γ s² s¹ (SymbolD σ LaTeX) Source #

nabla :: (SymbolClass σ, SCConstraint σ LaTeX) => CAS' γ s² s¹ (SymbolD σ LaTeX) Source #

(±) :: MathsInfix infixl 6 Source #

(∓) :: MathsInfix infixl 6 Source #

set :: LaTeXC l => CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) Source #

setCompr :: LaTeXC l => CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) Source #

tup :: LaTeXC l => CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) Source #

intv :: LaTeXC l => CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) Source #

infty :: (SymbolClass σ, SCConstraint σ LaTeX) => CAS' γ s² s¹ (SymbolD σ LaTeX) Source #

norm :: LaTeXC l => CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) Source #

nobreaks :: LaTeXC l => CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) Source #

matrix :: LaTeXC l => [[CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l)]] -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) Source #

cases :: LaTeXC l => [(CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l), LaTeX)] -> CAS' γ (Infix l) (Encapsulation l) (SymbolD σ l) Source #

Algebraic manipulation

(&~~!) :: (Eq l, Eq (Encapsulation l), SymbolClass σ, SCConstraint σ l, Show (AlgebraExpr σ l), Show (AlgebraPattern σ l)) => AlgebraExpr σ l -> [AlgebraPattern σ l] -> AlgebraExpr σ l infixl 1 #

Apply a sequence of pattern-transformations and yield the result concatenated to the original via the corresponding chain-operator. Because only the rightmost expression in a chain is processed, this can be iterated, giving a chain of intermediate results.

If one of the patterns does not match, this manipulator will raise an error.

(&~~:) :: (Eq l, Eq (Encapsulation l), SymbolClass σ, SCConstraint σ l, Show (AlgebraExpr σ l), Show (AlgebraPattern σ l)) => AlgebraExpr σ l -> [AlgebraPattern σ l] -> AlgebraExpr σ l infixl 1 #

Apply a sequence of pattern-transformations, each in every spot possible, and yield the result concatenated to the original via the corresponding chain-operator. Because only the rightmost expression in a chain is processed, this can be iterated, giving a chain of intermediate results.

continueExpr #

Arguments

:: (Eq l, Monoid l) 
=> (AlgebraExpr' γ σ l -> AlgebraExpr' γ σ l -> AlgebraExpr' γ σ l)

Combinator to use for chaining the new expression to the old ones

-> (AlgebraExpr' γ σ l -> AlgebraExpr' γ σ l)

Transformation to apply to the rightmost expression in the previous chain

-> AlgebraExpr' γ σ l

Transformation which appends the result.

-> AlgebraExpr' γ σ l 

(&) :: a -> (a -> b) -> b infixl 1 Source #

& is a reverse application operator. This provides notational convenience. Its precedence is one higher than that of the forward application operator $, which allows & to be nested in $.

Since: 4.8.0.0

(&~:) :: (Eq s⁰, Eq s¹, Eq s²) => CAS s² s¹ s⁰ -> Eqspattern s² s¹ s⁰ -> CAS s² s¹ s⁰ infixl 1 #

expr &~: pat :=: rep replaces every occurence of pat within expr with rep.

For example, 𝑎·𝑏𝑐·𝑑 &~: · :=: ㄘ·ㄅ yields 𝑏·𝑎 − 𝑑·𝑐.

(&~?) :: (Eq s⁰, Eq s¹, Eq s²) => CAS s² s¹ s⁰ -> Eqspattern s² s¹ s⁰ -> [CAS s² s¹ s⁰] infixl 1 #

expr &~? pat :=: rep gives every possible way pat can be replaced exactly once within expr.

For example, 𝑎·𝑏𝑐·𝑑 &~? · :=: ㄘ·ㄅ yields [𝑏·𝑎 − 𝑐·𝑑, 𝑎·𝑏 − 𝑑·𝑐].

(&~!) :: (Eq s⁰, Eq s¹, Eq s², Show (CAS s² s¹ s⁰), Show (CAS' GapId s² s¹ s⁰)) => CAS s² s¹ s⁰ -> Eqspattern s² s¹ s⁰ -> CAS s² s¹ s⁰ infixl 1 #

expr &~! pat :=: rep replaces pat exactly once in expr. If this is not possible, an error is raised. If multiple occurences match, the leftmost is preferred.

(|->) :: CAS' γ s² s¹ s⁰ -> CAS' γ s² s¹ s⁰ -> Equality' γ s² s¹ s⁰ infix 2 Source #

Use in documents

($<>) :: LaTeXC r => LaTeXMath__MathLatin_RomanGreek__BopomofoGaps -> r -> r infixr 6 Source #

Embed inline maths in a semigroup/monoidal chain of document-components.

    "If "<>𝑎$<>" and "<>𝑏$<>" are the lengths of the legs and "<>𝑐$<>
     " of the cathete of a right triangle, then "<>(𝑎◝2+𝑏◝2 ⩵ 𝑐◝2)$<>" holds."

This will be rendered as: If \(a\) and \(b\) are the lengths of the legs and \(c\) of the cathete of a right triangle, then \(a^2+b^2=c^2\) holds.

(>$) :: LaTeXC r => r -> LaTeXMath__MathLatin_RomanGreek__BopomofoGaps -> r infixl 1 Source #

Embed inline maths in a monadic chain of document-components. Space before the math is included automatically.

  do
    "If">$𝑎;" and">$𝑏;" are the lengths of the legs and">$𝑐
    " of the cathete of a right triangle, then">$ 𝑎◝2+𝑏◝2 ⩵ 𝑐◝2;" holds."

Note: these versions of the $<> and >$ operators have a signature that's monomorphic to unicode symbol-literals. (This restriction is to avoid ambiguous types when writing maths without any symbols in it, like simply embedding a fraction in inline text.) See Custom literals if this is a problem for you.

dmaths Source #

Arguments

:: (LaTeXC r, LaTeXSymbol σ) 
=> [[LaTeXMath σ]]

Equations to show.

-> String

“Terminator” – this can include punctuation (when an equation is at the end of a sentence in the preceding text).

-> r 

Include a formula / equation system as a LaTeX display. If it's a single equation, automatic line breaks are inserted (requires the breqn LaTeX package).

maths Source #

Arguments

:: (LaTeXC r, LaTeXSymbol σ) 
=> [[LaTeXMath σ]]

Equations to show.

-> String

“Terminator” – this can include punctuation (when an equation is at the end of a sentence in the preceding text).

-> r 

Include a formula / equation system as a LaTeX display.

equations Source #

Arguments

:: (LaTeXC r, LaTeXSymbol σ, HasCallStack) 
=> [(LaTeXMath σ, String)]

Equations to show, with label name.

-> String

“Terminator” – this can include punctuation (when an equation is at the end of a sentence in the preceding text).

-> r 

Include a set of equations or formulas, each with a LaTeX label that can be referenced with 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.)

dcalculation Source #

Arguments

:: (LaTeXC (m ()), LaTeXSymbol σ, Functor m) 
=> LaTeXMath σ

Computation chain to display.

-> String

“Terminator” – this can include punctuation (when an equation is at the end of a sentence in the preceding text).

-> m (LaTeXMath σ)

Yield the rightmost expression in the displayed computation (i.e. usually the final result in a chain of algebraic equalities).

Display an equation and also extract the final result. As with dmaths, automatic line breaks are inserted by breqn.

toMathLaTeX :: forall σ l. (l ~ LaTeX, SymbolClass σ, SCConstraint σ l) => CAS (Infix l) (Encapsulation l) (SymbolD σ l) -> l Source #