module Text.LaTeX.Packages.Hyperref
(
hyperref
, HRefOption (..)
, URL
, createURL
, href
, url
, nolinkurl
, hyperbaseurl
, hyperimage
, autoref
, nameref
, pdftex
, pdftitle
, pdfauthor
, pdfsubject
, pdfcreator
, pdfproducer
, pdfkeywords
, pdftrapped
, pdfstartpage
, pdfpagelayout
, PdfPageLayout(..)
) where
import Text.LaTeX.Base.Syntax
import Text.LaTeX.Base.Class
import Text.LaTeX.Base.Commands
import Text.LaTeX.Base.Render
import Text.LaTeX.Base.Types
import Data.Text (pack)
hyperref :: PackageName
hyperref = "hyperref"
data HRefOption =
PDFRemoteStartView
| PDFNewWindow
| HRefPage Int
deriving Show
instance Render HRefOption where
render PDFRemoteStartView = "pdfremotestartview"
render PDFNewWindow = "pdfnewwindow"
render (HRefPage n) = "page=" <> render n
newtype URL = URL String deriving Show
instance Render URL where
render (URL str) = fromString str
createURL :: String -> URL
createURL = URL
instance IsString URL where
fromString = createURL
href :: LaTeXC l => [HRefOption] -> URL -> l -> l
href options u = liftL $ \t -> TeXComm "href" [ MOptArg $ fmap rendertex options
, FixArg $ rendertex u
, FixArg t ]
url :: LaTeXC l => URL -> l
url u = fromLaTeX $ TeXComm "url" [ FixArg $ rendertex u ]
nolinkurl :: LaTeXC l => URL -> l
nolinkurl u = fromLaTeX $ TeXComm "nolinkurl" [ FixArg $ rendertex u ]
hyperbaseurl :: LaTeXC l => URL -> l
hyperbaseurl u = fromLaTeX $ TeXComm "hyperbaseurl" [ FixArg $ rendertex u ]
hyperimage :: LaTeXC l => URL -> l -> l
hyperimage u = liftL $ \t -> TeXComm "hyperimage" [ FixArg $ rendertex u , FixArg t ]
autoref :: LaTeXC l => Label -> l
autoref l = fromLaTeX $ TeXComm "autoref" [ FixArg $ rendertex l ]
nameref :: LaTeXC l => Label -> l
nameref l = fromLaTeX $ TeXComm "nameref" [ FixArg $ rendertex l ]
packageOption :: LaTeXC l => Text -> l -> l
packageOption n p = raw n <> raw "={" <> p <> raw "}"
pdftex :: LaTeXC l => l
pdftex = raw "pdftex"
pdftitle :: LaTeXC l => l -> l
pdftitle = packageOption "pdftitle"
pdfauthor :: LaTeXC l => l -> l
pdfauthor = packageOption "pdfauthor"
pdfsubject :: LaTeXC l => l -> l
pdfsubject = packageOption "pdfsubject"
pdfcreator :: LaTeXC l => l -> l
pdfcreator = packageOption "pdfcreator"
pdfproducer :: LaTeXC l => l -> l
pdfproducer = packageOption "pdfproducer"
pdfkeywords :: LaTeXC l => l -> l
pdfkeywords = packageOption "pdfkeywords"
pdftrapped :: LaTeXC l => Maybe Bool -> l
pdftrapped Nothing = packageOption "pdftrapped" mempty
pdftrapped (Just t) = packageOption "pdftrapped" . raw . pack . show $ t
pdfstartpage :: LaTeXC l => l -> l
pdfstartpage = packageOption "pdfstartpage"
pdfpagelayout :: LaTeXC l => PdfPageLayout -> l
pdfpagelayout l = packageOption "pdfpagelayout" . raw . pack . show $ l
data PdfPageLayout = SinglePage
| OneColumn
| TwoColumnLeft
| TwoColumnRight
| TwoPageLeft
| TwoPageRight
deriving (Eq, Ord, Read, Show)