module Text.LaTeX.Packages.Fancyhdr (
fancyhdr
, HdrSettings (..)
, defaultHdrSettings
, applyHdrSettings
, fancy
, lhead, chead, rhead
, lfoot, cfoot, rfoot
, renewheadrulewidth
, renewfootrulewidth
) where
import Text.LaTeX.Base.Syntax
import Text.LaTeX.Base.Class
import Text.LaTeX.Base.Types
import Text.LaTeX.Base.Commands
import Text.LaTeX.Base.Texy
fancyhdr :: PackageName
fancyhdr = "fancyhdr"
data HdrSettings = HdrSettings
{ leftHeader :: LaTeX
, centerHeader :: LaTeX
, rightHeader :: LaTeX
, leftFooter :: LaTeX
, centerFooter :: LaTeX
, rightFooter :: LaTeX
, headRuleWidth :: Measure
, footRuleWidth :: Measure
} deriving (Eq,Show)
defaultHdrSettings :: HdrSettings
defaultHdrSettings =
HdrSettings
{ leftHeader = mempty
, centerHeader = mempty
, rightHeader = mempty
, leftFooter = mempty
, centerFooter = thePage
, rightFooter = mempty
, headRuleWidth = Pt 0.4
, footRuleWidth = Pt 0
}
applyHdrSettings :: LaTeXC l => HdrSettings -> l
applyHdrSettings hs =
usepackage [] fancyhdr
<> pagestyle fancy
<> fromLaTeX (lhead $ leftHeader hs)
<> fromLaTeX (chead $ centerHeader hs)
<> fromLaTeX (rhead $ rightHeader hs)
<> fromLaTeX (lfoot $ leftFooter hs)
<> fromLaTeX (cfoot $ centerFooter hs)
<> fromLaTeX (rfoot $ rightFooter hs)
<> renewheadrulewidth (headRuleWidth hs)
<> renewfootrulewidth (footRuleWidth hs)
fancy :: PageStyle
fancy = "fancy"
lhead :: LaTeXC l => l -> l
lhead = comm1 "lhead"
chead :: LaTeXC l => l -> l
chead = comm1 "chead"
rhead :: LaTeXC l => l -> l
rhead = comm1 "rhead"
lfoot :: LaTeXC l => l -> l
lfoot = comm1 "lfoot"
cfoot :: LaTeXC l => l -> l
cfoot = comm1 "cfoot"
rfoot :: LaTeXC l => l -> l
rfoot = comm1 "rfoot"
renewheadrulewidth :: LaTeXC l => Measure -> l
renewheadrulewidth m = fromLaTeX $
TeXComm "renewcommand" [ FixArg $ TeXCommS "headrulewidth"
, FixArg $ texy m
]
renewfootrulewidth :: LaTeXC l => Measure -> l
renewfootrulewidth m = fromLaTeX $
TeXComm "renewcommand" [ FixArg $ TeXCommS "footrulewidth"
, FixArg $ texy m
]