packages feed

HaTeX 3.6.0.1 → 3.6.1.0

raw patch · 8 files changed

+146/−26 lines, 8 filesdep ~attoparsecdep ~bytestringdep ~containersPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: attoparsec, bytestring, containers, text

API changes (from Hackage documentation)

+ Text.LaTeX.Packages.AMSMath: integral :: LaTeXC l => l
+ Text.LaTeX.Packages.AMSMath: integralFromTo :: LaTeXC l => l -> l -> l
+ Text.LaTeX.Packages.AMSMath: prod :: LaTeXC l => l
+ Text.LaTeX.Packages.AMSMath: prodFromTo :: LaTeXC l => l -> l -> l
+ Text.LaTeX.Packages.AMSMath: sumFromTo :: LaTeXC l => l -> l -> l
+ Text.LaTeX.Packages.AMSMath: tsum :: LaTeXC l => l
+ Text.LaTeX.Packages.TikZ.PathBuilder: node :: LaTeX -> PathBuilder ()
+ Text.LaTeX.Packages.TikZ.Simple: (->>) :: TikZ -> TikZ -> TikZ
+ Text.LaTeX.Packages.TikZ.Simple: Rotate :: Double -> Figure -> Figure
+ Text.LaTeX.Packages.TikZ.Simple: Text :: Point -> LaTeX -> Figure
+ Text.LaTeX.Packages.TikZ.Simple: pathImage :: Double -> (Double, Double) -> (Double -> Point) -> Figure
+ Text.LaTeX.Packages.TikZ.Syntax: Node :: TPath -> LaTeX -> TPath
+ Text.LaTeX.Packages.TikZ.Syntax: TRotate :: Double -> Parameter

Files

Examples/tikzsimple.hs view
@@ -1,4 +1,6 @@ +{-# LANGUAGE OverloadedStrings #-}+ import Text.LaTeX import Text.LaTeX.Packages.TikZ.Simple @@ -14,7 +16,7 @@   usepackage [] tikz  theBody :: LaTeXT IO ()-theBody = center $ tikzpicture $ figuretikz myFigure+theBody = mapM_ (center . tikzpicture . figuretikz) [myFigure,myFigure2,myFigure3]  myFigure :: Figure myFigure = Scale 3 $ Figures@@ -23,3 +25,20 @@  , Colored Red   $ RectangleFilled ( 0,2) 1 1  , Colored Blue  $ RectangleFilled ( 1,1) 1 1    ]++myFigure2 :: Figure+myFigure2 = Scale 2 $ Figures+ [ Colored Blue $ PolygonFilled [(-2,-1),(0,1),(2,-1)]+ , Text (0,1.4) $ "Is this a " <> textit "blue" <> " triangle?"+ , Rotate (pi/9) $ Colored Yellow $ Text (-0.2,-0.2) "Yes, it is!"+   ]++myFigure3 :: Figure+myFigure3 = LineWidth (Pt 2) $+   pathImage 0.01 (0,4) $+      -- Spira mirabilis (logarithmic spiral)+      \t -> ( a * exp t * cos (b*t)+            , a * exp t * sin (b*t)+              )+  where+    a = 0.1 ; b = 4
HaTeX.cabal view
@@ -1,25 +1,26 @@ Name: HaTeX
-Version: 3.6.0.1
+Version: 3.6.1.0
 Author: Daniel Díaz
-Category: Text
+Category: Text, LaTeX
 Build-type: Simple
 License: BSD3
 License-file: license
 Maintainer: Daniel Díaz (dhelta `dot` diaz `at` gmail `dot` com)
-Stability: Experimental
 Bug-reports: https://github.com/Daniel-Diaz/HaTeX/issues
 Synopsis: The Haskell LaTeX library.
 Description: The LaTeX project site states: \"LaTeX is a high-quality typesetting system\". This library provides
-             a bridge between LaTeX and Haskell (i.e. it is a LaTeX DSL).
+             a bridge between LaTeX and Haskell, implementing the LaTeX syntax in Haskell.
              .
+             Some of the things you can do are:
+             .
              Write LaTeX documents with all the advantages you already have in Haskell (recursion,
              type system, high order functions, ...), create a LaTeX backend for your own program,
              make analysis of LaTeX code through its Abstract Syntax Tree (AST), pretty-print Haskell
              values in LaTeX, generate TikZ scripts easily, ...
              .
              See the @examples@ directory in the source distribution to look some simple examples.
-             It would be good to get you started. HaTeX User's Guide is available at
-             <https://github.com/Daniel-Diaz/HaTeX-Guide>.
+             It would be good to get you started. The HaTeX User's Guide is available at
+             <https://github.com/Daniel-Diaz/hatex-guide>.
 Cabal-version: >= 1.6
 Extra-source-files:
   ReleaseNotes
@@ -37,16 +38,16 @@ 
 Source-repository head
   type: git
-  location: git://github.com/Daniel-Diaz/HaTeX.git
+  location: git@github.com:Daniel-Diaz/HaTeX.git
 
 Library
-  Build-depends: base ==4.*
-               , bytestring
+  Build-depends: base == 4.*
+               , bytestring >= 0.9.2.1 && < 0.11
                , transformers >= 0.2.2 && < 0.4
-               , text
-               , attoparsec
+               , text >= 0.11.2.3 && < 0.12
+               , attoparsec >= 0.10.2 && < 0.11
                , matrix
-               , containers
+               , containers >= 0.4.2.1 && < 0.6
   Exposed-modules:
     Text.LaTeX
       -- Base (Core of the library)
README.md view
@@ -1,6 +1,6 @@ # HaTeX ReadMe
 
-`HaTeX` is the LaTeX syntax implementation done in Haskell.
+HaTeX is a Haskell library that implements the LaTeX syntax.
 
 Check a list of examples of usage in the [examples](Examples/) directory.
 A good starting point may be [simple.hs](Examples/simple.hs).
@@ -22,12 +22,12 @@     $ cabal install
 
 However, note that the API may be unstable and is subject to any kind of change.
-The package version follows the [_Package Versioning Policy_](http://www.haskell.org/haskellwiki/Package_versioning_policy),
+In the other hand, this package follows the [_Package Versioning Policy_](http://www.haskell.org/haskellwiki/Package_versioning_policy),
 so it is unlikely to suffer from API breakages if you follow it too when importing the library.
 
 ## HaTeX User's Guide
 
-The HaTeX User's Guide lives [here](https://github.com/Daniel-Diaz/HaTeX-Guide)... and is also done in Haskell!
+The HaTeX User's Guide lives [here](https://github.com/Daniel-Diaz/hatex-guide)... and is also done in Haskell!
 It is free source and anybody can contribute to it. Doing so, you will help current and future users!
 
 A downloadable version (not necessarily the last version, but most likely)
Text/LaTeX/Packages/AMSMath.hs view
@@ -37,6 +37,10 @@  , texp
  , tlog , ln
  , tsqrt
+   -- ** Sum/Integral symbols
+ , tsum , sumFromTo
+ , prod , prodFromTo
+ , integral , integralFromTo
    -- ** Operator symbols
    -- *** Arithmetic
  , pm , mp
@@ -382,6 +386,41 @@ tsqrt :: LaTeXC l => Maybe l -> l -> l
 tsqrt Nothing  = liftL $ \x -> TeXComm "sqrt" [FixArg x]
 tsqrt (Just n) = liftL2 (\n x -> TeXComm "sqrt" [OptArg n, FixArg x]) n
+
+---- Sum/Integral symbols
+
+-- | Sigma sumation symbol.
+tsum :: LaTeXC l => l
+tsum = comm0 "sum"
+
+-- | Sigma sumation symbol with limits.
+sumFromTo :: LaTeXC l
+          => l -- ^ Expression below the sigma.
+          -> l -- ^ Expression above the sigma.
+          -> l
+sumFromTo from to = tsum !: from ^: to
+
+-- | Pi product symbol.
+prod :: LaTeXC l => l
+prod = comm0 "prod"
+
+-- | Pi product symbol with limits.
+prodFromTo :: LaTeXC l
+           => l -- ^ Expression below the pi.
+           -> l -- ^ Expression above the pi.
+           -> l
+prodFromTo from to = prod !: from ^: to
+
+-- | Integral symbol.
+integral :: LaTeXC l => l
+integral = comm0 "int"
+
+-- | Integral symbol with limits of integration.
+integralFromTo :: LaTeXC l
+               => l -- ^ Lower limit of integration.
+               -> l -- ^ Upper limit of integration.
+               -> l
+integralFromTo from to = integral !: from ^: to
 
 ---- Operator symbols
 
Text/LaTeX/Packages/Beamer.hs view
@@ -17,8 +17,8 @@  , uncover
  , only
    -- ** Themes
- , Theme (..)
  , usetheme
+ , Theme (..)
    ) where
 
 import Text.LaTeX.Base.Syntax
@@ -95,6 +95,7 @@ --TODO: Add a short description of each theme.
 
 -- | A 'Theme' of a presentation. See 'usetheme'.
+--   A preview of each one is given below.
 data Theme = 
     AnnArbor -- ^ <<http://daniel-diaz.github.io/projects/hatex/beamer/previewAnnArbor.png>>
   | Antibes -- ^ <<http://daniel-diaz.github.io/projects/hatex/beamer/previewAntibes.png>>
Text/LaTeX/Packages/TikZ/PathBuilder.hs view
@@ -31,9 +31,11 @@  , rectangle  , circle  , ellipse+ , node  , grid    ) where +import Text.LaTeX.Base.Syntax (LaTeX) import Text.LaTeX.Packages.TikZ.Syntax import Control.Monad.Trans.State import Control.Applicative@@ -88,7 +90,10 @@ grid :: [GridOption] -> TPoint -> PathBuilder () grid xs p = applyToPath $ \x -> Grid x xs p +-- | Text centered at the current point.+node :: LaTeX -> PathBuilder ()+node l = applyToPath $ \x -> Node x l+ -- | Build a path using a /starting point/ and a 'PathBuilder'. bpath :: TPoint -> PathBuilder a -> TPath bpath p pb = currentPath $ execState (pathBuilder pb) (PS $ Start p)-
Text/LaTeX/Packages/TikZ/Simple.hs view
@@ -7,12 +7,12 @@ -- --   Please, note that this module is not intended to be imported in the same module --   than Text.LaTeX.Packages.TikZ. This module is itself a self-contained /alternative/---   of that module. If still want to use both modules, please, use qualified imports+--   of that module. If you still want to use both modules, please, use qualified imports --   to avoid name clashes. -- --   In the /Examples/ directory of the source distribution, the file @tikzsimple.hs@---   contains a complete example of usage of this module. Below you can see a picture---   along with the code it came from.+--   contains a complete example of usage of this module with several pictures.+--   Below you can see a picture along with the code it came from. -- --   <<http://daniel-diaz.github.com/projects/hatex/tikzsimple.png>> --@@ -30,12 +30,17 @@    -- * Figures  , Figure (..)  , Point+   -- | /In the future we will accept colors other than the basic ones./  , Color (..)+   -- * Additional functions+ , pathImage    -- * Figure scripting  , figuretikz+ , (T.->>)  , tikzpicture    ) where +import Text.LaTeX.Base.Syntax (LaTeX) import Text.LaTeX.Base.Types (Measure) import Text.LaTeX.Packages.TikZ (TikZ,Color,tikzpicture,emptytikz,tikz) import qualified Text.LaTeX.Packages.TikZ as T@@ -57,14 +62,20 @@  | Ellipse Point Double Double -- ^ Ellipse centered at the given point with width and                                --   height given by the other parameters.  | EllipseFilled Point Double Double -- ^ Same as 'Ellipse', but filled with some color.+ | Text Point LaTeX -- ^ Insert some 'LaTeX' code, centered at the given 'Point'.+                    --   The text should not be very complex to fit nicely in the picture.  | Colored Color Figure -- ^ Color for the given 'Figure'.  | LineWidth Measure Figure -- ^ Line width for the given 'Figure'.  | Scale Double Figure -- ^ Scaling of the given 'Figure' by a factor.+ | Rotate Double Figure -- ^ Rotate a 'Figure' by a given angle (in radians).  | Figures [Figure] -- ^ A figure composed by a list of figures.  castpoint :: Point -> T.TPoint castpoint (x,y) = T.pointAtXY x y +radiansToDegrees :: Double -> Double+radiansToDegrees x = (180 * x) / pi+ -- | Translate a 'Figure' to a 'TikZ' script. figuretikz :: Figure -> TikZ figuretikz (Line []) = emptytikz@@ -79,7 +90,41 @@ figuretikz (CircleFilled p r) = T.fill $ T.Circle (T.Start $ castpoint p) r figuretikz (Ellipse p r1 r2) = T.draw $ T.Ellipse (T.Start $ castpoint p) (r1/2) (r2/2) figuretikz (EllipseFilled p r1 r2) = T.fill $ T.Ellipse (T.Start $ castpoint p) r1 r2+figuretikz (Text p l) = T.draw $ T.Node (T.Start $ castpoint p) l figuretikz (Colored c f) = T.scope [T.TColor c] $ figuretikz f figuretikz (LineWidth m f) = T.scope [T.TWidth m] $ figuretikz f figuretikz (Scale q f) = T.scope [T.TScale q] $ figuretikz f+figuretikz (Rotate a f) = T.scope [T.TRotate $ radiansToDegrees a] $ figuretikz f figuretikz (Figures fs) = foldr (\x y -> figuretikz x T.->> y) emptytikz fs++-- | The figure of a /path/. A /path/ (in this context) means a function from an interval to+--   the plane. The image of such a function is what this function returns as a 'Figure'.+--   An additional argument is needed to set the precision of the curve.+--+--   The actual implementation builds a spline of degree one joining different points of the+--   image. Given that the interval is /(a,b)/ and the precision argument is &#949;, the points+--   in the spline will be /f(a)/, /f(a+/&#949;/)/, /f(a+2/&#949;/)/, and so on, until reaching /f(b)/.+--   The smaller is &#949;, the closer is the figure to the original image.+--+--   Here is an example with a logarithmic spiral.+--+--   <<http://daniel-diaz.github.io/projects/hatex/spiral.png>>+--+-- > spiral :: Figure+-- > spiral = LineWidth (Pt 2) $+-- >     pathImage 0.01 (0,4) $+-- >       \t -> ( a * exp t * cos (b*t)+-- >             , a * exp t * sin (b*t)+-- >               )+-- >   where+-- >     a = 0.1 ; b = 4+--+pathImage :: Double -- ^ Precision argument, &#949;.+          -> (Double,Double) -- ^ Interval, /(a,b)/.+          -> (Double -> Point) -- ^ Path function, /f/.+          -> Figure -- ^ Output figure.+pathImage eps (a,b) f = Line $ fmap f $ listFrom a+  where+   listFrom a =+     if a >= b then [b]+               else a : listFrom (a+eps)
Text/LaTeX/Packages/TikZ/Syntax.hs view
@@ -42,6 +42,7 @@   import Text.LaTeX.Base.Types import Text.LaTeX.Base.Render+import Text.LaTeX.Base.Syntax import Text.LaTeX.Packages.Color -- TODO: Extend colors to anything accepted in TikZ. import Data.Monoid@@ -136,6 +137,12 @@                                 -- /Last point:/ The last point of @y@ is the same as the                                 -- last point of @x@.   | Grid TPath [GridOption] TPoint+  | Node TPath LaTeX -- ^ Let @y = Node x l@.+                     --+                     -- /Operation:/ Set a text centered at the last point of @x@.+                     --+                     -- /Last point:/ The last point of @y@ is the same as the last+                     -- point of @x@.     deriving Show  data GridOption =@@ -157,6 +164,7 @@  render (Ellipse p r1 r2) = render p <> " ellipse (" <> render r1 <> " and " <> render r2 <> ")"  render (Grid p1 [] p2) = render p1 <> " grid " <> render p2  render (Grid p1 xs p2) = render p1 <> " grid " <> render xs <> " " <> render p2+ render (Node p l) = render p <> " node[transform shape] " <> render (TeXBraces l)  instance Render GridOption where  render (GridStep s) = "step=" <> render s@@ -202,15 +210,17 @@    TWidth Measure  | TColor Color  | TScale Double+ | TRotate Double -- ^ Angle is in degrees.      deriving Show  renderPair :: Render a => Text -> a -> Text renderPair x y = x <> "=" <> render y  instance Render Parameter where- render (TWidth m) = renderPair "line width" m- render (TColor c) = renderPair "color" c- render (TScale q) = renderPair "scale" q+ render (TWidth m)  = renderPair "line width" m+ render (TColor c)  = renderPair "color" c+ render (TScale q)  = renderPair "scale" q+ render (TRotate a) = renderPair "rotate" a  -- TikZ @@ -262,11 +272,11 @@ path :: [ActionType] -> TPath -> TikZ path = PathAction --- | Applies a scope to a TikZ script.+-- | Applies a scope to a Ti/k/Z script. scope :: [Parameter] -> TikZ -> TikZ scope = Scope --- | Sequence two TikZ scripts.+-- | Sequence two Ti/k/Z scripts. (->>) :: TikZ -> TikZ -> TikZ (TikZSeq s1) ->> (TikZSeq s2) = TikZSeq (s1 <> s2) (TikZSeq s) ->> a = TikZSeq $ s S.|> a