module Text.LaTeX.Commands (
documentclass
, usepackage
, pagestyle
, thispagestyle
, author
, title
, date
, document
, lnbk , lnbk_
, pfbk
, newpage
, linebreak , nolinebreak
, pagebreak , nopagebreak
, fussy , sloppy
, endsen
, frenchspacing
, par
, include , includeonly
, input
, hyphenation , hyp
, today
, tex , latex , latexe
, section , section_ , sectiontab
, subsection , subsection_ , subsectiontab
, subsubsection , subsubsection_ , subsubsectiontab
, paragraph , paragraph_ , paragraphtab
, subparagraph , subparagraph_ , subparagraphtab
, part , part_ , parttab
, chapter , chapter_ , chaptertab
, appendix
, maketitle , tableofcontents
, frontmatter , mainmatter , backmatter
, label , ref , pageref
, footnote
, underline , emph
, itemize
, enumerate
, description
, item
, flushleft
, flushright
, center
, quote , quotation
, verse
, abstract
, verbatim , verbatim_
, verb , verb_
, figure
, table
, caption
, listoffigures , listoftables
, clearpage , cleardoublepage
, newcommand , renewcommand , providecommand
, newenvironment
, ignorespaces , ignorespacesafterend
, providesPackage
, textrm , texttt , textmd
, textup , textsl , textsf
, textbf , textit , textsc
, textnormal
, tiny , scriptsize
, footnotesize , small
, normalsize
, large , large2 , large3
, huge , huge2
, linespread
, hspace , hspace_
, vspace , vspace_
, stretch
, skip , bigskip , smallskip
, mbox , mbox_
, fbox
, parbox
, minipage
, makebox
, framebox
, raisebox
, rule
, Tabular
, cjustified
, csep
, tabular
, (&) , (//)
, hline , cline
, multicolumn
, LxMatrix
, matrixTab
, protect
, phantom
, string
, qts
, ldots
) where
import Prelude hiding (unwords)
import Data.List (intersperse)
import GHC.Exts (fromString)
import Data.Monoid (mappend)
import Data.String.Combinators (braces,unwords,between
,mid ,newline,brackets)
import Text.LaTeX.Monad
import Text.LaTeX.Define
import Text.LaTeX.Arguments
import Text.LaTeX.Packages
import Text.LaTeX.Result
char :: Monad m => Char -> LaTeX m
char = chReplace resCharsStr
where
chReplace [] c = lx $ toResult [c]
chReplace ((x,y):xs) c = if x == c then lx y else chReplace xs c
string :: Monad m => String -> LaTeX m
string = mapM_ char
qts :: Monad m => LaTeX m -> LaTeX m
qts = between "``" "''"
ldots :: Monad m => LaTeX m
ldots = comm0 "ldots"
documentclass :: Monad m => [ClassOption m] -> Class m -> LaTeX m
documentclass = comm4 "documentclass"
usepackage :: Monad m => [PackageOption m] -> Package m -> LaTeX m
usepackage = comm4 "usepackage"
pagestyle :: Monad m => Style m -> LaTeX m
pagestyle = comm1 "pagestyle"
thispagestyle :: Monad m => Style m -> LaTeX m
thispagestyle = comm1 "thispagestyle"
author :: Monad m => Name m -> LaTeX m
author = comm1 "author"
title :: Monad m => Title m -> LaTeX m
title = comm1 "title"
date :: Monad m => Date m -> LaTeX m
date = comm1 "date"
document :: Monad m => LaTeX m -> LaTeX m
document = env "document"
lnbk :: Monad m => LaTeX m
lnbk = comm0_ "\\"
pfbk :: Monad m => LaTeX m
pfbk = newline >> newline
lnbk_ :: Monad m => LaTeX m
lnbk_ = comm0_ "\\*"
newpage :: Monad m => LaTeX m
newpage = comm0 "newpage"
linebreak :: Monad m => Int -> LaTeX m
linebreak = comm3 "linebreak" . (:[]) . lxany
nolinebreak :: Monad m => Int -> LaTeX m
nolinebreak = comm3 "nolinebreak" . (:[]) . lxany
pagebreak :: Monad m => Int -> LaTeX m
pagebreak = comm3 "pagebreak" . (:[]) . lxany
nopagebreak :: Monad m => Int -> LaTeX m
nopagebreak = comm3 "nopagebreak" . (:[]) . lxany
fussy :: Monad m => LaTeX m
fussy = comm0 "fussy"
sloppy :: Monad m => LaTeX m
sloppy = comm0 "sloppy"
endsen :: Monad m => LaTeX m
endsen = comm0_ "@"
frenchspacing :: Monad m => LaTeX m
frenchspacing = comm0 "frenchspacing"
include :: Monad m => FilePath -> LaTeX m
include = comm1 "include" . fromString
includeonly :: Monad m => [FilePath] -> LaTeX m
includeonly = comm1 "includeonly" . mapM_ fromString . intersperse ","
input :: Monad m => FilePath -> LaTeX m
input = comm1 "input" . fromString
hyphenation :: Monad m => [Word m] -> LaTeX m
hyphenation = comm1 "hyphenation" . unwords
hyp :: Monad m => LaTeX m
hyp = comm0 "-"
today :: Monad m => LaTeX m
today = comm0 "today"
tex :: Monad m => LaTeX m
tex = comm0 "TeX"
latex :: Monad m => LaTeX m
latex = comm0 "LaTeX"
latexe :: Monad m => LaTeX m
latexe = comm0 "LaTeXe"
section :: Monad m => Title m -> LaTeX m
section = comm1 "section"
section_ :: Monad m => Title m -> LaTeX m
section_ = comm1 "section*"
sectiontab :: Monad m => Title m -> Title m -> LaTeX m
sectiontab t1 = comm4 "section" [t1]
subsection :: Monad m => Title m -> LaTeX m
subsection = comm1 "subsection"
subsection_ :: Monad m => Title m -> LaTeX m
subsection_ = comm1 "subsection*"
subsectiontab :: Monad m => Title m -> Title m -> LaTeX m
subsectiontab t1 = comm4 "subsection" [t1]
subsubsection :: Monad m => Title m -> LaTeX m
subsubsection = comm1 "subsubsection"
subsubsection_ :: Monad m => Title m -> LaTeX m
subsubsection_ = comm1 "subsubsection*"
subsubsectiontab :: Monad m => Title m -> Title m -> LaTeX m
subsubsectiontab t1 = comm4 "subsubsection" [t1]
paragraph :: Monad m => Title m -> LaTeX m
paragraph = comm1 "paragraph"
paragraph_ :: Monad m => Title m -> LaTeX m
paragraph_ = comm1 "paragraph*"
paragraphtab :: Monad m => Title m -> Title m -> LaTeX m
paragraphtab t1 = comm4 "paragraph" [t1]
subparagraph :: Monad m => Title m -> LaTeX m
subparagraph = comm1 "subparagraph"
subparagraph_ :: Monad m => Title m -> LaTeX m
subparagraph_ = comm1 "subparagraph*"
subparagraphtab :: Monad m => Title m -> Title m -> LaTeX m
subparagraphtab t1 = comm4 "subparagraph" [t1]
part :: Monad m => Title m -> LaTeX m
part = comm1 "part"
part_ :: Monad m => Title m -> LaTeX m
part_ = comm1 "part*"
parttab :: Monad m => Title m -> Title m -> LaTeX m
parttab t1 = comm4 "part" [t1]
chapter :: Monad m => Title m -> LaTeX m
chapter = comm1 "chapter"
chapter_ :: Monad m => Title m -> LaTeX m
chapter_ = comm1 "chapter*"
chaptertab :: Monad m => Title m -> Title m -> LaTeX m
chaptertab t1 = comm4 "chapter" [t1]
appendix :: Monad m => LaTeX m
appendix = comm0 "appendix"
maketitle :: Monad m => LaTeX m
maketitle = comm0 "maketitle"
tableofcontents :: Monad m => LaTeX m
tableofcontents = comm0 "tableofcontents"
frontmatter :: Monad m => LaTeX m
frontmatter = comm0 "frontmatter"
mainmatter :: Monad m => LaTeX m
mainmatter = comm0 "mainmatter"
backmatter :: Monad m => LaTeX m
backmatter = comm0 "backmatter"
label :: Monad m => Marker m -> LaTeX m
label = comm1 "label"
ref :: Monad m => Marker m -> LaTeX m
ref = comm1 "ref"
pageref :: Monad m => Marker m -> LaTeX m
pageref = comm1 "pageref"
footnote :: Monad m => Text m -> LaTeX m
footnote = comm1 "footnote"
underline :: Monad m => Text m -> LaTeX m
underline = comm1 "underline"
emph :: Monad m => Text m -> LaTeX m
emph = comm1 "emph"
itemize :: Monad m => LaTeX m -> LaTeX m
itemize = env "itemize"
enumerate :: Monad m => LaTeX m -> LaTeX m
enumerate = env "enumerate"
description :: Monad m => LaTeX m -> LaTeX m
description = env "description"
item :: Monad m => [ItemOption m] -> LaTeX m
item = comm3 "item"
flushleft :: Monad m => LaTeX m -> LaTeX m
flushleft = env "flushleft"
flushright :: Monad m => LaTeX m -> LaTeX m
flushright = env "flushright"
center :: Monad m => LaTeX m -> LaTeX m
center = env "center"
quote :: Monad m => LaTeX m -> LaTeX m
quote = env "quote"
quotation :: Monad m => LaTeX m -> LaTeX m
quotation = env "quotation"
verse :: Monad m => LaTeX m -> LaTeX m
verse = env "verse"
abstract :: Monad m => LaTeX m -> LaTeX m
abstract = env "abstract"
verbatim :: Monad m => LaTeX m -> LaTeX m
verbatim = env "verbatim"
verbatim_ :: Monad m => LaTeX m -> LaTeX m
verbatim_ = env "verbatim*"
sep :: Monad m => LaTeX m -> LaTeX m
sep = between "|" "|"
verb :: Monad m => LaTeX m -> LaTeX m
verb = (comm0_ "verb" >>) . sep
verb_ :: Monad m => LaTeX m -> LaTeX m
verb_ = (comm0_ "verb*" >>) . sep
figure :: Monad m => [PlacementSpecifier m] -> LaTeX m -> LaTeX m
figure = env2 "figure"
table :: Monad m => [PlacementSpecifier m] -> LaTeX m -> LaTeX m
table = env2 "table"
caption :: Monad m => Text m -> LaTeX m
caption = comm1 "caption"
listoffigures :: Monad m => LaTeX m
listoffigures = comm0 "listoffigures"
listoftables :: Monad m => LaTeX m
listoftables = comm0 "listoftables"
clearpage :: Monad m => LaTeX m
clearpage = comm0 "clearpage"
cleardoublepage :: Monad m => LaTeX m
cleardoublepage = "cleardoblepage"
newcommand :: Monad m => Name m -> [Int] -> LaTeX m -> LaTeX m
newcommand n i = comm6 "newcommand" n (map lxany i)
renewcommand :: Monad m => Name m -> [Int] -> LaTeX m -> LaTeX m
renewcommand n i = comm6 "renewcommand" n (map lxany i)
providecommand :: Monad m => Name m -> [Int] -> LaTeX m -> LaTeX m
providecommand n i = comm6 "providecommand" n (map lxany i)
newenvironment :: Monad m => Name m -> [Int] -> LaTeX m -> LaTeX m -> LaTeX m
newenvironment n i = comm7 "newenvironment" n (map lxany i)
ignorespaces :: Monad m => LaTeX m
ignorespaces = comm0 "ignorespaces"
ignorespacesafterend :: Monad m => LaTeX m
ignorespacesafterend = comm0 "ignorespacesafterend"
providesPackage :: Monad m => Name m -> LaTeX m
providesPackage = comm1 "ProvidesPackage"
textrm :: Monad m => LaTeX m -> LaTeX m
textrm = comm1 "textrm"
texttt :: Monad m => LaTeX m -> LaTeX m
texttt = comm1 "texttt"
textmd :: Monad m => LaTeX m -> LaTeX m
textmd = comm1 "textmd"
textup :: Monad m => LaTeX m -> LaTeX m
textup = comm1 "textup"
textsl :: Monad m => LaTeX m -> LaTeX m
textsl = comm1 "textsl"
textsf :: Monad m => LaTeX m -> LaTeX m
textsf = comm1 "textsf"
textbf :: Monad m => LaTeX m -> LaTeX m
textbf = comm1 "textbf"
textit :: Monad m => LaTeX m -> LaTeX m
textit = comm1 "textit"
textsc :: Monad m => LaTeX m -> LaTeX m
textsc = comm1 "textsc"
textnormal :: Monad m => LaTeX m -> LaTeX m
textnormal = comm1 "textnormal"
tiny :: Monad m => LaTeX m -> LaTeX m
tiny = comm8 "tiny"
scriptsize :: Monad m => LaTeX m -> LaTeX m
scriptsize = comm8 "scriptsize"
footnotesize :: Monad m => LaTeX m -> LaTeX m
footnotesize = comm8 "footnotesize"
small :: Monad m => LaTeX m -> LaTeX m
small = comm8 "small"
normalsize :: Monad m => LaTeX m -> LaTeX m
normalsize = comm8 "normalsize"
large :: Monad m => LaTeX m -> LaTeX m
large = comm8 "large"
large2 :: Monad m => LaTeX m -> LaTeX m
large2 = comm8 "Large"
large3 :: Monad m => LaTeX m -> LaTeX m
large3 = comm8 "LARGE"
huge :: Monad m => LaTeX m -> LaTeX m
huge = comm8 "huge"
huge2 :: Monad m => LaTeX m -> LaTeX m
huge2 = comm8 "Huge"
par :: Monad m => LaTeX m
par = comm0 "par"
linespread :: Monad m => Float -> LaTeX m
linespread = comm1 "linespread" . lxany
hspace :: Monad m => LaTeX m -> LaTeX m
hspace = comm1 "hspace"
hspace_ :: Monad m => LaTeX m -> LaTeX m
hspace_ = comm1 "hspace*"
vspace :: Monad m => LaTeX m -> LaTeX m
vspace = comm1 "vspace"
vspace_ :: Monad m => LaTeX m -> LaTeX m
vspace_ = comm1 "vspace*"
stretch :: Monad m => Int -> LaTeX m
stretch = comm1 "stretch" . lxany
skip :: Monad m => LaTeX m -> LaTeX m
skip = mappend lnbk . brackets
bigskip :: Monad m => LaTeX m
bigskip = comm0 "bigskip"
smallskip :: Monad m => LaTeX m
smallskip = comm0 "smallskip"
mbox :: Monad m => LaTeX m -> LaTeX m
mbox = comm1 "mbox"
mbox_ :: Monad m => LaTeX m
mbox_ = mbox ""
fbox :: Monad m => LaTeX m -> LaTeX m
fbox = comm1 "fbox"
parbox :: Monad m => [Char] -> Width m -> LaTeX m -> LaTeX m
parbox c = comm9 "parbox" (if null c then [] else [fromString c])
minipage :: Monad m => [Char] -> Width m -> LaTeX m -> LaTeX m
minipage c = env3 "minipage" (if null c then [] else [fromString c])
makebox :: Monad m => [Width m] -> [Char] -> LaTeX m -> LaTeX m
makebox w c = comm10 "makebox" w (if null c then [] else [fromString c])
framebox :: Monad m => [Width m] -> [Char] -> LaTeX m -> LaTeX m
framebox w c = comm10 "framebox" w (if null c then [] else [fromString c])
raisebox :: Monad m => Lift m -> [Extend m] -> [Extend m] -> LaTeX m -> LaTeX m
raisebox = comm11 "raisebox"
rule :: Monad m => [Lift m] -> Width m -> Height m -> LaTeX m
rule = comm9 "rule"
protect :: Monad m => LaTeX m
protect = comm0_ "protect"
phantom :: Monad m => LaTeX m -> LaTeX m
phantom = comm1 "phantom"
type Tabular m = LaTeX m
cjustified :: Monad m => Width m -> LaTeX m
cjustified = ("p">>) . braces
csep :: Monad m => LaTeX m -> LaTeX m
csep = ("@">>) . braces
tabular :: Monad m => [LaTeX m] -> LaTeX m -> LaTeX m -> Tabular m
tabular = env3 "tabular"
(&) :: Monad m => LaTeX m -> LaTeX m -> LaTeX m
(&) = mid " & "
(//) :: Monad m => LaTeX m -> LaTeX m -> LaTeX m
(//) = mid $ lnbk >> newline
hline :: Monad m => LaTeX m
hline = comm0 "hline"
cline :: Monad m => Int
-> Int
-> LaTeX m
cline n m = comm1 "cline" $ lxany n lxany m
multicolumn :: Monad m => Int -> LaTeX m -> LaTeX m -> LaTeX m
multicolumn n = comm12 "multicolumn" $ lxany n
type LxMatrix m = [[LaTeX m]]
matrixTab :: Monad m => [LaTeX m] -> LaTeX m -> LxMatrix m -> Tabular m
matrixTab p spec m = let f = tabular p spec . foldr1 (//) . map (foldr1 (&))
in if sum (map length m) == 0 then "" else f m