module Text.LaTeX.Packages.Graphicx
(
graphicx
, dvips
, dvipdfm
, pdftex
, IGOption (..)
, includegraphics
, rotatebox
, scalebox
, reflectbox
, resizebox
) where
import Text.LaTeX.Base.Syntax
import Text.LaTeX.Base.Class
import Text.LaTeX.Base.Render
import Text.LaTeX.Base.Types
import Data.Char (toLower)
graphicx :: PackageName
graphicx = "graphicx"
dvips, dvipdfm, pdftex :: LaTeXC l => l
dvips = "dvips"
dvipdfm = "dvipdfm"
pdftex = "pdftex"
data IGOption =
IGWidth Measure
| IGHeight Measure
| KeepAspectRatio Bool
| IGScale Float
| IGAngle Int
| IGTrim Measure Measure Measure Measure
| IGClip Bool
| IGPage Int
deriving Show
instance Render IGOption where
render (IGWidth m) = "width=" <> render m
render (IGHeight m) = "height=" <> render m
render (KeepAspectRatio b) = "keepaspectratio=" <> fromString (fmap toLower $ show b)
render (IGScale r) = "scale=" <> render r
render (IGAngle a) = "angle=" <> render a
render (IGTrim l b r t) = "trim=" <> renderChars ' ' [l,b,r,t]
render (IGClip b) = "clip=" <> fromString (fmap toLower $ show b)
render (IGPage p) = "page=" <> render p
includegraphics :: LaTeXC l =>
[IGOption]
-> FilePath
-> l
includegraphics opts fp = fromLaTeX $ TeXComm "includegraphics"
[ MOptArg $ fmap rendertex opts , FixArg $ TeXRaw $ fromString fp ]
rotatebox :: LaTeXC l => Float -> l -> l
rotatebox a = liftL $ \l -> TeXComm "rotatebox" [FixArg $ rendertex a , FixArg l]
scalebox :: LaTeXC l =>
Float
-> Maybe Float
-> l
-> l
scalebox h mv = liftL $ \l ->
TeXComm "rotatebox" $ [FixArg $ rendertex h]
++ maybe [] ((:[]) . OptArg . rendertex) mv
++ [FixArg l]
reflectbox :: LaTeXC l => l -> l
reflectbox = liftL $ \l -> TeXComm "reflectbox" [FixArg l]
resizebox :: LaTeXC l =>
Measure
-> Measure
-> l
-> l
resizebox h v = liftL $ \l ->
TeXComm "resizebox" [FixArg $ rendertex h,FixArg $ rendertex v,FixArg l]