HaTeX 3.17.2.0 → 3.17.3.0
raw patch · 15 files changed
+293/−29 lines, 15 filesdep +ghc-primdep +hashabledep ~basePVP ok
version bump matches the API change (PVP)
Dependencies added: ghc-prim, hashable
Dependency ranges changed: base
API changes (from Hackage documentation)
+ Text.LaTeX.Base.Class: comm2 :: LaTeXC l => String -> l -> l -> l
+ Text.LaTeX.Base.Class: comm3 :: LaTeXC l => String -> l -> l -> l -> l
+ Text.LaTeX.Base.Commands: arraybackslash :: LaTeXC l => l
+ Text.LaTeX.Base.Commands: centering :: LaTeXC l => l
+ Text.LaTeX.Base.Commands: raggedleft :: LaTeXC l => l
+ Text.LaTeX.Base.Commands: raggedright :: LaTeXC l => l
+ Text.LaTeX.Base.Commands: tabularnewline :: LaTeXC l => l
+ Text.LaTeX.Base.Commands: tabularnewlineSpc :: LaTeXC l => Measure -> l
+ Text.LaTeX.Base.Syntax: DoubleDollar :: MathType
+ Text.LaTeX.Base.Syntax: instance Data.Hashable.Class.Hashable Text.LaTeX.Base.Syntax.LaTeX
+ Text.LaTeX.Base.Syntax: instance Data.Hashable.Class.Hashable Text.LaTeX.Base.Syntax.MathType
+ Text.LaTeX.Base.Syntax: instance Data.Hashable.Class.Hashable Text.LaTeX.Base.Syntax.Measure
+ Text.LaTeX.Base.Syntax: instance Data.Hashable.Class.Hashable Text.LaTeX.Base.Syntax.TeXArg
+ Text.LaTeX.Base.Types: AfterColumn :: LaTeX -> TableSpec
+ Text.LaTeX.Base.Types: BeforeColumn :: LaTeX -> TableSpec
+ Text.LaTeX.Base.Types: NameColumn :: String -> TableSpec
+ Text.LaTeX.Packages.LTableX: convertXColumns :: LaTeXC l => l
+ Text.LaTeX.Packages.LTableX: keepXColumns :: LaTeXC l => l
+ Text.LaTeX.Packages.LTableX: ltablex :: PackageName
+ Text.LaTeX.Packages.LongTable: endfirsthead :: LaTeXC l => l
+ Text.LaTeX.Packages.LongTable: endfoot :: LaTeXC l => l
+ Text.LaTeX.Packages.LongTable: endhead :: LaTeXC l => l
+ Text.LaTeX.Packages.LongTable: endlastfoot :: LaTeXC l => l
+ Text.LaTeX.Packages.LongTable: longtable :: LaTeXC l => Maybe Pos -> [TableSpec] -> l -> l
+ Text.LaTeX.Packages.LongTable: longtablep :: PackageName
+ Text.LaTeX.Packages.TabularX: tabularx :: LaTeXC l => Measure -> Maybe Pos -> [TableSpec] -> l -> l
+ Text.LaTeX.Packages.TabularX: tabularxp :: PackageName
Files
- Examples/accents.hs +27/−0
- HaTeX.cabal +7/−1
- README.md +0/−2
- Text/LaTeX/Base/Class.hs +18/−0
- Text/LaTeX/Base/Commands.hs +30/−0
- Text/LaTeX/Base/Parser.hs +7/−2
- Text/LaTeX/Base/Pretty.hs +1/−0
- Text/LaTeX/Base/Render.hs +1/−0
- Text/LaTeX/Base/Syntax.hs +35/−23
- Text/LaTeX/Base/Types.hs +6/−0
- Text/LaTeX/Packages/AMSMath.hs +5/−0
- Text/LaTeX/Packages/LTableX.hs +39/−0
- Text/LaTeX/Packages/LongTable.hs +67/−0
- Text/LaTeX/Packages/TabularX.hs +44/−0
- Text/LaTeX/Packages/Trees/Qtree.hs +6/−1
+ Examples/accents.hs view
@@ -0,0 +1,27 @@++{-# LANGUAGE OverloadedStrings #-}++import Text.LaTeX+import Text.LaTeX.Packages.Inputenc++main :: IO ()+main = renderFile "accents.tex" $ execLaTeXM accents++accents :: LaTeXM ()+accents = thePreamble >> document theBody++thePreamble :: LaTeXM ()+thePreamble = do+ documentclass [] article+ usepackage [utf8] inputenc+ author "Daniel Díaz"+ title "HaTeX and accents"++theBody :: LaTeXM ()+theBody = do+ maketitle+ flushleft "ÁáÉéÍíÓóÚú"+ flushleft "ÀàÈèÌìÒòÙù"+ flushleft "ÄäËëÏïÖöÜü"+ flushleft "ÂâÊêÎîÔôÛû"+ flushleft "ß"
HaTeX.cabal view
@@ -1,5 +1,5 @@ Name: HaTeX -Version: 3.17.2.0 +Version: 3.17.3.0 Author: Daniel Díaz Category: LaTeX Build-type: Simple @@ -64,6 +64,7 @@ , text >= 0.11.2.3 && < 2 , transformers >= 0.2.2 && < 0.6 , containers >= 0.4.2.1 && < 0.6 + , hashable >= 1.2 && < 1.3 , matrix -- Testing , QuickCheck @@ -71,6 +72,8 @@ , parsec >= 3.1.6 -- Pretty-printing , wl-pprint-extras >= 3.5 + if impl(ghc < 7.6) + build-depends: ghc-prim Exposed-modules: Text.LaTeX -- Base (Core of the library) @@ -98,9 +101,12 @@ Text.LaTeX.Packages.Geometry Text.LaTeX.Packages.Graphicx Text.LaTeX.Packages.Hyperref + Text.LaTeX.Packages.LongTable + Text.LaTeX.Packages.LTableX Text.LaTeX.Packages.Inputenc Text.LaTeX.Packages.QRCode Text.LaTeX.Packages.Relsize + Text.LaTeX.Packages.TabularX -- Trees Text.LaTeX.Packages.Trees Text.LaTeX.Packages.Trees.Qtree
README.md view
@@ -73,8 +73,6 @@ within a LaTeX file. * [TeX-my-math](https://github.com/leftaroundabout/Symbolic-math-HaTeX): Experimental library to ease the production of mathematical expressions using HaTeX.-* [blatex](http://hackage.haskell.org/package/blatex): Static site generator for blogs where posts are written-in LaTeX. ## Travis automatic build
Text/LaTeX/Base/Class.hs view
@@ -23,6 +23,8 @@ -- ** Others , comm0 , comm1+ , comm2+ , comm3 , commS , braces ) where@@ -78,6 +80,22 @@ -- comm1 :: LaTeXC l => String -> l -> l comm1 str = liftL $ \l -> TeXComm str [FixArg l]++-- | A two parameter command generator using the name of the command.+-- The parameters will be rendered as fixed arguments.+--+-- > comm2 str = liftL2 $ \l1 l2 -> TeXComm str [FixArg l1, FixArg l2]+--+comm2 :: LaTeXC l => String -> l -> l -> l+comm2 str = liftL2 $ \l1 l2 -> TeXComm str [FixArg l1, FixArg l2]++-- | A three parameter command generator using the name of the command.+-- The parameters will be rendered as fixed arguments.+--+-- > comm3 str = liftL2 $ \l1 l2 -> TeXComm str [FixArg l1, FixArg l2]+--+comm3 :: LaTeXC l => String -> l -> l -> l -> l+comm3 str = liftL3 $ \l1 l2 l3 -> TeXComm str [FixArg l1, FixArg l2, FixArg l3] -- | Like 'comm0' but using 'TeXCommS', i.e. no \"{}\" will be inserted to protect -- the command's end.
Text/LaTeX/Base/Commands.hs view
@@ -191,6 +191,9 @@ , pageref -- ** Tables , tabular+ , tabularnewline+ , tabularnewlineSpc+ , arraybackslash , array , (&) , hline@@ -199,6 +202,9 @@ -- *** Special tables , matrixTabular -- ** Others+ , centering+ , raggedleft+ , raggedright , footnote , protect , hyphenation@@ -689,6 +695,15 @@ qts :: LaTeXC l => l -> l qts l = between l (raw "``") (raw "''") +centering :: LaTeXC l => l+centering = comm0 "centering"++raggedleft :: LaTeXC l => l+raggedleft = comm0 "raggedleft"++raggedright :: LaTeXC l => l+raggedright = comm0 "raggedright"+ footnote :: LaTeXC l => l -> l footnote = liftL $ \l -> TeXComm "footnote" [FixArg l] @@ -882,6 +897,21 @@ -- | Horizontal line. hline :: LaTeXC l => l hline = commS "hline "++-- | 'tabularnewline' ends a row in array or tabular environments. The+-- '\' command has different meanings in different contexts. It can+-- end a line in normal text, or it can end an array or tabular+-- line. It may be preferrable to use 'newline' and in the first case,+-- and 'tabularnewline' in the second.+tabularnewline :: LaTeXC l => l+tabularnewline = commS "tabularnewline "++tabularnewlineSpc :: LaTeXC l => Measure -> l+tabularnewlineSpc m = fromLaTeX $ TeXComm "tabularnewline" [OptArg $ rendertex m]++-- | 'arraybackslash' resets the definition of '\' to 'tabularnewline'.+arraybackslash :: LaTeXC l => l+arraybackslash = commS "arraybackslash " -- | Cell taking multiple columns. multicolumn :: LaTeXC l => Int -> [TableSpec] -> l -> l
Text/LaTeX/Base/Parser.hs view
@@ -303,8 +303,13 @@ dolMath :: Parser LaTeX dolMath = do _ <- char '$' - b <- mconcat <$> latexBlockParser `manyTill` char '$'- return $ TeXMath Dollar b+ choice+ [ do _ <- char '$'+ b <- mconcat <$> latexBlockParser `manyTill` try (string "$$")+ return $ TeXMath DoubleDollar b+ , do b <- mconcat <$> latexBlockParser `manyTill` char '$'+ return $ TeXMath Dollar b+ ] math :: MathType -> String -> Parser LaTeX math t eMath = do
Text/LaTeX/Base/Pretty.hs view
@@ -48,6 +48,7 @@ Parentheses -> ("\\(","\\)") Square -> ("\\[","\\]") Dollar -> ("$","$")+ DoubleDollar -> ("$$","$$") in text l <> docLaTeX b <> text r docLaTeX (TeXLineBreak m b) = text "\\\\" <> maybe mempty (brackets . text . unpack . render) m <> ( if b then text "*" else mempty )
Text/LaTeX/Base/Render.hs view
@@ -124,6 +124,7 @@ <> "}" render (TeXMath Dollar l) = "$" <> render l <> "$"+ render (TeXMath DoubleDollar l) = "$$" <> render l <> "$$" render (TeXMath Square l) = "\\[" <> render l <> "\\]" render (TeXMath Parentheses l) = "\\(" <> render l <> "\\)"
Text/LaTeX/Base/Syntax.hs view
@@ -38,8 +38,9 @@ import Data.Functor.Identity (runIdentity) import Data.Data (Data) import Data.Typeable-import GHC.Generics (Generic) import Test.QuickCheck+import Data.Hashable+import GHC.Generics (Generic) -- | Measure units defined in LaTeX. Use 'CustomMeasure' to use commands like 'textwidth'. -- For instance:@@ -59,7 +60,7 @@ deriving (Data, Eq, Generic, Show, Typeable) -- | Different types of syntax for mathematical expressions.-data MathType = Parentheses | Square | Dollar+data MathType = Parentheses | Square | Dollar | DoubleDollar deriving (Data, Eq, Generic, Show, Typeable) -- | Type of @LaTeX@ blocks.@@ -277,7 +278,7 @@ arbitraryChar = elements $ ['A'..'Z'] ++ ['a'..'z']- ++ "\n-+*/!\"$%&(){}^_.,:;'#@<>?\\ "+ ++ "\n-+*/!\"().,:;'@<>? " -- | Utility for the instance of 'LaTeX' to 'Arbitrary'. -- We generate a short sequence of characters and@@ -301,27 +302,32 @@ f <$> arbitrary instance Arbitrary LaTeX where- arbitrary = do- -- We give more chances to 'TeXRaw'.- -- This results in arbitrary 'LaTeX' values- -- not getting too large.- n <- choose (0,16 :: Int)- case n of- 0 -> pure TeXEmpty- 1 -> do m <- choose (0,5)- TeXComm <$> arbitraryName <*> vectorOf m arbitrary- 2 -> TeXCommS <$> arbitraryName- 3 -> do m <- choose (0,5)- TeXEnv <$> arbitraryName <*> vectorOf m arbitrary <*> arbitrary- 4 -> do m <- choose (0,2)- let t = [Parentheses,Square,Dollar] !! m- TeXMath <$> pure t <*> arbitrary- 5 -> TeXLineBreak <$> arbitrary <*> arbitrary- 6 -> TeXBraces <$> arbitrary- 7 -> TeXComment <$> arbitraryRaw- 8 -> TeXSeq <$> arbitrary <*> arbitrary- _ -> TeXRaw <$> arbitraryRaw+ arbitrary = arbitraryLaTeX False +arbitraryLaTeX :: Bool -> Gen LaTeX+arbitraryLaTeX inDollar = do+ -- We give more chances to 'TeXRaw'.+ -- This results in arbitrary 'LaTeX' values+ -- not getting too large.+ n <- choose (0,16 :: Int)+ case n of+ 0 -> if inDollar then arbitraryLaTeX True else pure TeXEmpty+ 1 -> do m <- choose (0,5)+ TeXComm <$> arbitraryName <*> vectorOf m arbitrary+ 2 -> TeXCommS <$> arbitraryName+ 3 -> do m <- choose (0,5)+ TeXEnv <$> arbitraryName <*> vectorOf m arbitrary <*> arbitrary+ 4 -> if inDollar+ then arbitraryLaTeX True+ else do do m <- choose (0,3)+ let t = [Parentheses,Square,Dollar,DoubleDollar] !! m+ TeXMath <$> pure t <*> arbitraryLaTeX (t == Dollar || t == DoubleDollar)+ 5 -> TeXLineBreak <$> arbitrary <*> arbitrary+ 6 -> TeXBraces <$> arbitrary+ 7 -> TeXComment <$> arbitraryRaw+ 8 -> TeXSeq <$> (if inDollar then arbitraryLaTeX True else arbitrary) <*> arbitrary+ _ -> TeXRaw <$> arbitraryRaw+ instance Arbitrary TeXArg where arbitrary = do n <- choose (0,6 :: Int)@@ -336,3 +342,9 @@ 5 -> do m <- choose (1,5) MParArg <$> vectorOf m arbitrary _ -> FixArg <$> arbitrary+++instance Hashable Measure+instance Hashable MathType+instance Hashable TeXArg+instance Hashable LaTeX
Text/LaTeX/Base/Types.hs view
@@ -66,6 +66,9 @@ | ParColumnTop LaTeX -- ^ Paragraph column with text vertically aligned at the top. | ParColumnMid LaTeX -- ^ Paragraph column with text vertically aligned at the middle. Requires 'array' package. | ParColumnBot LaTeX -- ^ Paragraph column with text vertically aligned at the bottom. Requires 'array' package.+ | NameColumn String -- ^ User defined column. Requires 'array' package.+ | BeforeColumn LaTeX -- ^ Can be used before a 'LeftColumn', 'CenterColumn', 'RightColumn', 'ParColumnTop', 'ParColumnMid' or a 'ParColumnBot' specification. Inserts the code directly in front of the entry of the column. Requires 'array' package.+ | AfterColumn LaTeX -- ^ Can be used after a 'LeftColumn', 'CenterColumn', 'RightColumn', 'ParColumnTop', 'ParColumnMid' or a 'ParColumnBot' specification. Inserts the code directly in front of the entry of the column. Requires 'array' package. | VerticalLine -- ^ Vertical line between two columns. | DVerticalLine -- ^ Double vertical line between two columns. | Separator LaTeX -- ^ Column separator. Requires 'array' package.@@ -78,6 +81,9 @@ render (ParColumnTop l) = "p" <> render (FixArg l) render (ParColumnMid l) = "m" <> render (FixArg l) render (ParColumnBot l) = "b" <> render (FixArg l)+ render (NameColumn n) = fromString n+ render (BeforeColumn l) = ">{" <> render l <> "}"+ render (AfterColumn l) = "<{" <> render l <> "}" render VerticalLine = "|" render DVerticalLine = "||" render (Separator l) = "@" <> render (FixArg l)
Text/LaTeX/Packages/AMSMath.hs view
@@ -1,5 +1,10 @@ {-# LANGUAGE CPP, OverloadedStrings, TypeFamilies #-}+#if __GLASGOW_HASKELL__ >= 801+{-# OPTIONS_GHC -Wno-orphans #-}+#else+{-# OPTIONS_GHC -fno-warn-orphans #-}+#endif -- | \AMSMath\ support. Also numeric instances ('Num', 'Fractional' and 'Floating') for 'LaTeX' and 'LaTeXT'. module Text.LaTeX.Packages.AMSMath
+ Text/LaTeX/Packages/LTableX.hs view
@@ -0,0 +1,39 @@++{-# LANGUAGE OverloadedStrings #-}++module Text.LaTeX.Packages.LTableX+ ( -- * ltablex package+ ltablex+ -- * ltablex commands+ , keepXColumns+ , convertXColumns+ , module Text.LaTeX.Packages.TabularX+ , module Text.LaTeX.Packages.LongTable+ ) where++import Text.LaTeX.Base.Syntax (LaTeX(TeXComm))+import Text.LaTeX.Base.Class (LaTeXC, fromLaTeX)+import Text.LaTeX.Base.Types (PackageName)+import Text.LaTeX.Packages.TabularX (tabularx)+import Text.LaTeX.Packages.LongTable (endfirsthead, endhead, endfoot, endlastfoot)++-- | ltablex package. Use it to import it like this:+--+-- > usepackage [] ltablex+ltablex :: PackageName+ltablex = "ltablex"++keepXColumns :: LaTeXC l => l+keepXColumns = fromLaTeX $ TeXComm "keepXColumns" []++-- | Treet the specified width as the maximum allowed, not the exact width of the table.+--+-- ltablex has added a feature that treats the X columns like ‘l’+-- columns if the table contents would allow that to happen without+-- exceeding the specified width of the table. In other words, the+-- specified width is treated as the maximum allowed and not the exact+-- width of the table. This feature is the default but can be disabled+-- (or enabled) with \keepXColumns (or \convertXColumns).++convertXColumns :: LaTeXC l => l+convertXColumns = fromLaTeX $ TeXComm "convertXColumns" []
+ Text/LaTeX/Packages/LongTable.hs view
@@ -0,0 +1,67 @@++{-# LANGUAGE OverloadedStrings #-}++module Text.LaTeX.Packages.LongTable+ ( -- * longtable package+ longtablep+ -- * longtable commands+ , longtable+ , endfirsthead+ , endhead+ , endfoot+ , endlastfoot+ -- * Package Options+ ) where++import Text.LaTeX.Base.Syntax (LaTeX(TeXEnv, TeXRaw, TeXComm), TeXArg(FixArg, OptArg))+import Text.LaTeX.Base.Class (LaTeXC, fromLaTeX, liftL)+import Text.LaTeX.Base.Render (render, renderAppend)+import Text.LaTeX.Base.Types (PackageName, Pos, TableSpec)++-- | longtable package. Use it to import it like this:+--+-- > usepackage [] longtable+longtablep :: PackageName+longtablep = "longtable"+++-- | The 'longtable' environment can be used to typeset multi-page tables.+longtable :: LaTeXC l =>+ Maybe Pos -- ^ This optional parameter can be used to specify the vertical position of the table.+ -- Defaulted to 'Center'.+ -> [TableSpec] -- ^ Table specification of columns and vertical lines.+ -> l -- ^ Table content. See '&', 'lnbk', 'hline' and 'cline'.+ -> l -- ^ Resulting table syntax.+longtable Nothing ts = liftL $ TeXEnv "longtable" [ FixArg $ TeXRaw $ renderAppend ts ]+longtable (Just p) ts = liftL $ TeXEnv "longtable" [ OptArg $ TeXRaw $ render p , FixArg $ TeXRaw $ renderAppend ts ]++-- | End the first head.+--+-- Everything above this command will appear at the beginning of the+-- table, in the first page.+endfirsthead :: LaTeXC l => l+endfirsthead = fromLaTeX $ TeXComm "endfirsthead" []++-- | End the head.+--+-- Whatever you put before this command and below \endfirsthead will+-- be displayed at the top of the table in every page except the first+-- one.+endhead :: LaTeXC l => l+endhead = fromLaTeX $ TeXComm "endhead" []++-- | End the foot.+--+-- Similar to \endhead, what you put after \endhead and before this+-- command will appear at the bottom of the table in every page except+-- the last one.+endfoot :: LaTeXC l => l+endfoot = fromLaTeX $ TeXComm "endfoot" []++-- | End the last foot.+--+-- Similar to \endfisthead. The elements after \endfoot and before+-- this command will be displayed at the bottom of the table but only+-- in the last page where the table appears.+endlastfoot :: LaTeXC l => l+endlastfoot = fromLaTeX $ TeXComm "endlastfoot" []
+ Text/LaTeX/Packages/TabularX.hs view
@@ -0,0 +1,44 @@++{-# LANGUAGE OverloadedStrings #-}++module Text.LaTeX.Packages.TabularX+ ( -- * tabularx package+ tabularxp+ -- * tabularx commands+ , tabularx+ ) where++import Text.LaTeX.Base.Syntax (LaTeX(TeXEnv, TeXRaw), TeXArg(FixArg, OptArg))+import Text.LaTeX.Base.Class (LaTeXC, liftL)+import Text.LaTeX.Base.Render (render, renderAppend)+import Text.LaTeX.Base.Types (PackageName, Pos, TableSpec, Measure)++-- | tabularx package. Use it to import it like this:+--+-- > usepackage [] tabularxp+tabularxp :: PackageName+tabularxp = "tabularx"++-- | The 'tabularx' environment takes the same arguments as tabular*,+-- but modifies the widths of certain columns, rather than the inter+-- column space, to set a table with the requested total width. The+-- columns that may stretch are marked with the new token X in the+-- preamble argument.+--+tabularx :: LaTeXC l =>+ Measure -- ^ Width of the whole tabular.+ -> Maybe Pos -- ^ This optional parameter can be used to specify the vertical position of the table.+ -- Defaulted to 'Center'.+ -> [TableSpec] -- ^ Table specification of columns and vertical lines.+ -> l -- ^ Table content. See '&', 'lnbk', 'hline' and 'cline'.+ -> l -- ^ Resulting table syntax.+tabularx width maybePos ts =+ liftL $ TeXEnv "tabularx" args+ where+ width' = FixArg $ TeXRaw $ render width+ ts' = FixArg $ TeXRaw $ renderAppend ts+ args = case maybePos of+ Nothing -> [width', ts']+ Just p -> [width', p', ts']+ where+ p' = OptArg $ TeXRaw $ render p
Text/LaTeX/Packages/Trees/Qtree.hs view
@@ -1,5 +1,10 @@ -{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE OverloadedStrings, CPP #-}+#if __GLASGOW_HASKELL__ >= 801+{-# OPTIONS_GHC -Wno-orphans #-}+#else+{-# OPTIONS_GHC -fno-warn-orphans #-}+#endif -- | Tree interface using the @qtree@ package. -- An example of usage is provided in the /examples/ directory of