#if __GLASGOW_HASKELL__ >= 801
#else
#endif
module Text.LaTeX.Packages.AMSMath
(
amsmath
, math, mathDisplay
, equation , equation_
, align , align_
, cases
, eqref , nonumber
, autoParens
, autoSquareBrackets, autoBraces, autoAngleBrackets
, autoBrackets
, langle , rangle
, lfloor , rfloor
, lceil , rceil
, dblPipe
, (^:) , (!:), (!^)
, tsin , arcsin
, tcos , arccos
, ttan , arctan
, cot , arccot
, tsinh , tcosh , ttanh , coth
, sec , csc
, texp
, tlog , ln
, tsqrt
, operatorname
, tsum , sumFromTo
, prod , prodFromTo
, integral , integralFromTo
, partial, totald, partialOf, totaldOf
, (+-), (-+)
, cdot , times , div_
, frac, tfrac
, (*:) , star
, circ , bullet
, (=:) , (/=:)
, (<:) , (<=:)
, (>:) , (>=:)
, ll , gg
, equiv
, propto
, parallel
, perp
, in_ , ni , notin
, subset , supset
, cap , cup
, setminus
, vee , wedge
, oplus , ominus , otimes
, oslash , odot
, hat, tilde, bar, vec, widehat, widetilde
, dot, ddot, dddot
, overline
, alpha , beta , gamma
, gammau , delta , deltau
, epsilon , varepsilon , zeta
, eta , theta , vartheta , thetau
, iota , kappa , lambda
, lambdau , mu , nu
, xi , xiu , pi_
, varpi , piu , rho
, varrho , sigma , varsigma
, sigmau , tau , upsilon
, upsilonu , phi , varphi
, phiu , chi , psi
, psiu , omega , omegau
, pm , mp
, to , mapsto, implies
, forall , exists
, dagger, ddagger
, infty
, imath, jmath
, bot
, mathdefault
, mathbf
, mathrm
, text
, mathcal
, mathsf
, mathtt
, mathit
, pmatrix , bmatrix
, b2matrix , vmatrix
, v2matrix
, quad, qquad
, thinspace, medspace, thickspace, negspace, space
) where
import Text.LaTeX.Base
import Text.LaTeX.Base.Syntax
import Text.LaTeX.Base.Class
import Data.List
import Data.Ratio
import Data.Matrix
amsmath :: PackageName
amsmath = "amsmath"
math :: LaTeXC l => l -> l
math = liftL $ TeXMath Dollar
mathDisplay :: LaTeXC l => l -> l
mathDisplay = liftL $ TeXMath Square
instance Num LaTeX where
(+) = between "+"
() = between "-"
(*) = (<>)
negate = (TeXEmpty )
fromInteger = rendertex
abs = autoBrackets "|" "|"
signum = (operatorname "sgn" <>)
instance Fractional LaTeX where
(/) = frac
fromRational = rendertex . (fromRational :: Rational -> Double)
instance Floating LaTeX where
pi = pi_
exp = (texp <>)
sqrt = tsqrt Nothing
log = (tlog <>)
(**) = (^:)
logBase b x = (commS "log" !: b) <> x
sin = (tsin <>)
tan = (ttan <>)
cos = (tcos <>)
asin = (arcsin <>)
atan = (arctan <>)
acos = (arccos <>)
sinh = (tsinh <>)
tanh = (ttanh <>)
cosh = (tcosh <>)
asinh = (operatorname "arsinh" <>)
atanh = (operatorname "artanh" <>)
acosh = (operatorname "arcosh" <>)
#if !MIN_VERSION_base(4,5,0)
instance Eq (LaTeXT m a) where
_ == _ = error "Cannot use \"(==)\" Eq method with a LaTeXT value."
instance Show (LaTeXT m a) where
show _ = error "Cannot use \"show\" Show method with a LaTeXT value."
#endif
instance (Monad m, a ~ ()) => Num (LaTeXT m a) where
(+) = liftOp (+)
() = liftOp ()
(*) = (>>)
negate = liftFun negate
fromInteger = fromLaTeX . fromInteger
abs = liftFun abs
signum = liftFun signum
instance (Monad m, a ~ ()) => Fractional (LaTeXT m a) where
(/) = liftOp (/)
fromRational = fromLaTeX . fromRational
instance (Monad m, a ~ ()) => Floating (LaTeXT m a) where
pi = pi_
exp = liftFun exp
sqrt = liftFun sqrt
log = liftFun log
(**) = liftOp (**)
logBase = liftOp logBase
sin = liftFun sin
tan = liftFun tan
cos = liftFun cos
asin = liftFun asin
atan = liftFun atan
acos = liftFun acos
sinh = liftFun sinh
tanh = liftFun tanh
cosh = liftFun cosh
asinh = liftFun asinh
atanh = liftFun atanh
acosh = liftFun acosh
eqref :: LaTeXC l => l -> l
eqref = liftL $ \l -> TeXComm "eqref" [FixArg . TeXRaw $ render l]
nonumber :: LaTeXC l => l
nonumber = comm0 "nonumber"
equation :: LaTeXC l => l -> l
equation = liftL $ TeXEnv "equation" []
equation_ :: LaTeXC l => l -> l
equation_ = liftL $ TeXEnv "equation*" []
align :: LaTeXC l => [l] -> l
align = liftL(TeXEnv "align" []) . mconcat . intersperse lnbk
align_ :: LaTeXC l => [l] -> l
align_ = liftL(TeXEnv "align*" []) . mconcat . intersperse lnbk
cases :: LaTeXC l => l -> l
cases = liftL $ TeXEnv "cases" []
autoParens :: LaTeXC l => l -> l
autoParens x = commS "left(" <> x <> commS "right)"
autoSquareBrackets :: LaTeXC l => l -> l
autoSquareBrackets x = commS "left[" <> x <> commS "right]"
autoBraces :: LaTeXC l => l -> l
autoBraces x = commS "left"<>"{" <> x <> commS "right"<>"}"
autoAngleBrackets :: LaTeXC l => l -> l
autoAngleBrackets x = commS "left"<>langle <> x <> commS "right"<>rangle
autoBrackets :: LaTeXC l => LaTeX -> LaTeX -> l -> l
autoBrackets lBrack rBrack x
= commS "left" <> fromLaTeX lBrack <> x <> commS "right" <> fromLaTeX rBrack
langle :: LaTeXC l => l
langle = comm0 "langle"
rangle :: LaTeXC l => l
rangle = comm0 "rangle"
lfloor :: LaTeXC l => l
lfloor = comm0 "lfloor"
rfloor :: LaTeXC l => l
rfloor = comm0 "rfloor"
lceil :: LaTeXC l => l
lceil = comm0 "lceil"
rceil :: LaTeXC l => l
rceil = comm0 "rceil"
dblPipe :: LaTeXC l => l
dblPipe = comm0 "|"
(^:) :: LaTeXC l => l -> l -> l
x ^: y = braces x <> raw "^" <> braces y
(!:) :: LaTeXC l => l -> l -> l
x !: y = braces x <> raw "_" <> braces y
(!^) :: LaTeXC l => l -> (l,l) -> l
x !^ (y,z) = braces x <> raw "_" <> braces y <> raw "^" <> braces z
tsin :: LaTeXC l => l
tsin = comm0 "sin"
arcsin :: LaTeXC l => l
arcsin = comm0 "arcsin"
tcos :: LaTeXC l => l
tcos = comm0 "cos"
arccos :: LaTeXC l => l
arccos = comm0 "arccos"
ttan :: LaTeXC l => l
ttan = comm0 "tan"
arctan :: LaTeXC l => l
arctan = comm0 "arctan"
cot :: LaTeXC l => l
cot = comm0 "cot"
arccot :: LaTeXC l => l
arccot = comm0 "arccot"
tsinh :: LaTeXC l => l
tsinh = comm0 "sinh"
tcosh :: LaTeXC l => l
tcosh = comm0 "cosh"
ttanh :: LaTeXC l => l
ttanh = comm0 "tanh"
coth :: LaTeXC l => l
coth = comm0 "coth"
sec :: LaTeXC l => l
sec = comm0 "sec"
csc :: LaTeXC l => l
csc = comm0 "csc"
texp :: LaTeXC l => l
texp = comm0 "exp"
tlog :: LaTeXC l => l
tlog = comm0 "log"
ln :: LaTeXC l => l
ln = comm0 "ln"
tsqrt :: LaTeXC l => Maybe l -> l -> l
tsqrt Nothing = liftL $ \x -> TeXComm "sqrt" [FixArg x]
tsqrt (Just n) = liftL2 (\m x -> TeXComm "sqrt" [OptArg m, FixArg x]) n
operatorname :: LaTeXC l => l -> l
operatorname = comm1 "operatorname"
tsum :: LaTeXC l => l
tsum = comm0 "sum"
sumFromTo :: LaTeXC l
=> l
-> l
-> l
sumFromTo x y = commS "sum" <> raw"_" <> braces x <> raw"^" <> braces y
prod :: LaTeXC l => l
prod = comm0 "prod"
prodFromTo :: LaTeXC l
=> l
-> l
-> l
prodFromTo x y = commS "prod" <> raw"_" <> braces x <> raw"^" <> braces y
integral :: LaTeXC l => l
integral = comm0 "int"
integralFromTo :: LaTeXC l
=> l
-> l
-> l
integralFromTo x y = commS "int" <> commS "limits" <> raw"_" <> braces x <> raw"^" <> braces y
partial :: LaTeXC l => l
partial = comm0 "partial"
totald :: LaTeXC l => l
totald = mathrm "d"
partialOf :: LaTeXC l => l -> l
partialOf v = comm0 "partial" <> v
totaldOf :: LaTeXC l => l -> l
totaldOf v = mathrm "d" <> v
notop :: LaTeXC l =>
(l -> l -> l)
-> l -> l -> l
notop op =
\l1 l2 ->
(l1 <> commS "not") `op` l2
infixl 6 +-, -+
(+-) :: LaTeXC l => l -> l -> l
(+-) = between $ comm0 "pm"
(-+) :: LaTeXC l => l -> l -> l
(-+) = between $ comm0 "mp"
cdot :: LaTeXC l => l -> l -> l
cdot = between $ comm0 "cdot"
times :: LaTeXC l => l -> l -> l
times = between $ comm0 "times"
div_ :: LaTeXC l => l -> l -> l
div_ = between $ comm0 "div"
frac :: LaTeXC l => l -> l -> l
frac = liftL2 $ \p q -> TeXComm "frac" [FixArg p, FixArg q]
tfrac :: LaTeXC l => l -> l -> l
tfrac = liftL2 $ \p q -> TeXComm "tfrac" [FixArg p, FixArg q]
infixl 7 *:
(*:) :: LaTeXC l => l -> l -> l
(*:) = between $ comm0 "ast"
star :: LaTeXC l => l -> l -> l
star = between $ comm0 "star"
circ :: LaTeXC l => l -> l -> l
circ = between $ comm0 "circ"
bullet :: LaTeXC l => l -> l -> l
bullet = between $ comm0 "bullet"
infixr 4 =: , /=:
(=:) :: LaTeXC l => l -> l -> l
(=:) = between "="
(/=:) :: LaTeXC l => l -> l -> l
(/=:) = notop (=:)
(>:) :: LaTeXC l => l -> l -> l
(>:) = between ">"
(>=:) :: LaTeXC l => l -> l -> l
(>=:) = between $ comm0 "geq"
(<:) :: LaTeXC l => l -> l -> l
(<:) = between "<"
(<=:) :: LaTeXC l => l -> l -> l
(<=:) = between $ comm0 "leq"
ll :: LaTeXC l => l -> l -> l
ll = between $ comm0 "ll"
gg :: LaTeXC l => l -> l -> l
gg = between $ comm0 "gg"
propto :: LaTeXC l => l -> l -> l
propto = between $ comm0 "propto"
perp :: LaTeXC l => l -> l -> l
perp = between $ comm0 "perp"
parallel :: LaTeXC l => l -> l -> l
parallel = between $ comm0 "parallel"
equiv :: LaTeXC l => l -> l -> l
equiv = between $ comm0 "equiv"
in_ :: LaTeXC l => l -> l -> l
in_ = between $ comm0 "in"
ni :: LaTeXC l => l -> l -> l
ni = between $ comm0 "ni"
notin :: LaTeXC l => l -> l -> l
notin = between $ comm0 "notin"
subset :: LaTeXC l => l -> l -> l
subset = between $ comm0 "subset"
supset :: LaTeXC l => l -> l -> l
supset = between $ comm0 "supset"
cap :: LaTeXC l => l -> l -> l
cap = between $ comm0 "cap"
cup :: LaTeXC l => l -> l -> l
cup = between $ comm0 "cup"
setminus :: LaTeXC l => l -> l -> l
setminus = between $ comm0 "setminus"
vee :: LaTeXC l => l -> l -> l
vee = between $ comm0 "vee"
wedge :: LaTeXC l => l -> l -> l
wedge = between $ comm0 "wedge"
oplus :: LaTeXC l => l -> l -> l
oplus = between $ comm0 "oplus"
ominus :: LaTeXC l => l -> l -> l
ominus = between $ comm0 "ominus"
otimes :: LaTeXC l => l -> l -> l
otimes = between $ comm0 "otimes"
oslash :: LaTeXC l => l -> l -> l
oslash = between $ comm0 "oslash"
odot :: LaTeXC l => l -> l -> l
odot = between $ comm0 "odot"
hat :: LaTeXC l => l -> l
hat = comm1 "hat"
tilde :: LaTeXC l => l -> l
tilde = comm1 "tilde"
bar :: LaTeXC l => l -> l
bar = comm1 "bar"
vec :: LaTeXC l => l -> l
vec = comm1 "vec"
widehat :: LaTeXC l => l -> l
widehat = comm1 "widehat"
widetilde :: LaTeXC l => l -> l
widetilde = comm1 "widetilde"
dot :: LaTeXC l => l -> l
dot = comm1 "dot"
ddot :: LaTeXC l => l -> l
ddot = comm1 "ddot"
dddot :: LaTeXC l => l -> l
dddot = comm1 "dddot"
overline :: LaTeXC l => l -> l
overline = comm1 "overline"
alpha :: LaTeXC l => l
alpha = comm0 "alpha"
beta :: LaTeXC l => l
beta = comm0 "beta"
gamma :: LaTeXC l => l
gamma = comm0 "gamma"
gammau :: LaTeXC l => l
gammau = comm0 "Gamma"
delta :: LaTeXC l => l
delta = comm0 "delta"
deltau :: LaTeXC l => l
deltau = comm0 "Delta"
epsilon :: LaTeXC l => l
epsilon = comm0 "epsilon"
varepsilon :: LaTeXC l => l
varepsilon = comm0 "varepsilon"
zeta :: LaTeXC l => l
zeta = comm0 "zeta"
eta :: LaTeXC l => l
eta = comm0 "eta"
theta :: LaTeXC l => l
theta = comm0 "theta"
vartheta :: LaTeXC l => l
vartheta = comm0 "vartheta"
thetau :: LaTeXC l => l
thetau = comm0 "Theta"
iota :: LaTeXC l => l
iota = comm0 "iota"
kappa :: LaTeXC l => l
kappa = comm0 "kappa"
lambda :: LaTeXC l => l
lambda = comm0 "lambda"
lambdau :: LaTeXC l => l
lambdau = comm0 "Lambda"
mu :: LaTeXC l => l
mu = comm0 "mu"
nu :: LaTeXC l => l
nu = comm0 "nu"
xi :: LaTeXC l => l
xi = comm0 "xi"
xiu :: LaTeXC l => l
xiu = comm0 "Xi"
pi_ :: LaTeXC l => l
pi_ = comm0 "pi"
varpi :: LaTeXC l => l
varpi = comm0 "varpi"
piu :: LaTeXC l => l
piu = comm0 "Pi"
rho :: LaTeXC l => l
rho = comm0 "rho"
varrho :: LaTeXC l => l
varrho = comm0 "varrho"
sigma :: LaTeXC l => l
sigma = comm0 "sigma"
varsigma :: LaTeXC l => l
varsigma = comm0 "varsigma"
sigmau :: LaTeXC l => l
sigmau = comm0 "Sigma"
tau :: LaTeXC l => l
tau = comm0 "tau"
upsilon :: LaTeXC l => l
upsilon = comm0 "upsilon"
upsilonu :: LaTeXC l => l
upsilonu = comm0 "Upsilon"
phi :: LaTeXC l => l
phi = comm0 "phi"
varphi :: LaTeXC l => l
varphi = comm0 "varphi"
phiu :: LaTeXC l => l
phiu = comm0 "Phi"
chi :: LaTeXC l => l
chi = comm0 "chi"
psi :: LaTeXC l => l
psi = comm0 "psi"
psiu :: LaTeXC l => l
psiu = comm0 "Psi"
omega :: LaTeXC l => l
omega = comm0 "omega"
omegau :: LaTeXC l => l
omegau = comm0 "Omega"
pm :: LaTeXC l => l
pm = comm0 "pm"
mp :: LaTeXC l => l
mp = comm0 "mp"
to :: LaTeXC l => l
to = comm0 "to"
mapsto :: LaTeXC l => l
mapsto = comm0 "mapsto"
implies :: LaTeXC l => l
implies = comm0 "implies"
forall :: LaTeXC l => l
forall = comm0 "forall"
exists :: LaTeXC l => l
exists = comm0 "exists"
dagger :: LaTeXC l => l
dagger = comm0 "dagger"
ddagger :: LaTeXC l => l
ddagger = comm0 "ddagger"
infty :: LaTeXC l => l
infty = comm0 "infty"
imath :: LaTeXC l => l
imath = comm0 "imath"
jmath :: LaTeXC l => l
jmath = comm0 "jmath"
bot :: LaTeXC l => l
bot = comm0 "bot"
mathdefault :: LaTeXC l => l -> l
mathdefault = comm1 "mathdefault"
mathbf :: LaTeXC l => l -> l
mathbf = comm1 "mathbf"
mathrm :: LaTeXC l => l -> l
mathrm = comm1 "mathrm"
text :: LaTeXC l => l -> l
text = comm1 "text"
mathcal :: LaTeXC l => l -> l
mathcal = comm1 "mathcal"
mathsf :: LaTeXC l => l -> l
mathsf = comm1 "mathsf"
mathtt :: LaTeXC l => l -> l
mathtt = comm1 "mathtt"
mathit :: LaTeXC l => l -> l
mathit = comm1 "mathit"
matrix2tex :: (Texy a, LaTeXC l) => Matrix a -> l
matrix2tex m = mconcat
[ foldr1 (&) [ texy $ m ! (i,j)
| j <- [1 .. ncols m]
] <> lnbk
| i <- [1 .. nrows m]
]
toMatrix :: (Texy a, LaTeXC l) => String -> Maybe HPos -> Matrix a -> l
toMatrix str Nothing = liftL (TeXEnv str []) . matrix2tex
toMatrix str (Just p) = liftL (TeXEnv (str ++ "*") [OptArg $ rendertex p]) . matrix2tex
pmatrix :: (Texy a, LaTeXC l) => Maybe HPos -> Matrix a -> l
pmatrix = toMatrix "pmatrix"
bmatrix :: (Texy a, LaTeXC l) => Maybe HPos -> Matrix a -> l
bmatrix = toMatrix "bmatrix"
b2matrix :: (Texy a, LaTeXC l) => Maybe HPos -> Matrix a -> l
b2matrix = toMatrix "Bmatrix"
vmatrix :: (Texy a, LaTeXC l) => Maybe HPos -> Matrix a -> l
vmatrix = toMatrix "vmatrix"
v2matrix :: (Texy a, LaTeXC l) => Maybe HPos -> Matrix a -> l
v2matrix = toMatrix "Vmatrix"
#if MIN_VERSION_base(4,9,0)
instance Texy a => Texy (Ratio a) where
#else
instance (Integral a, Texy a) => Texy (Ratio a) where
#endif
texy x = frac (texy $ numerator x) (texy $ denominator x)
instance (Texy a, Texy b) => Texy (a,b) where
texy (x,y) = autoParens $ texy x <> "," <> texy y
instance (Texy a, Texy b, Texy c) => Texy (a,b,c) where
texy (x,y,z) = autoParens $ texy x <> "," <> texy y <> "," <> texy z
instance (Texy a, Texy b, Texy c, Texy d) => Texy (a,b,c,d) where
texy (a,b,c,d) = autoParens $ texy a <> "," <> texy b <> "," <> texy c <> "," <> texy d
instance Texy a => Texy (Matrix a) where
texy = pmatrix Nothing
instance Texy a => Texy [a] where
texy = autoSquareBrackets . mconcat . intersperse "," . fmap texy
quad :: LaTeXC l => l
quad = comm0 "quad"
qquad :: LaTeXC l => l
qquad = comm0 "qquad"
thinspace :: LaTeXC l => l
thinspace = comm0 ","
medspace :: LaTeXC l => l
medspace = comm0 ":"
thickspace :: LaTeXC l => l
thickspace = comm0 ";"
negspace :: LaTeXC l => l
negspace = comm0 "!"
space :: LaTeXC l => l
space = comm0 " "