HaTeX 3.17.3.1 → 3.23.0.2
raw patch · 40 files changed
Files
- CHANGELOG.md +158/−1
- Examples/biblatex.hs +48/−0
- Examples/biblatexDOI.hs +24/−0
- Examples/matrices.hs +1/−1
- Examples/multirow.hs +48/−0
- HaTeX.cabal +145/−143
- README.md +16/−74
- ReleaseNotes +0/−91
- Setup.hs +0/−3
- Text/LaTeX.hs +1/−1
- Text/LaTeX/Base.hs +3/−4
- Text/LaTeX/Base/Class.hs +188/−23
- Text/LaTeX/Base/Commands.hs +147/−31
- Text/LaTeX/Base/Math.hs +1081/−0
- Text/LaTeX/Base/Parser.hs +17/−13
- Text/LaTeX/Base/Pretty.hs +21/−12
- Text/LaTeX/Base/Render.hs +73/−34
- Text/LaTeX/Base/Syntax.hs +25/−33
- Text/LaTeX/Base/Types.hs +9/−7
- Text/LaTeX/Base/Warnings.hs +4/−1
- Text/LaTeX/Base/Writer.hs +13/−18
- Text/LaTeX/Packages/AMSFonts.hs +18/−5
- Text/LaTeX/Packages/AMSMath.hs +31/−796
- Text/LaTeX/Packages/AMSSymb.hs +186/−4
- Text/LaTeX/Packages/AMSThm.hs +8/−1
- Text/LaTeX/Packages/Acronym.hs +258/−0
- Text/LaTeX/Packages/Babel.hs +5/−4
- Text/LaTeX/Packages/BibLaTeX.hs +237/−0
- Text/LaTeX/Packages/Bigstrut.hs +37/−0
- Text/LaTeX/Packages/Color.hs +4/−2
- Text/LaTeX/Packages/Graphicx.hs +7/−5
- Text/LaTeX/Packages/Hyperref.hs +1/−2
- Text/LaTeX/Packages/Lscape.hs +37/−0
- Text/LaTeX/Packages/Multirow.hs +62/−0
- Text/LaTeX/Packages/QRCode.hs +1/−2
- Text/LaTeX/Packages/TikZ/PathBuilder.hs +5/−8
- Text/LaTeX/Packages/TikZ/Syntax.hs +1/−1
- Text/LaTeX/Packages/Trees.hs +2/−9
- license +2/−2
- test/Main.hs +3/−9
CHANGELOG.md view
@@ -5,10 +5,85 @@ For a full list of changes, see the commit history of the git repository: -https://github.com/Daniel-Diaz/HaTeX/commits/master+https://codeberg.org/daniel-casanueva/HaTeX/commits/branch/main # Changelog by versions +## 3.23.0.2+* Support for containers-0.8.++## 3.23.0.1+* Metadata update.+* Drop gitlab CI.++## 3.23.0.0+* Rename `forall` as `forall_` (Patrick Ritzenfeld).+* Drop trailing zeros and decimal point from rendered Floats and Doubles (David Fox).+* Fix line break command formatting (David Fox).+* Fix typo in `twoheadrightarrow` (Daniel Casanueva).++## 3.22.4.2+* Drop support for `base < 4.14`.+* Support `hashable-1.5.0.0`.+* Remove uses of CPP.++## 3.22.4.1+* QuickCheck instance fix.++## 3.22.4.0+* Define `(<>)` instead of `mappend`.+* Use `fmap` instead of `liftM`.+* New function: `applyDOIReferenceResolves`.+* Make parser test more lenient (it was commented due to issue #144).+* Metadata update.+* Unify files `ReleaseNotes` and `CHANGELOG.md`.++## From 3.22.3.1 to 3.22.3.2+* Relax transformers dependency upper bound from `< 0.6` to `< 0.7`.++## From 3.22.3.0 to 3.22.3.1+* Allow bytestring version 0.11 (#153).+* Allow hashable 1.4 and text 2.0 (#154).++## From 3.22.2.0 to 3.22.3.0+* Add more math symbols. (leftaroundabout)++## From 3.22.1.0 to 3.22.2.0+* New render method: renderBuilder.++## From 3.22.0.0 to 3.22.1.0+* Export PlainDOI type synonym.+* Comment out QuickCheck parser test. See https://github.com/Daniel-Diaz/HaTeX/issues/144.+* New function `qed`.++## From 3.21.0.0 to 3.22.0.0+* More liftLX, commX and envX functions. (KommuSoft)+* New module: Text.LaTeX.Packages.Acronym. (KommuSoft)+* Expanded BibLaTeX module with new functionality. (leftaroundabout)+* Dropped support for GHC-7.8 (and earlier versions).++## From 3.20.0.1 to 3.21.0.0++* Replace wl-pprint-extras with prettyprinter in the latex pretty-printer.+* Now 'table' takes a list of positions. (breaking change)+* Added constructors Here and ForcePos to the Pos type.+* Make argument of 'nopagebreak' optional.++## From 3.18.0.0 to 3.19.0.0++* Fix build with GHC 8.4.1 (#113) (leftaroundabout).+* Added Multirow, Bigstrut, and Lscape modules (#107, #111) (romildo).+* More spacing and line breaking commands (#108, #110) (romildo).++## From 3.17.3.1 to 3.18.0.0++* _Warning:_ Using 3.18.0.0 is not recommended, since it fails to build with GHC 8.4.1.+ Please, upgrade to 3.19.0.0.++* New bibtex module (leftaroundabout).+* New function 'squareBraces' (NorfairKing).+* New function 'table' (leftaroundabout).+ ## From 3.17.1.0 to 3.17.2.0 * Semigroup instance for LaTeX.@@ -88,3 +163,85 @@ * Modified LaTeX Monoid instance to make monoid laws hold. * Some documentation improvements. * Added this CHANGELOG!++## 3.4++* Num instance for LaTeXT.+* New re-exports: liftIO.+* Relaxed transformers package dependency to: >= 0.2.2 && < 0.4+* Changed infix rule of (=:) and (/=:).+* More documentation notes.+* New functions: hfill, vfill.+* The internal representation of LaTeXT has changed to prevent+ a set of errors.+* Changes in Text.LaTeX.+* Several minor fixes.++## 3.3++* New functions 'protectString' and 'protectText'.+* New function 'rendertexM'.+* New environments: 'figure' and 'caption'.+* New example: simple.hs.+* Updated version of transfomers to 0.3.*.+* Trees implemented: datatype and Qtree package.+* Render instances for Integer and Double.+* New docs.+* Class system implemented. Monad modules dropped.++## 3.2.0.1++* This version only fix the patch that makes HaTeX compatible with GHC 7.4.++## 3.2++### Highlights:++* Parser implemented (New dependency on parsec).+* Greek alphabet added to AMSMath.+* New LaTeX package: graphicx.+* Function 'documentclass' changed.++### Other changes:++* Dependency changed from mtl to transformers.+* New commands: par, textwidth and linewidth.+* New environment: minipage.+* Compatibility with GHC 7.4 (with CPP extension).+* Function 'lift' is now re-exported in Text.LaTeX.Base.Writer module.+* New function 'renderChars' in the Render module.+* ReadMe edited, now with ToDo list.++## 3.1.1++* Dependency relaxed from 'mtl == 2.*' to 'transformers == 0.2.*'.++## 3.1.0++### Highlights:++* Added warnings (See Text.LaTeX.Base.Warnings).+* Added an "Examples" directory.+* Num instance for LaTeX and LaTeXT.+* New package implemented "AMSThm" (See Text.LaTeX.Packages.AMSThm).++### Changes by modules:++Base modules:++* Text.LaTeX.Base.Syntax: Added Eq instance to LaTeX and TeXArg.+* Text.LaTeX.Base.Writer: Added MonadTrans instance to LaTeXT.+ New functions: execLaTeXTWarn, liftFun, liftOp.+* Text.LaTeX.Base.Types: Added Eq instance to Label.+* Text.LaTeX.Base: Added Num instance to LaTeX.+* Text.LaTeX.Base.Monad: Added Num instance to LaTeXT.+* Text.LaTeX.Base.Commands: New function: between.++Package modules:++* Text.LaTeX.Packages.AMSMath: New symbols: (=:) , (/=:) , forall+ , dagger, ddagger, in_ , ni, (<:) , (<=:), (>:) , (>=:)++## 3.0.0++* First release of the third version of HaTeX.
+ Examples/biblatex.hs view
@@ -0,0 +1,48 @@++{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE PackageImports #-}++import Text.LaTeX+import Text.LaTeX.Packages.BibLaTeX+import Text.LaTeX.Packages.Inputenc+import qualified "bibtex" Text.BibTeX.Entry as BibTeX+import qualified "bibtex" Text.BibTeX.Format as BibTeX+import System.IO (writeFile)+import System.Process (callProcess)++main :: IO ()+main = do+ execLaTeXT bibLaTeXExample >>= renderFile "biblatex.tex"+ writeFile bibFile . unlines $ BibTeX.entry <$> exampleBibliography+ mapM_ (`callProcess`["biblatex"]) ["pdflatex", "biber", "pdflatex"]++bibFile = "biblatex-example.bib"++bibLaTeXExample :: Monad m => LaTeXT_ m+bibLaTeXExample = thePreamble >> document theBody++thePreamble :: Monad m => LaTeXT_ m+thePreamble = do+ documentclass [] article+ usepackage [utf8] inputenc+ usepackage ["backend=biber"] biblatex+ addbibresource bibFile+ author "Justus Sageműller"+ title "BibLaTeX example using HaTeX"++theBody :: Monad m => LaTeXT_ m+theBody = do+ "Bib"<>latex<>cite "bibLaTeX-manual"+ " is a package for creating references to literature listed in a Bib"<>tex<>" file"+ " (extension "<>verb".bib"<>")."+ printbibliography++exampleBibliography :: [BibTeX.T]+exampleBibliography =+ [ BibTeX.Cons+ "manual"+ "bibLaTeX-manual"+ [ ("author", "P Lehman and P Kime and A Boruvka and J Wright")+ , ("title", "The biblatex Package. Programmable Bibliographies and Citations.")+ , ("URL", "http://mirrors.ctan.org/macros/latex/contrib/biblatex/doc/biblatex.pdf") ]+ ]
+ Examples/biblatexDOI.hs view
@@ -0,0 +1,24 @@++{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE PackageImports #-}++import Text.LaTeX+import Text.LaTeX.Packages.BibLaTeX+import Text.LaTeX.Packages.Inputenc+import System.IO (writeFile)+import System.Process (callProcess)++main :: IO ()+main = do+ execLaTeXT bibLaTeXExample >>= renderFile "biblatexDOI.tex"+ mapM_ (`callProcess`["biblatexDOI"]) ["pdflatex", "biber", "pdflatex"]++bibLaTeXExample :: LaTeXT IO ()+bibLaTeXExample = do+ documentclass [] article+ usepackage ["backend=biber"] biblatex+ documentWithDOIReferences+ (masterBibFile "/home/data/promotion/Literatur/literatur.bib") $ do+ "We can cite documents by simply giving a DOI, such as "+ citeDOI "123456789" "J Doe et al 1950: Investigation of Foo"+ printbibliography
Examples/matrices.hs view
@@ -19,4 +19,4 @@ usepackage [] amsmath theBody :: Monad m => LaTeXT_ m-theBody = equation_ $ pmatrix Nothing $ (identity 5 :: Matrix Int)+theBody = equation_ $ pmatrix Nothing (identity 5 :: Matrix Int)
+ Examples/multirow.hs view
@@ -0,0 +1,48 @@+{-# LANGUAGE OverloadedStrings #-}++import Text.LaTeX+import Text.LaTeX.Packages.Bigstrut+import Text.LaTeX.Packages.Multirow++main :: IO ()+main = execLaTeXT example >>= renderFile "multirow.tex"++example :: Monad m => LaTeXT_ m+example = do+ documentclass [] article+ usepackage [] multirowp+ usepackage [] bigstrutp+ document exampleBody++minitab :: Monad m => TableSpec -> LaTeXT_ m -> LaTeXT_ m+minitab tableSpec = tabular Nothing [tableSpec]++exampleBody :: Monad m => LaTeXT_ m+exampleBody = do+ "An example with both multirow and bigstrut"+ par+ tabular Nothing [VerticalLine, CenterColumn, VerticalLine, CenterColumn, VerticalLine] $ do+ hline+ multirow Nothing 4 Nothing (In 1) Nothing "Common g text" &+ "Column g2a" <> lnbk+ mempty & "Column g2b" <> lnbk+ mempty & "Column g2c" <> lnbk+ mempty & "Column g2d" <> lnbk+ hline+ multirow Nothing 3 (Just (BigStruts 6)) (CustomMeasure "*") Nothing "Common g text" &+ ("Column g2a" <> bigstrut) <> lnbk <> cline 2 2+ mempty & ("Column g2b" <> bigstrut) <> lnbk <> cline 2 2+ mempty & ("Column g2c" <> bigstrut) <> lnbk+ hline+ multirow Nothing 4 (Just (BigStruts 8)) (In 1) Nothing "Common g text, but a bit longer." &+ ("Column g2a" <> bigstrut) <> lnbk <> cline 2 2+ mempty & ("Column g2b" <> bigstrut) <> lnbk <> cline 2 2+ mempty & ("Column g2c" <> bigstrut) <> lnbk <> cline 2 2+ mempty & ("Column g2d" <> bigstrut) <> lnbk+ hline+ multirow Nothing 4 Nothing (CustomMeasure "*") Nothing (minitab CenterColumn ("Common " <> lnbk <> "g text")) &+ "Column g2a" <> lnbk+ mempty & "Column g2b" <> lnbk+ mempty & "Column g2c" <> lnbk+ mempty & "Column g2d" <> lnbk+ hline
HaTeX.cabal view
@@ -1,143 +1,145 @@-Name: HaTeX -Version: 3.17.3.1 -Author: Daniel Díaz -Category: LaTeX -Build-type: Simple -License: BSD3 -License-file: license -Maintainer: Daniel Díaz (dhelta `dot` diaz `at` gmail `dot` com) -Bug-reports: https://github.com/Daniel-Diaz/HaTeX/issues -homepage: https://github.com/Daniel-Diaz/HaTeX/blob/master/README.md -Synopsis: The Haskell LaTeX library. -Description: This library implements the LaTeX syntax and provides some useful abstractions. - . - Some of the things you can do with HaTeX 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. - . - * Parse a LaTeX file and obtain its Abstract Syntax Tree (AST). - . - * Pretty-print Haskell values in LaTeX. - . - * Generate TikZ scripts (images!) easily. - . - Browse the @examples@ directory in the source distribution to see some simple examples. - It might help you to get started. The HaTeX User's Guide is available at - <https://github.com/Daniel-Diaz/hatex-guide/blob/master/README.md>. - We also have a mailing list (<http://projects.haskell.org/cgi-bin/mailman/listinfo/hatex>) - and an IRC channel (@#hatex@). If you just want to read a short introduction, read - the "Text.LaTeX" module. - . - If you prefer to write in LaTeX and all you want is to /program/ some parts of the document, - or if you already have the LaTeX document written and you just want to add some automatically - generated LaTeX code somewhere, check haskintex: <http://daniel-diaz.github.io/projects/haskintex>. - It allows you to embed Haskell in LaTeX. It also makes you easy to use HaTeX within a LaTeX document. -Cabal-version: >= 1.18 -Extra-source-files: - ReleaseNotes - README.md - CHANGELOG.md - -- Examples - Examples/*.hs - -- Tests - parsertest/*.tex - parsertest/parsertest.hs -Extra-doc-files: - -- TikZ - docfiles/tikz/*.png - -- Beamer - docfiles/beamers/*.png - -- Others - docfiles/others/*.png - -Source-repository head - type: git - location: git://github.com/Daniel-Diaz/HaTeX.git - -Library - Default-language: Haskell2010 - Build-depends: base == 4.* - , bytestring >= 0.9.2.1 && < 0.11 - , 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 - -- Parsing - , 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) - Text.LaTeX.Base - Text.LaTeX.Base.Class - Text.LaTeX.Base.Commands - Text.LaTeX.Base.Parser - Text.LaTeX.Base.Pretty - Text.LaTeX.Base.Render - Text.LaTeX.Base.Syntax - Text.LaTeX.Base.Texy - Text.LaTeX.Base.Types - Text.LaTeX.Base.Writer - Text.LaTeX.Base.Warnings - -- Packages - Text.LaTeX.Packages.AMSFonts - Text.LaTeX.Packages.AMSMath - Text.LaTeX.Packages.AMSSymb - Text.LaTeX.Packages.AMSThm - Text.LaTeX.Packages.Babel - Text.LaTeX.Packages.Beamer - Text.LaTeX.Packages.Color - Text.LaTeX.Packages.Fancyhdr - Text.LaTeX.Packages.Fontenc - 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 - -- TikZ - Text.LaTeX.Packages.TikZ - Text.LaTeX.Packages.TikZ.PathBuilder - Text.LaTeX.Packages.TikZ.Simple - Text.LaTeX.Packages.TikZ.Syntax - Other-modules: Paths_HaTeX - Default-extensions: OverloadedStrings, TypeFamilies - Other-extensions: CPP - ghc-options: -Wall -fno-warn-orphans - -Test-Suite hatex-test - Default-language: Haskell2010 - type: exitcode-stdio-1.0 - hs-source-dirs: test - main-is: Main.hs - build-depends: base == 4.* - , HaTeX - , tasty - , QuickCheck - , tasty-quickcheck - , parsec - ghc-options: -Wall -fno-warn-orphans -Test-Suite parser-tests - Default-language: Haskell2010 - type: exitcode-stdio-1.0 - hs-source-dirs: parsertest - main-is: parsertest.hs - build-depends: base == 4.* - , HaTeX - , text - ghc-options: -Wall +name: HaTeX+version: 3.23.0.2+category: LaTeX+build-type: Simple+license: BSD3+license-file: license+maintainer: Daniel Casanueva (coding `at` danielcasanueva.eu)+homepage: https://codeberg.org/daniel-casanueva/HaTeX+bug-reports: https://codeberg.org/daniel-casanueva/HaTeX/issues+synopsis: The Haskell LaTeX library.+description: This library implements the LaTeX syntax and provides some useful abstractions.+ .+ Some of the things you can do with HaTeX 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.+ .+ * Parse a LaTeX file and obtain its Abstract Syntax Tree (AST).+ .+ * Pretty-print Haskell values in LaTeX.+ .+ * Generate TikZ scripts (images!) easily.+ .+ Browse the @examples@ directory in the source distribution to see some simple examples.+ It might help you to get started.+ .+ If you prefer to write in LaTeX and all you want is to /program/ some parts of the document,+ or if you already have the LaTeX document written and you just want to add some automatically+ generated LaTeX code somewhere, check haskintex:+ <https://codeberg.org/daniel-casanueva/haskintex>.+ It allows you to embed Haskell in LaTeX. It also makes it easy to use HaTeX within a+ LaTeX document.+cabal-version: 1.18+extra-source-files:+ -- Examples+ Examples/*.hs+ -- Tests+ parsertest/*.tex+ parsertest/parsertest.hs+extra-doc-files:+ README.md+ CHANGELOG.md+ -- TikZ+ docfiles/tikz/*.png+ -- Beamer+ docfiles/beamers/*.png+ -- Others+ docfiles/others/*.png++library+ default-language: Haskell2010+ build-depends: base >= 4.14 && < 5+ , bytestring >= 0.9.2.1 && < 0.13+ , text >= 0.11.2.3 && < 2.2+ , transformers >= 0.2.2 && < 0.7+ , containers >= 0.4.2.1 && < 0.9+ , hashable >= 1.2 && < 1.6+ , bibtex >= 0.1 && < 0.2+ , matrix+ -- Testing+ , QuickCheck+ -- Parsing+ , parsec >= 3.1.6+ -- Pretty-printing+ , prettyprinter+ if impl(ghc < 7.6)+ build-depends: ghc-prim+ if impl(ghc < 8.0)+ build-depends: semigroups+ exposed-modules:+ Text.LaTeX+ -- Base (Core of the library)+ Text.LaTeX.Base+ Text.LaTeX.Base.Class+ Text.LaTeX.Base.Commands+ Text.LaTeX.Base.Math+ Text.LaTeX.Base.Parser+ Text.LaTeX.Base.Pretty+ Text.LaTeX.Base.Render+ Text.LaTeX.Base.Syntax+ Text.LaTeX.Base.Texy+ Text.LaTeX.Base.Types+ Text.LaTeX.Base.Writer+ Text.LaTeX.Base.Warnings+ -- Packages+ Text.LaTeX.Packages.Acronym+ Text.LaTeX.Packages.AMSFonts+ Text.LaTeX.Packages.AMSMath+ Text.LaTeX.Packages.AMSSymb+ Text.LaTeX.Packages.AMSThm+ Text.LaTeX.Packages.Babel+ Text.LaTeX.Packages.Beamer+ Text.LaTeX.Packages.BibLaTeX+ Text.LaTeX.Packages.Bigstrut+ Text.LaTeX.Packages.Color+ Text.LaTeX.Packages.Fancyhdr+ Text.LaTeX.Packages.Fontenc+ Text.LaTeX.Packages.Geometry+ Text.LaTeX.Packages.Graphicx+ Text.LaTeX.Packages.Hyperref+ Text.LaTeX.Packages.LongTable+ Text.LaTeX.Packages.Lscape+ Text.LaTeX.Packages.LTableX+ Text.LaTeX.Packages.Inputenc+ Text.LaTeX.Packages.Multirow+ Text.LaTeX.Packages.QRCode+ Text.LaTeX.Packages.Relsize+ Text.LaTeX.Packages.TabularX+ -- Trees+ Text.LaTeX.Packages.Trees+ Text.LaTeX.Packages.Trees.Qtree+ -- TikZ+ Text.LaTeX.Packages.TikZ+ Text.LaTeX.Packages.TikZ.PathBuilder+ Text.LaTeX.Packages.TikZ.Simple+ Text.LaTeX.Packages.TikZ.Syntax+ other-modules: Paths_HaTeX+ default-extensions: OverloadedStrings, TypeFamilies, TypeOperators+ other-extensions: CPP+ ghc-options: -Wall -fno-warn-orphans++test-suite hatex-test+ default-language: Haskell2010+ type: exitcode-stdio-1.0+ hs-source-dirs: test+ main-is: Main.hs+ build-depends: base == 4.*+ , HaTeX+ , tasty+ , QuickCheck+ , tasty-quickcheck+ , parsec+ ghc-options: -Wall -fno-warn-orphans++test-suite parser-tests+ default-language: Haskell2010+ type: exitcode-stdio-1.0+ hs-source-dirs: parsertest+ main-is: parsertest.hs+ build-depends: base == 4.*+ , HaTeX+ , text+ ghc-options: -Wall
README.md view
@@ -3,83 +3,25 @@ HaTeX is a Haskell library that implements the *LaTeX syntax*, plus some abstractions on top. -Check a list of usage examples in the [Examples](https://github.com/Daniel-Diaz/HaTeX/tree/master/Examples) directory-of the repository in GitHub.-A good starting point is [simple.hs](https://github.com/Daniel-Diaz/HaTeX/blob/master/Examples/simple.hs).-Run any example script executing the ``main`` function.--## Installation notes--To install `HaTeX`, use [cabal-install](http://hackage.haskell.org/package/cabal-install)-or [stack](http://docs.haskellstack.org/en/stable/README).--To install with cabal, run:-- $ cabal update- $ cabal install HaTeX--This will download and install the latest official release (recommended).-If you want to try a newer version, use _git_ to clone the code contained-in this repository.-- $ git clone https://github.com/Daniel-Diaz/HaTeX.git- $ cd HaTeX- $ cabal install--However, this is not recommended as it may include some bugs or oddities due to in-development features.-Note that 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 (assuming-you are using the version in Hackage).--## Current HaTeX versions--[](https://hackage.haskell.org/package/HaTeX)--[](http://stackage.org/lts/package/HaTeX)--[](http://stackage.org/nightly/package/HaTeX)--## HaTeX User's Guide--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 latest version, but most likely)-can be found [here](http://daniel-diaz.github.com/projects/hatex/hatex-guide.pdf).-To be sure that you are reading the last version, go to the github repository of the guide and follow instructions-to build it. It is fairly easy.--Please note that the user's guide needs to be updated (contributions are more than welcome!).--## Community and Contributions--There are many ways to get involved in the HaTeX project. Use the most comfortable way for you.+Check a list of usage examples in the+[Examples](https://codeberg.org/daniel-casanueva/HaTeX/src/branch/main/Examples)+directory.+A good starting point is+[simple.hs](https://codeberg.org/daniel-casanueva/HaTeX/src/branch/main/Examples/simple.hs).+Run any example script executing the `main` function. -* Fork the [GitHub repository](https://github.com/Daniel-Diaz/HaTeX) and make your own contributions.-* Report bugs or make suggestions opening a ticket in the [Issue Tracker](https://github.com/Daniel-Diaz/HaTeX/issues).-* Help us to improve and extend our [hatex-guide](https://github.com/Daniel-Diaz/hatex-guide).-* Join the [Mailing List](http://projects.haskell.org/cgi-bin/mailman/listinfo/hatex) for help or announcements of the-latest developments.+## How to contribute -## TODO list+There are the options for potential contributors: -* Add more examples.-* Add more documentation.-* BibTeX support.+* Fork the [git repository](https://codeberg.org/daniel-casanueva/HaTeX)+ and open a pull request.+* Report bugs or make suggestions opening a ticket in the+ [Issue Tracker](https://codeberg.org/daniel-casanueva/HaTeX/issues). ## Related projects -* [haskintex](http://daniel-diaz.github.io/projects/haskintex): Tool to use Haskell (and, additionaly, the HaTeX library)-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.--## Travis automatic build--For every code push to the GitHub repository, an automatic build checks that the library compiles with several-versions of GHC (7.4, 7.6, and 7.8) and that all tests pass. This label indicates the result of the last automatic-build.--[](https://travis-ci.org/Daniel-Diaz/HaTeX)--Currently, automatic builds are only running under Linux. We hope Travis will support other systems in the future.+* [haskintex](https://codeberg.org/daniel-casanueva/haskintex):+ Tool to use Haskell (and, additionaly, the HaTeX library) 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.
− ReleaseNotes
@@ -1,91 +0,0 @@-HaTeX Release Notes--- From version 3.0.0-->>> 3.4--- Num instance for LaTeXT.-- New re-exports: liftIO.-- Relaxed transformers package dependency to: >= 0.2.2 && < 0.4-- Changed infix rule of (=:) and (/=:).-- More documentation notes.-- New functions: hfill, vfill.-- The internal representation of LaTeXT has changed to prevent- a set of errors.-- Changes in Text.LaTeX.-- Several minor fixes.-->>> 3.3--- New functions 'protectString' and 'protectText'.-- New function 'rendertexM'.-- New environments: 'figure' and 'caption'.-- New example: simple.hs.-- Updated version of transfomers to 0.3.*.-- Trees implemented: datatype and Qtree package.-- Render instances for Integer and Double.-- New docs.-- Class system implemented. Monad modules dropped.-->>> 3.2.0.1--- This version only fix the patch that makes HaTeX compatible with GHC 7.4.-->>> 3.2--Highlights:--+ Parser implemented (New dependency on parsec).-+ Greek alphabet added to AMSMath.-+ New LaTeX package: graphicx.-+ Function 'documentclass' changed.--Other changes:--- Dependency changed from mtl to transformers.-- New commands: par, textwidth and linewidth.-- New environment: minipage.-- Compatibility with GHC 7.4 (with CPP extension).-- Function 'lift' is now re-exported in Text.LaTeX.Base.Writer module.-- New function 'renderChars' in the Render module.-- ReadMe edited, now with ToDo list.-->>> 3.1.1--- Dependency relaxed from 'mtl == 2.*' to 'transformers == 0.2.*'.-->>> 3.1.0--Highlights:--+ Added warnings (See Text.LaTeX.Base.Warnings).-+ Added an "Examples" directory.-+ Num instance for LaTeX and LaTeXT.-+ New package implemented "AMSThm" (See Text.LaTeX.Packages.AMSThm).--Changes by modules:--** Base modules-* Text.LaTeX.Base.Syntax:--- Added Eq instance to LaTeX and TeXArg.-* Text.LaTeX.Base.Writer:--- Added MonadTrans instance to LaTeXT.--- New functions: execLaTeXTWarn, liftFun, liftOp.-* Text.LaTeX.Base.Types:--- Added Eq instance to Label.-* Text.LaTeX.Base:--- Added Num instance to LaTeX.-* Text.LaTeX.Base.Monad:--- Added Num instance to LaTeXT.-* Text.LaTeX.Base.Commands:--- New function: between.--** Package modules:-* Text.LaTeX.Packages.AMSMath--- New symbols: (=:) , (/=:) , forall- , dagger, ddagger, in_ , ni- , (<:) , (<=:)- , (>:) , (>=:)-->>> 3.0.0--* First release of the third version of HaTeX.
− Setup.hs
@@ -1,3 +0,0 @@-import Distribution.Simple--main = defaultMain
Text/LaTeX.hs view
@@ -56,7 +56,7 @@ it contains functions to generate blocks containing LaTeX commands and environments that are always defined. In the other hand, 'LaTeX' is an instance of the 'IsString' class. This allow us to insert LaTeX code containing simple text by just writing it as a 'String'-and enabling the @OverlaodedStrings@ language extension.+and enabling the @OverloadedStrings@ language extension. -} {- $rnd
Text/LaTeX/Base.hs view
@@ -27,7 +27,7 @@ ( -- * @LaTeX@ datatype LaTeX -- * Escaping reserved characters- , protectString , protectText+ , protectString, protectText -- * Internal re-exports , module Text.LaTeX.Base.Render , module Text.LaTeX.Base.Types@@ -45,9 +45,6 @@ -- Internal modules import Text.LaTeX.Base.Syntax ( LaTeX-#if __GLASGOW_HASKELL__ < 704- , (<>)-#endif , protectString , protectText) import Text.LaTeX.Base.Render@@ -56,4 +53,6 @@ import Text.LaTeX.Base.Writer import Text.LaTeX.Base.Texy -- External modules+#if !MIN_VERSION_base(4,11,0) import Data.Monoid+#endif
Text/LaTeX/Base/Class.hs view
@@ -1,6 +1,6 @@- {-# LANGUAGE CPP #-}-{-# OPTIONS_GHC -fno-warn-name-shadowing #-}+{-# OPTIONS_GHC -Wno-name-shadowing #-}+{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} -- | Definition of the 'LaTeXC' class, used to combine the classic applicative and -- the latter monadic interfaces of /HaTeX 3/. The user can define new instances@@ -17,16 +17,15 @@ -- -- > liftLN f x1 ... xN = liftListL (\[x1,...,xN] -> f x1 ... xN) [x1,...,xN] --- , liftL- , liftL2- , liftL3+ , liftL, liftL2, liftL3, liftL4, liftL5, liftL6, liftL7, liftL8, liftL9 -- ** Others- , comm0- , comm1- , comm2- , comm3+ , comm0, comm1, comm2, comm3, comm4, comm5, comm6, comm7, comm8, comm9 , commS- , braces+ , fixComm, optFixComm+ , env0, env1, env2, env3, env4, env5, env6, env7, env8, env9+ , fixEnv+ , braces, squareBraces+ , raw ) where import Text.LaTeX.Base.Syntax@@ -34,37 +33,91 @@ #if !MIN_VERSION_base(4,8,0) import Data.Monoid #endif+import Data.Text (Text) -- | This is the class of 'LaTeX' code generators. It has 'Monoid' and 'IsString' as -- superclasses. class (Monoid l,IsString l) => LaTeXC l where- -- | This method must take a function that combines a list of 'LaTeX' values into a new one,- -- and creates a function that combines @l@-typed values. The combining function can be- -- seen as a function with 0 or more 'LaTeX' arguments with a 'LaTeX' value as output.- liftListL :: ([LaTeX] -> LaTeX) -> [l] -> l+ -- | This method must take a function that combines a list of 'LaTeX' values into a new one,+ -- and creates a function that combines @l@-typed values. The combining function can be+ -- seen as a function with 0 or more 'LaTeX' arguments with a 'LaTeX' value as output.+ liftListL :: ([LaTeX] -> LaTeX) -> [l] -> l -- | This instance just sets @liftListL = id@. instance LaTeXC LaTeX where- liftListL = id+ liftListL = id -- COMBINATORS -- | Map a 'LaTeX' value to its equivalent in any 'LaTeXC' instance. fromLaTeX :: LaTeXC l => LaTeX -> l-fromLaTeX l = liftListL (\_ -> l) []+fromLaTeX l = liftListL (const l) [] -- | Lift a inner function of 'LaTeX' values into any 'LaTeXC' instance. liftL :: LaTeXC l => (LaTeX -> LaTeX) -> l -> l-liftL f x = liftListL (\[x] -> f x) [x]+liftL f x1 = liftListL (\[x1] -> f x1) [x1] -- | Variant of 'liftL' with a two arguments function. liftL2 :: LaTeXC l => (LaTeX -> LaTeX -> LaTeX) -> l -> l -> l-liftL2 f x y = liftListL (\[x,y] -> f x y) [x,y]+liftL2 f x1 x2 = liftListL (\[x1,x2] -> f x1 x2) [x1,x2] -- | Variant of 'liftL' with a three arguments function. liftL3 :: LaTeXC l => (LaTeX -> LaTeX -> LaTeX -> LaTeX) -> l -> l -> l -> l-liftL3 f x y z = liftListL (\[x,y,z] -> f x y z) [x,y,z]+liftL3 f x1 x2 x3 = liftListL (\[x1,x2,x3] -> f x1 x2 x3) [x1,x2,x3] +-- | Variant of 'liftL' with a four arguments function.+liftL4 :: LaTeXC l => (LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX) -> l -> l -> l -> l -> l+liftL4 f x1 x2 x3 x4 = liftListL (\[x1,x2,x3,x4] -> f x1 x2 x3 x4) [x1,x2,x3,x4]++-- | Variant of 'liftL' with a five arguments function.+liftL5 :: LaTeXC l => (LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX) -> l -> l -> l -> l -> l -> l+liftL5 f x1 x2 x3 x4 x5 = liftListL (\[x1,x2,x3,x4,x5] -> f x1 x2 x3 x4 x5) [x1,x2,x3,x4,x5]++-- | Variant of 'liftL' with a six arguments function.+liftL6 :: LaTeXC l => (LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX) -> l -> l -> l -> l -> l -> l -> l+liftL6 f x1 x2 x3 x4 x5 x6 = liftListL (\[x1,x2,x3,x4,x5,x6] -> f x1 x2 x3 x4 x5 x6) [x1,x2,x3,x4,x5,x6]++-- | Variant of 'liftL' with a seven arguments function.+liftL7 :: LaTeXC l => (LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX) -> l -> l -> l -> l -> l -> l -> l -> l+liftL7 f x1 x2 x3 x4 x5 x6 x7 = liftListL (\[x1,x2,x3,x4,x5,x6,x7] -> f x1 x2 x3 x4 x5 x6 x7) [x1,x2,x3,x4,x5,x6,x7]++-- | Variant of 'liftL' with an eight arguments function.+liftL8 :: LaTeXC l => (LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX) -> l -> l -> l -> l -> l -> l -> l -> l -> l+liftL8 f x1 x2 x3 x4 x5 x6 x7 x8 = liftListL (\[x1,x2,x3,x4,x5,x6,x7,x8] -> f x1 x2 x3 x4 x5 x6 x7 x8) [x1,x2,x3,x4,x5,x6,x7,x8]++-- | Variant of 'liftL' with a nine arguments function.+liftL9 :: LaTeXC l => (LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX) -> l -> l -> l -> l -> l -> l -> l -> l -> l -> l+liftL9 f x1 x2 x3 x4 x5 x6 x7 x8 x9 = liftListL (\[x1,x2,x3,x4,x5,x6,x7,x8,x9] -> f x1 x2 x3 x4 x5 x6 x7 x8 x9) [x1,x2,x3,x4,x5,x6,x7,x8,x9]+++-- | Map the given functor of LaTeX values to fixed TeX arguments.+fixArgs :: Functor f => f LaTeX -> f TeXArg+fixArgs = fmap FixArg++-- | Map the first 'n' elements as optional arguments, and the remaining ones as+-- fixed arguments. Most LaTeX commands are structured with first a sequence of+-- optional arguments, followed by a sequence of fixed arguments.+optFixArgs :: Int -> [LaTeX] -> [TeXArg]+optFixArgs _ [] = []+optFixArgs k xa@(x:xs) | k <= 0 = map FixArg xa+ | otherwise = OptArg x : optFixArgs (k-1) xs++-- | Call a LaTeX command where all the arguments in the list are fixed+-- arguments.+fixComm :: LaTeXC l => String -> [l] -> l+fixComm str = liftListL (TeXComm str . fixArgs)++-- | Call a LaTeX command with the first 'n' arguments as optional ones,+-- followed by fixed arguments. Most LaTeX commands are structured with first a+-- sequence of optional arguments, followed by a sequence of fixed arguments.+optFixComm :: LaTeXC l => String -> Int -> [l] -> l+optFixComm str k = liftListL (TeXComm str . optFixArgs k)++-- | Create a LaTeX environment where all the arguments in the list are fixed+-- arguments.+fixEnv :: LaTeXC l => String -> [l] -> l -> l+fixEnv str args inner = liftListL (\(inn:as) -> TeXEnv str (fixArgs as) inn) (inner:args)+ -- | A simple (without arguments) and handy command generator -- using the name of the command. --@@ -79,7 +132,7 @@ -- > comm1 str = liftL $ \l -> TeXComm str [FixArg l] -- comm1 :: LaTeXC l => String -> l -> l-comm1 str = liftL $ \l -> TeXComm str [FixArg l]+comm1 str l1 = fixComm str [l1] -- | A two parameter command generator using the name of the command. -- The parameters will be rendered as fixed arguments.@@ -87,16 +140,65 @@ -- > 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]+comm2 str l1 l2 = fixComm str [l1, 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 l3 -> TeXComm str [FixArg l1, FixArg l2, FixArg l3]+-- > comm3 str = liftL3 $ \l1 l2 l3 -> TeXComm str [FixArg l1, FixArg l2, FixArg l3] -- comm3 :: LaTeXC l => String -> l -> l -> l -> l-comm3 str = liftL3 $ \l1 l2 l3 -> TeXComm str [FixArg l1, FixArg l2, FixArg l3]+comm3 str l1 l2 l3 = fixComm str [l1, l2, l3] +-- | A four parameter command generator using the name of the command.+-- The parameters will be rendered as fixed arguments.+--+-- > comm4 str = liftL4 $ \l1 l2 l3 l4 -> TeXComm str [FixArg l1, FixArg l2, FixArg l3, FixArg l4]+--+comm4 :: LaTeXC l => String -> l -> l -> l -> l -> l+comm4 str l1 l2 l3 l4 = fixComm str [l1, l2, l3, l4]++-- | A five parameter command generator using the name of the command.+-- The parameters will be rendered as fixed arguments.+--+-- > comm5 str = liftL5 $ \l1 l2 l3 l4 l5 -> TeXComm str [FixArg l1, FixArg l2, FixArg l3, FixArg l4, FixArg l5]+--+comm5 :: LaTeXC l => String -> l -> l -> l -> l -> l -> l+comm5 str l1 l2 l3 l4 l5 = fixComm str [l1, l2, l3, l4, l5]++-- | A six parameter command generator using the name of the command.+-- The parameters will be rendered as fixed arguments.+--+-- > comm6 str = liftL6 $ \l1 l2 l3 l4 l5 l6 -> TeXComm str [FixArg l1, FixArg l2, FixArg l3, FixArg l4, FixArg l5, FixArg l6]+--+comm6 :: LaTeXC l => String -> l -> l -> l -> l -> l -> l -> l+comm6 str l1 l2 l3 l4 l5 l6 = fixComm str [l1, l2, l3, l4, l5, l6]++-- | A seven parameter command generator using the name of the command.+-- The parameters will be rendered as fixed arguments.+--+-- > comm7 str = liftL7 $ \l1 l2 l3 l4 l5 l6 l7 -> TeXComm str [FixArg l1, FixArg l2, FixArg l3, FixArg l4, FixArg l5, FixArg l6, FixArg l7]+--+comm7 :: LaTeXC l => String -> l -> l -> l -> l -> l -> l -> l -> l+comm7 str l1 l2 l3 l4 l5 l6 l7 = fixComm str [l1, l2, l3, l4, l5, l6, l7]++-- | An eight parameter command generator using the name of the command.+-- The parameters will be rendered as fixed arguments.+--+-- > comm8 str = liftL8 $ \l1 l2 l3 l4 l5 l6 l7 l8 -> TeXComm str [FixArg l1, FixArg l2, FixArg l3, FixArg l4, FixArg l5, FixArg l6, FixArg l7, FixArgs l8]+--+comm8 :: LaTeXC l => String -> l -> l -> l -> l -> l -> l -> l -> l -> l+comm8 str l1 l2 l3 l4 l5 l6 l7 l8 = fixComm str [l1, l2, l3, l4, l5, l6, l7, l8]++-- | A nine parameter command generator using the name of the command.+-- The parameters will be rendered as fixed arguments.+--+-- > comm9 str = liftL9 $ \l1 l2 l3 l4 l5 l6 l7 l8 l9 -> TeXComm str [FixArg l1, FixArg l2, FixArg l3, FixArg l4, FixArg l5, FixArg l6, FixArg l7, FixArgs l8, l9]+--+comm9 :: LaTeXC l => String -> l -> l -> l -> l -> l -> l -> l -> l -> l -> l+comm9 str l1 l2 l3 l4 l5 l6 l7 l8 l9 = fixComm str [l1, l2, l3, l4, l5, l6, l7, l8, l9]++ -- | Like 'comm0' but using 'TeXCommS', i.e. no \"{}\" will be inserted to protect -- the command's end. --@@ -105,9 +207,72 @@ commS :: LaTeXC l => String -> l commS = fromLaTeX . TeXCommS +-- | Define an environment, without any parameters that are passed to the+-- environment.+env0 :: LaTeXC l => String -> l -> l+env0 str = fixEnv str []++-- | Define an environment, with one fixed parameter that is passed to the+-- environment.+env1 :: LaTeXC l => String -> l -> l -> l+env1 str l1 = fixEnv str [l1]++-- | Define an environment, with two fixed parameters that is passed to the+-- environment.+env2 :: LaTeXC l => String -> l -> l -> l -> l+env2 str l1 l2 = fixEnv str [l1, l2]++-- | Define an environment, with three fixed parameters that is passed to the+-- environment.+env3 :: LaTeXC l => String -> l -> l -> l -> l -> l+env3 str l1 l2 l3 = fixEnv str [l1, l2, l3]++-- | Define an environment, with four fixed parameters that is passed to the+-- environment.+env4 :: LaTeXC l => String -> l -> l -> l -> l -> l -> l+env4 str l1 l2 l3 l4 = fixEnv str [l1, l2, l3, l4]++-- | Define an environment, with five fixed parameters that is passed to the+-- environment.+env5 :: LaTeXC l => String -> l -> l -> l -> l -> l -> l -> l+env5 str l1 l2 l3 l4 l5 = fixEnv str [l1, l2, l3, l4, l5]++-- | Define an environment, with six fixed parameters that is passed to the+-- environment.+env6 :: LaTeXC l => String -> l -> l -> l -> l -> l -> l -> l -> l+env6 str l1 l2 l3 l4 l5 l6 = fixEnv str [l1, l2, l3, l4, l5, l6]++-- | Define an environment, with seven fixed parameters that is passed to the+-- environment.+env7 :: LaTeXC l => String -> l -> l -> l -> l -> l -> l -> l -> l -> l+env7 str l1 l2 l3 l4 l5 l6 l7 = fixEnv str [l1, l2, l3, l4, l5, l6, l7]++-- | Define an environment, with eight fixed parameters that is passed to the+-- environment.+env8 :: LaTeXC l => String -> l -> l -> l -> l -> l -> l -> l -> l -> l -> l+env8 str l1 l2 l3 l4 l5 l6 l7 l8 = fixEnv str [l1, l2, l3, l4, l5, l6, l7, l8]++-- | Define an environment, with nine fixed parameters that is passed to the+-- environment.+env9 :: LaTeXC l => String -> l -> l -> l -> l -> l -> l -> l -> l -> l -> l -> l+env9 str l1 l2 l3 l4 l5 l6 l7 l8 l9 = fixEnv str [l1, l2, l3, l4, l5, l6, l7, l8, l9]+ -- | A lifted version of the 'TeXBraces' constructor. -- -- > braces = liftL TeXBraces -- braces :: LaTeXC l => l -> l braces = liftL TeXBraces++squareBraces :: LaTeXC l => l -> l+squareBraces = liftL $ \l -> TeXRaw "[" <> l <> TeXRaw "]" ++-- | Insert a raw piece of 'Text'.+-- This functions doesn't escape @LaTeX@ reserved characters,+-- it insert the text just as it is received.+--+-- /Warning:/ This function is /unsafe/, in the sense that it does+-- not check that the input text is a valid LaTeX /block/.+-- Make sure any braces, commands or environments are properly closed.+raw :: LaTeXC l => Text -> l+raw = fromLaTeX . TeXRaw
Text/LaTeX/Base/Commands.hs view
@@ -79,8 +79,11 @@ , part , chapter , section+ , section' , subsection+ , subsection' , subsubsection+ , subsubsection' , paragraph , subparagraph -- ** Logos & symbols@@ -103,6 +106,8 @@ , newline , lnbk , lnbk_+ , lnbkspc+ , lnbkspc_ , newpage , cleardoublepage , clearpage@@ -113,10 +118,16 @@ , hspace , hspace_ , vspace+ , vspace_+ , addvspace+ , quad, qquad , hfill , vfill+ , dotfill+ , hrulefill , stretch , smallskip+ , medskip , bigskip , baselineskip , indent@@ -169,6 +180,7 @@ , description , minipage , figure+ , table -- ** Page numbering , pagenumbering , arabic@@ -206,10 +218,16 @@ , raggedleft , raggedright , footnote+ , footnotemark+ , footnotetext+ , stepcounter+ , addtocounter , protect , hyphenation , hyp , qts+ -- * Maths commands+ , module Text.LaTeX.Base.Math -- * External files , input , include@@ -224,29 +242,13 @@ import Text.LaTeX.Base.Render import Text.LaTeX.Base.Types import Text.LaTeX.Base.Texy+import Text.LaTeX.Base.Math import Data.Version import Data.List (find, intercalate,intersperse) import Data.Matrix (Matrix,nrows,ncols,(!)) -- import Paths_HaTeX --- | Insert a raw piece of 'Text'.--- This functions doesn't escape @LaTeX@ reserved characters,--- it insert the text just as it is received.------ /Warning:/ This function is /unsafe/, in the sense that it does--- not check that the input text is a valid LaTeX /block/.--- Make sure any braces, commands or environments are properly closed.-raw :: LaTeXC l => Text -> l-raw = fromLaTeX . TeXRaw---- | Calling 'between' @c l1 l2@ puts @c@ between @l1@ and @l2@ and--- appends them.------ > between c l1 l2 = l1 <> c <> l2-between :: Monoid m => m -> m -> m -> m-between c l1 l2 = l1 <> c <> l2- -- | Create a comment. comment :: LaTeXC l => Text -> l comment = fromLaTeX . TeXComment@@ -266,6 +268,15 @@ (%:) :: LaTeXC l => l -> Text -> l (%:) l = (l <>) . comment +-- I am not sure this is a worth addition to the namespace. If added, maybe+-- it should be with a different name? Although any name that is slightly+-- longer will make 'eol' not cheaper to type than just @comment ""@, which+-- is already really cheap.++-- | Append a blank comment.+-- eol :: LaTeXC l => l+-- eol = comment ""+ -- | Generate the title. It normally contains the 'title' name -- of your document, the 'author'(s) and 'date'. maketitle :: LaTeXC l => l@@ -306,7 +317,7 @@ par :: LaTeXC l => l par = comm0 "par" --- | Start a new line.+-- | Start a new line. It can be used only in paragraph mode. newline :: LaTeXC l => l newline = comm0 "newline" @@ -321,14 +332,26 @@ section :: LaTeXC l => l -> l section = comm1 "section" +-- | Start a new unnumbered section with a given title.+section' :: LaTeXC l => l -> l+section' = comm1 "section*"+ -- | Start a new subsection. subsection :: LaTeXC l => l -> l subsection = comm1 "subsection" +-- | Start a new unnumbered subsection.+subsection' :: LaTeXC l => l -> l+subsection' = comm1 "subsection*"+ -- | Start a new sub/sub/section. subsubsection :: LaTeXC l => l -> l subsubsection = comm1 "subsubsection" +-- | Start a new unnumbered sub/sub/section.+subsubsection' :: LaTeXC l => l -> l+subsubsection' = comm1 "subsubsection*"+ -- | Start a paragraph. paragraph :: LaTeXC l => l -> l paragraph = comm1 "paragraph"@@ -391,14 +414,28 @@ minipage Nothing = liftL2 $ \ts -> TeXEnv "minipage" [ FixArg ts ] minipage (Just p) = liftL2 $ \ts -> TeXEnv "minipage" [ OptArg $ rendertex p , FixArg ts ] --- | Figure environment.+-- | Figure environment. Use this for floating "Text.LaTeX.Packages.Graphicx"+-- content out of the text block and giving it a 'caption'. The figure can be+-- referred to with 'ref' from elsewhere in the document. figure :: LaTeXC l =>- Maybe Pos -- ^ Optional position- -> l -- ^ Figure content+ Maybe Pos -- ^ Optional position.+ -> l -- ^ Figure content (should usually contain+ -- 'Text.LaTeX.Packages.Graphicx.includegraphics',+ -- 'caption' and 'label'). -> l figure Nothing = liftL $ TeXEnv "figure" [] figure (Just p) = liftL $ TeXEnv "figure" [ OptArg $ TeXRaw $ render p ] +-- | Table environment. Use this for floating a 'tabular' out of the text block and+-- giving it a 'caption'. The table can be referred to with 'ref'.+table :: LaTeXC l =>+ [Pos] -- ^ Position preferences. Leave empty to use default.+ -> l -- ^ Table content (assemble with 'tabular'/'matrixTabular',+ -- 'caption' and 'label').+ -> l+table [] = liftL $ TeXEnv "table" []+table ps = liftL $ TeXEnv "table" [ OptArg $ TeXRaw $ renderAppend ps ]+ -- | Abstract section. abstract :: LaTeXC l => l -> l abstract = liftL $ TeXEnv "abstract" []@@ -620,13 +657,34 @@ markright :: LaTeXC l => l -> l markright = liftL $ \l -> TeXComm "markright" [FixArg l] --- | Start a new line. In a 'tabular', it starts a new row, so use 'newline' instead.+-- | Start a new line. The exactly meaning depends on the context+-- where it is used. In normal running text when it forces a line+-- break it is essentially a shorthand for '\\newline' (does not end+-- horizontal mode or end the paragraph, it just inserts some glue and+-- penalties at that point into the horizontal material so that when+-- the paragraph does end a line break will occur at that point with+-- the short line padded with white space). In alignment environments+-- (like 'tabular'), it starts a new row, so use 'newline' instead to+-- start a new line. lnbk :: LaTeXC l => l lnbk = fromLaTeX $ TeXLineBreak Nothing False +-- | Like 'lnbk', 'lnbk_' introduces a line break, but preventing a+-- page break. lnbk_ :: LaTeXC l => l lnbk_ = fromLaTeX $ TeXLineBreak Nothing True +-- | Like 'lnbk', introduces a line break. But it has an argument that+-- specifies how much extra vertical space is to be inserted before+-- the next line. This can be a negative amount.+lnbkspc :: LaTeXC l => Measure -> l+lnbkspc extraSpace = fromLaTeX $ TeXLineBreak (Just extraSpace) False++-- | Like 'lnbkspc', 'lnbkspc_' introduces a line break with an extra+-- vertical space, but preventing a page break.+lnbkspc_ :: LaTeXC l => Measure -> l+lnbkspc_ extraSpace = fromLaTeX $ TeXLineBreak (Just extraSpace) True+ hyp :: LaTeXC l => l hyp = fromLaTeX $ TeXCommS "-" @@ -639,17 +697,27 @@ newpage :: LaTeXC l => l newpage = comm0 "newpage" +-- | Request to break the current line at the point of the command+-- stretching the line so that it extends to the right margin. The+-- number must be a number from 0 to 4. The higher the number, the+-- more insistent the request is (0 means it will be easily ignored+-- and 4 means do it anyway). When this line break option is used,+-- LaTeX will try to produce the best line breaks possible. linebreak :: LaTeXC l => l -> l linebreak = liftL $ \l -> TeXComm "linebreak" [OptArg l] +-- | Like 'linebreak', but prevents a like break instead of requesting+-- one. nolinebreak :: LaTeXC l => l -> l nolinebreak = liftL $ \l -> TeXComm "nolinebreak" [OptArg l] -nopagebreak :: LaTeXC l => l -> l-nopagebreak = liftL $ \l -> TeXComm "nopagebreak" [OptArg l]+pagebreak :: LaTeXC l => Maybe l -> l+pagebreak = maybe (comm0 "pagebreak")+ $ liftL $ \l -> TeXComm "pagebreak" [OptArg l] -pagebreak :: LaTeXC l => l -> l-pagebreak = liftL $ \l -> TeXComm "pagebreak" [OptArg l]+nopagebreak :: LaTeXC l => Maybe l -> l+nopagebreak = maybe (comm0 "nopagebreak")+ $ liftL $ \l -> TeXComm "nopagebreak" [OptArg l] hyphenation :: LaTeXC l => l -> l hyphenation = liftL $ \l -> TeXComm "hyphenation" [FixArg l]@@ -707,6 +775,23 @@ footnote :: LaTeXC l => l -> l footnote = liftL $ \l -> TeXComm "footnote" [FixArg l] +-- | Prints a foot note mark but without the actual footnote.+footnotemark :: LaTeXC l => l+footnotemark = comm0 "footnotemark"++-- | Prints the footnote corresponding to the previous footnotemark.+-- Useful when dealing with footnotes in tabular environment.+footnotetext :: LaTeXC l => l -> l+footnotetext = comm1 "footnotetext"++-- | Increases by 1 the value of given counter+stepcounter :: LaTeXC l => String -> l+stepcounter = comm1 "stepcounter" . fromString++-- | Increases by `n` the value of given counter `t`+addtocounter :: LaTeXC l => String -> Int -> l+addtocounter t n = comm2 "addtocounter" (fromString t) (fromString . show $ n)+ linespread :: LaTeXC l => Float -> l linespread x = fromLaTeX $ TeXComm "linespread" [FixArg $ rendertex x] @@ -725,12 +810,32 @@ hspace_ :: LaTeXC l => Measure -> l hspace_ m = fromLaTeX $ TeXComm "hspace*" [FixArg $ rendertex m] -stretch :: LaTeXC l => Int -> l+-- | Space equal to the current font size (= 18 mu). \(a\quad b\)+quad :: LaTeXC l => l+quad = comm0 "quad"++-- | Twice of @\quad@ (= 36 mu). \(a\qquad b\)+qquad :: LaTeXC l => l+qquad = comm0 "qquad"+++stretch :: LaTeXC l => Double -> l stretch n = fromLaTeX $ TeXComm "stretch" [FixArg $ rendertex n] +-- | Add vertical white space, except at the end of a page. vspace :: LaTeXC l => Measure -> l vspace m = fromLaTeX $ TeXComm "vspace" [FixArg $ rendertex m] +-- | Add vertical white space, even at the end of a page.+vspace_ :: LaTeXC l => Measure -> l+vspace_ m = fromLaTeX $ TeXComm "vspace*" [FixArg $ rendertex m]++-- | Add extra vertical white space. In a sequence of 'addvspace' the+-- length of the final white space is given by the maximum of the+-- individual lengths.+addvspace :: LaTeXC l => Measure -> l+addvspace m = fromLaTeX $ TeXComm "addvspace" [FixArg $ rendertex m]+ -- | Fill out all available horizontal space. hfill :: LaTeXC l => l hfill = comm0 "hfill"@@ -739,6 +844,14 @@ vfill :: LaTeXC l => l vfill = comm0 "vfill" +-- | Fill out all available horizontal space with dots.+dotfill :: LaTeXC l => l+dotfill = comm0 "dotfill"++-- | Fill out all available horizontal space with a line.+hrulefill :: LaTeXC l => l+hrulefill = comm0 "hrulefill"+ protect :: LaTeXC l => l -> l protect l = commS "protect" <> l @@ -866,6 +979,9 @@ smallskip :: LaTeXC l => l smallskip = comm0 "smallskip" +medskip :: LaTeXC l => l+medskip = comm0 "medskip"+ bigskip :: LaTeXC l => l bigskip = comm0 "bigskip" @@ -968,7 +1084,7 @@ -> Matrix a -- ^ Matrix of data -> l -- ^ Data organized in a tabular environment matrixTabular ts m =- let spec = VerticalLine : (intersperse VerticalLine $ replicate (ncols m) CenterColumn) ++ [VerticalLine]+ let spec = VerticalLine : intersperse VerticalLine (replicate (ncols m) CenterColumn) ++ [VerticalLine] in tabular Nothing spec $ mconcat [ hline , foldl1 (&) ts@@ -1049,11 +1165,11 @@ -- | Print the HaTeX logo, beside the complete version number. hatex_version :: LaTeXC l => l hatex_version = hatex- <> emph (textbf $ rendertex x)+ <> emph (textbf $ rendertex $ head v) <> hspace (Ex $ negate 0.3)- <> emph ("." <> fromString (intercalate "." $ fmap show xs))+ <> emph ("." <> fromString (intercalate "." $ fmap show $ tail v)) where- (x:xs) = versionBranch version+ v = versionBranch version caption :: LaTeXC l => l -> l caption = liftL $ \l -> TeXComm "caption" [FixArg l]
+ Text/LaTeX/Base/Math.hs view
@@ -0,0 +1,1081 @@+{-# LANGUAGE OverloadedStrings #-}+{-# OPTIONS_GHC -Wno-orphans #-}++-- | This module contains the maths-specific part of "Text.LaTeX.Base.Commands",+-- i.e. of the commands that are available in LaTeX out of the box without+-- any imports.+-- +-- Note however that most maths-related documents use the+-- <https://ctan.org/pkg/amsmath?lang=en amsmath package>, which not only adds+-- some more environments but also improves on rendering details such as symbol+-- spacing.+-- So even if you only need the vanilla-LaTeX commands that this module provides, +-- consider importing "Text.LaTeX.Packages.AMSMath" instead; it re-exports the+-- entire "Text.LaTeX.Base.Math" module.+module Text.LaTeX.Base.Math+ ( -- * Math Environments+ math, mathDisplay+ , equation , equation_+ -- ** Referencing+ , nonumber+ -- * Symbols and utilities+ + -- ** Brackets / delimiters+ , autoParens+ , autoSquareBrackets, autoBraces, autoAngleBrackets+ , autoBrackets+ + , langle , rangle+ , lfloor , rfloor+ , lceil , rceil + , dblPipe+ -- ** Superscript and subscript+ , (^:) , (!:), (!^)+ -- ** Function symbols+ -- | Some symbols are preceded with /t/ to be distinguished from+ -- predefined Haskell entities (like 'sin' and 'cos').+ , tsin , arcsin+ , tcos , arccos+ , ttan , arctan+ , cot , arccot+ , tsinh , tcosh , ttanh , coth+ , sec , csc+ , texp+ , tlog , ln+ , tsqrt+ -- ** Custom function symbols+ , operatorname+ -- ** Summation \/ integration \/ differentiation \/ relations+ , tsum , sumFromTo+ , prod , prodFromTo+ , coprod, coprodFromTo+ , integral , integralFromTo+ , partial, totald, partialOf, totaldOf+ , bigcup, bigcupFromTo+ , bigcap, bigcapFromTo + -- ** Operator symbols+ -- *** Arithmetic+ , (+-), (-+)+ , cdot , times , div_+ , frac+ , (*:) , star+ , circ , bullet+ -- *** Comparison+ , (=:) , (/=:)+ , (<:) , (<=:)+ , (>:) , (>=:)+ , ll , gg+ , equiv+ , propto+ , parallel+ , perp+ , approx+ , sim, simeq+ , cong+ -- *** Sets+ , in_ , ni , notin+ , subset , supset, subseteq, supseteq+ , cap , cup+ , setminus+ -- *** Misc operators+ , vee , wedge+ , oplus , ominus , otimes+ , oslash , odot , uplus+ -- *** Accents+ , hat, tilde, bar, vec, widehat, widetilde+ , dot+ , overline+ + -- ** Greek alphabet+ -- | Functions of greek alphabet symbols.+ --+ -- Uppercase versions are suffixed with @u@.+ -- Variants are prefixed with @var@.+ -- The function 'pi_' is ended by an underscore symbol to+ -- distinguish it from the 'pi' Prelude function.+ , alpha , beta , gamma+ , gammau , delta , deltau+ , epsilon , varepsilon , zeta+ , eta , theta , vartheta , thetau+ , iota , kappa , lambda+ , lambdau , mu , nu+ , xi , xiu , pi_+ , varpi , piu , rho+ , varrho , sigma , varsigma+ , sigmau , tau , upsilon+ , upsilonu , phi , varphi+ , phiu , chi , psi+ , psiu , omega , omegau+ -- ** Arrows+ , uparrow, downarrow+ , uparrow2, downarrow2+ , updownarrow, updownarrow2+ , leftarrow, rightarrow+ , leftrightarrow, leftrightarrow2+ , leftarrow2, rightarrow2+ , longleftarrow, longrightarrow+ , longleftarrow2, longrightarrow2+ , longleftrightarrow, longleftrightarrow2+ , nwarrow, nearrow+ , swarrow, searrow+ , to, mapsto, longmapsto+ , hookleftarrow, hookrightarrow+ , leftharpoonup, rightharpoonup+ , leftharpoondown, rightharpoondown+ -- ** Other symbols+ , pm , mp+ , implies+ , forall_ , exists+ , dagger, ddagger+ , infty+ , imath, jmath+ , bot+ -- * Fonts+ , mathdefault+ , mathbf+ , mathrm+ , mathcal+ , mathsf+ , mathtt+ , mathit+ ) where++import Text.LaTeX.Base.Syntax+import Text.LaTeX.Base.Class+import Text.LaTeX.Base.Writer+import Text.LaTeX.Base.Render++-- | Inline mathematical expressions.+math :: LaTeXC l => l -> l+math = liftL $ TeXMath Dollar++-- | Displayed mathematical expressions, i.e. in a seperate line / block.+mathDisplay :: LaTeXC l => l -> l+mathDisplay = liftL $ TeXMath Square++-------------------------------------------------------+------- Numeric instances for LaTeX and LaTeXT --------+-------------------------------------------------------++----------- LaTeX instances++-- | The 'signum' method uses a custom 'operatorname' and will not be automatically translated by babel.+-- This instance is defined in the "Text.LaTeX.Packages.AMSMath" module.+instance Num LaTeX where+ (+) = between "+"+ (-) = between "-"+ (*) = (<>)+ negate = (TeXEmpty -)+ fromInteger = rendertex+ abs = autoBrackets "|" "|"+ signum = (operatorname "sgn" <>)++-- | Division uses the LaTeX 'frac' command.+-- This instance is defined in the "Text.LaTeX.Packages.AMSMath" module.+instance Fractional LaTeX where+ (/) = frac+ fromRational = rendertex . (fromRational :: Rational -> Double)++-- | The 'asinh', 'atanh' and 'acosh' methods use custom 'operatorname's and will not be automatically translated by babel.+-- This instance is defined in the "Text.LaTeX.Packages.AMSMath" module.+instance Floating LaTeX where+ pi = pi_+ exp = (texp <>)+ sqrt = tsqrt Nothing+ log = (tlog <>)+ (**) = (^:)+ logBase b x = (commS "log" !: b) <> x+ sin = (tsin <>)+ tan = (ttan <>)+ cos = (tcos <>)+ asin = (arcsin <>)+ atan = (arctan <>)+ acos = (arccos <>)+ sinh = (tsinh <>)+ tanh = (ttanh <>)+ cosh = (tcosh <>)+ asinh = (operatorname "arsinh" <>)+ atanh = (operatorname "artanh" <>)+ acosh = (operatorname "arcosh" <>)++----------- LaTeXT instances++-- | Careful! Method 'signum' is undefined. Don't use it!+-- This instance is defined in the "Text.LaTeX.Packages.AMSMath" module.+instance (Monad m, a ~ ()) => Num (LaTeXT m a) where+ (+) = liftOp (+)+ (-) = liftOp (-)+ (*) = (>>)+ negate = liftFun negate+ fromInteger = fromLaTeX . fromInteger+ abs = liftFun abs+ signum = liftFun signum++-- | Division uses the LaTeX 'frac' command.+-- This instance is defined in the "Text.LaTeX.Packages.AMSMath" module.+instance (Monad m, a ~ ()) => Fractional (LaTeXT m a) where+ (/) = liftOp (/)+ fromRational = fromLaTeX . fromRational++-- | Undefined methods: 'asinh', 'atanh' and 'acosh'.+-- This instance is defined in the "Text.LaTeX.Packages.AMSMath" module.+instance (Monad m, a ~ ()) => Floating (LaTeXT m a) where+ pi = pi_+ exp = liftFun exp+ sqrt = liftFun sqrt+ log = liftFun log+ (**) = liftOp (**)+ logBase = liftOp logBase+ sin = liftFun sin+ tan = liftFun tan+ cos = liftFun cos+ asin = liftFun asin+ atan = liftFun atan+ acos = liftFun acos+ sinh = liftFun sinh+ tanh = liftFun tanh+ cosh = liftFun cosh+ asinh = liftFun asinh+ atanh = liftFun atanh+ acosh = liftFun acosh++-- | Prevent an equation from being numbered, where the environment would by default do that.+nonumber :: LaTeXC l => l+nonumber = comm0 "nonumber"++-- | A numbered mathematical equation (or otherwise math expression).+equation :: LaTeXC l => l -> l+equation = liftL $ TeXEnv "equation" []++-- | The unnumbered variant of 'equation'.+equation_ :: LaTeXC l => l -> l+equation_ = liftL $ TeXEnv "equation*" []++-------------------------------------+------- Symbols and utilities -------++-- | Surround a LaTeX math expression by parentheses whose height+-- automatically matches the expression's. Translates to @\\left(...\\right)@.+autoParens :: LaTeXC l => l -> l+autoParens x = commS "left(" <> x <> commS "right)"++-- | Like 'autoParens', but with square brackets. Equivalent to @'autoBrackets'\"[\"\"]\"@.+autoSquareBrackets :: LaTeXC l => l -> l+autoSquareBrackets x = commS "left[" <> x <> commS "right]"++-- | Like 'autoParens', but with curly brackets.+autoBraces :: LaTeXC l => l -> l+autoBraces x = commS "left"<>"{" <> x <> commS "right"<>"}"++-- | Like 'autoParens', but with angle brackets \(\langle\) ... \(\rangle\). Equivalent to @'autoBrackets' 'langle' 'rangle'@.+autoAngleBrackets :: LaTeXC l => l -> l+autoAngleBrackets x = commS "left"<>langle <> x <> commS "right"<>rangle++-- | Use custom LaTeX expressions as auto-scaled delimiters to surround math.+-- Suitable delimiters include \(|\ldots|\) (absolute value), \(\|\ldots\|\) (norm,+-- 'dblPipe'), \(\lfloor\ldots\rfloor\) (round-off Gauss brackets, 'lfloor' / 'rfloor') etc..+autoBrackets :: LaTeXC l => LaTeX -> LaTeX -> l -> l+autoBrackets lBrack rBrack x+ = commS "left" <> fromLaTeX lBrack <> x <> commS "right" <> fromLaTeX rBrack++-- | Left angle bracket, \(\langle\).+langle :: LaTeXC l => l+langle = comm0 "langle"++-- | Right angle bracket, \(\rangle\).+rangle :: LaTeXC l => l+rangle = comm0 "rangle"++-- | Left floor, \(\lfloor\).+lfloor :: LaTeXC l => l+lfloor = comm0 "lfloor"++-- | Right floor, \(\rfloor\).+rfloor :: LaTeXC l => l+rfloor = comm0 "rfloor"++-- | Left ceiling, \(\lceil\).+lceil :: LaTeXC l => l+lceil = comm0 "lceil"++-- | Right ceiling, \(\rceil\).+rceil :: LaTeXC l => l+rceil = comm0 "rceil"++-- | Double vertical line, used as delimiter for norms \(\| \ldots \|\).+dblPipe :: LaTeXC l => l+dblPipe = comm0 "|"++-- | Superscript.+(^:) :: LaTeXC l => l -> l -> l+x ^: y = braces x <> raw "^" <> braces y++-- | Subscript.+(!:) :: LaTeXC l => l -> l -> l+x !: y = braces x <> raw "_" <> braces y++-- | Sub- and superscript, both stacked.+(!^) :: LaTeXC l => l -> (l,l) -> l+x !^ (y,z) = braces x <> raw "_" <> braces y <> raw "^" <> braces z++---- Function symbols++-- | Sine function symbol.+tsin :: LaTeXC l => l+tsin = comm0 "sin"++-- | Arcsine function symbol.+arcsin :: LaTeXC l => l+arcsin = comm0 "arcsin"++-- | Cosine function symbol.+tcos :: LaTeXC l => l+tcos = comm0 "cos"++-- | Arccosine function symbol.+arccos :: LaTeXC l => l+arccos = comm0 "arccos"++-- | Tangent function symbol.+ttan :: LaTeXC l => l+ttan = comm0 "tan"++-- | Arctangent function symbol.+arctan :: LaTeXC l => l+arctan = comm0 "arctan"++-- | Cotangent function symbol.+cot :: LaTeXC l => l+cot = comm0 "cot"++-- | Arccotangent function symbol.+arccot :: LaTeXC l => l+arccot = comm0 "arccot"++-- | Hyperbolic sine function symbol.+tsinh :: LaTeXC l => l+tsinh = comm0 "sinh"++-- | Hyperbolic cosine function symbol.+tcosh :: LaTeXC l => l+tcosh = comm0 "cosh"++-- | Hyperbolic tangent function symbol.+ttanh :: LaTeXC l => l+ttanh = comm0 "tanh"++-- | Hyperbolic cotangent function symbol.+coth :: LaTeXC l => l+coth = comm0 "coth"++-- | Secant function symbol.+sec :: LaTeXC l => l+sec = comm0 "sec"++-- | Cosecant function symbol.+csc :: LaTeXC l => l+csc = comm0 "csc"++-- | Exponential function symbol.+texp :: LaTeXC l => l+texp = comm0 "exp"++-- | Logarithm function symbol.+tlog :: LaTeXC l => l+tlog = comm0 "log"++-- | Natural logarithm symbol.+ln :: LaTeXC l => l+ln = comm0 "ln"++-- | Root notation. Use @tsqrt (Just n) x@ for the @n@th root of @x@.+-- When 'Nothing' is supplied, the function will output a square root.+tsqrt :: LaTeXC l => Maybe l -> l -> l+tsqrt Nothing = liftL $ \x -> TeXComm "sqrt" [FixArg x]+tsqrt (Just n) = liftL2 (\m x -> TeXComm "sqrt" [OptArg m, FixArg x]) n++---- Custom Function Symbols+-- | Defines a new function symbol.+-- Note that function symbols defined in this way will not be automatically translated by babel.+operatorname :: LaTeXC l => l -> l+operatorname = comm1 "operatorname"++---- Sum/Integral symbols++-- | Sigma sumation symbol \(\sum\). Use 'sumFromTo' instead if you want to+-- specify the limits of the sum.+tsum :: LaTeXC l => l+tsum = comm0 "sum"++-- | Sigma sumation symbol with limits, like \[\sum_0^n\].+sumFromTo :: LaTeXC l+ => l -- ^ Expression below the sigma.+ -> l -- ^ Expression above the sigma.+ -> l+sumFromTo x y = commS "sum" <> raw"_" <> braces x <> raw"^" <> braces y++-- | Pi product symbol \(\prod\). Use 'prodFromTo' if you want to specify the+-- limits of the product.+prod :: LaTeXC l => l+prod = comm0 "prod"++-- | Pi product symbol with limits, like \[\prod_0^n\].+prodFromTo :: LaTeXC l+ => l -- ^ Expression below the pi.+ -> l -- ^ Expression above the pi.+ -> l+prodFromTo x y = commS "prod" <> raw"_" <> braces x <> raw"^" <> braces y++-- | Coproduct symbol \(\coprod\). Use 'coprodFromTo' if you want to specify the+-- limits of the coproduct.+coprod :: LaTeXC l => l+coprod = comm0 "coprod"++-- | Coproduct symbol with limits, like \[\coprod_0^n\].+coprodFromTo :: LaTeXC l+ => l -- ^ Expression below.+ -> l -- ^ Expression above.+ -> l+coprodFromTo x y = commS "coprod" <> raw"_" <> braces x <> raw"^" <> braces y++-- | Big union symbol \(\bigcup\). Use 'bigcupFromTo' if you want to specify the+-- limits of the union.+bigcup :: LaTeXC l => l+bigcup = comm0 "bigcup"++-- | Big union symbol with limits, like \[\bigcup_0^n\].+bigcupFromTo :: LaTeXC l+ => l -- ^ Expression below.+ -> l -- ^ Expression above.+ -> l+bigcupFromTo x y = commS "bigcup" <> raw"_" <> braces x <> raw"^" <> braces y++-- | Big intersection symbol \(\bigcap\). Use 'bigcapFromTo' if you want to specify the+-- limits of the intersection.+bigcap :: LaTeXC l => l+bigcap = comm0 "bigcap"++-- | Big intersection symbol with limits, like \[\bigcap_0^n\].+bigcapFromTo :: LaTeXC l+ => l -- ^ Expression below.+ -> l -- ^ Expression above.+ -> l+bigcapFromTo x y = commS "bigcap" <> raw"_" <> braces x <> raw"^" <> braces y+++-- | Integral symbol. Use 'integralFromTo' if you want to specify+-- the limits of the integral.+integral :: LaTeXC l => l+integral = comm0 "int"++-- | Integral symbol with limits of integration. \(\int\limits_{-1}^1\)+integralFromTo :: LaTeXC l+ => l -- ^ Lower limit of integration.+ -> l -- ^ Upper limit of integration.+ -> l+integralFromTo x y = commS "int" <> commS "limits" <> raw"_" <> braces x <> raw"^" <> braces y++-- | Partial-differentiation symbol \(\partial\)+partial :: LaTeXC l => l+partial = comm0 "partial"++-- | Total-differentiation (or integration-variable) symbol d (non-italic!)+-- To be used as @frac (totald) (totald<>"x")@ → \(\frac{\mathrm{d}}{\mathrm{d}x}\).+totald :: LaTeXC l => l+totald = mathrm "d"++-- | Partial-differentiation of variable, e.g.+-- @frac (partialOf h) (partialOf t)@ → \(\frac{\partial h}{\partial t}\).+partialOf :: LaTeXC l => l -> l+partialOf v = comm0 "partial" <> v++-- | Total-differentiation of variable, or integration over variable.+-- To be used as+-- +-- @+-- integralFromTo 0 infty $ totaldOf "x" <> "f(x)"+-- @+-- +-- \[\int\limits_0^\infty\mathrm{d}x f(x),\] or+-- @frac (totaldOf"f") (totaldOf"x")@ → \(\frac{\mathrm{d}f}{\mathrm{d}x}\).+totaldOf :: LaTeXC l => l -> l+totaldOf v = mathrm "d" <> v++---- Operator symbols++-- | Negative form of an operator.+notop :: LaTeXC l =>+ (l -> l -> l)+ -> l -> l -> l+notop op l1 l2 = (l1 <> commS "not") `op` l2++infixl 6 +-, -+++-- | Plus-or-minus operator \(\pm\). Also available as symbol 'pm'.+(+-) :: LaTeXC l => l -> l -> l+(+-) = between $ comm0 "pm"++-- | Minus-or-plus operator \(\mp\). Also available as symbol 'mp'.+(-+) :: LaTeXC l => l -> l -> l+(-+) = between $ comm0 "mp"++-- | Centered-dot operator \(\cdot\).+cdot :: LaTeXC l => l -> l -> l+cdot = between $ comm0 "cdot"++-- | \"x-cross\" multiplication operator \(\times\).+times :: LaTeXC l => l -> l -> l+times = between $ comm0 "times"++-- | Division operator \(\div\).+div_ :: LaTeXC l => l -> l -> l+div_ = between $ comm0 "div"++-- | Fraction operator, like @frac 1 2@ → \(\frac12\).+frac :: LaTeXC l => l -> l -> l+frac = liftL2 $ \p q -> TeXComm "frac" [FixArg p, FixArg q]++infixl 7 *:++-- | Asterisk operator \(\ast\).+--+-- > infixl 7 *:+(*:) :: LaTeXC l => l -> l -> l+(*:) = between $ comm0 "ast"++-- | Star operator \(\star\).+star :: LaTeXC l => l -> l -> l+star = between $ comm0 "star"++-- | Ring operator \(\circ\).+circ :: LaTeXC l => l -> l -> l+circ = between $ comm0 "circ"++-- | Bullet operator \(\bullet\).+bullet :: LaTeXC l => l -> l -> l+bullet = between $ comm0 "bullet"++infixr 4 =: , /=:++-- | Simple equals sign \(=\).+--+-- > infixr 4 =:+(=:) :: LaTeXC l => l -> l -> l+(=:) = between "="++-- | Not equal \(\neq\).+--+-- > infixr 4 /=:+(/=:) :: LaTeXC l => l -> l -> l+(/=:) = notop (=:)++-- | Greater \(>\).+(>:) :: LaTeXC l => l -> l -> l+(>:) = between ">"++-- | Greater or equal \(\geq\).+(>=:) :: LaTeXC l => l -> l -> l+(>=:) = between $ comm0 "geq"++-- | Lesser \(<\).+(<:) :: LaTeXC l => l -> l -> l+(<:) = between "<"++-- | Lesser or equal \(\leq\).+(<=:) :: LaTeXC l => l -> l -> l+(<=:) = between $ comm0 "leq"++-- | Much less \(\ll\).+ll :: LaTeXC l => l -> l -> l+ll = between $ comm0 "ll"++-- | Much greater \(\gg\).+gg :: LaTeXC l => l -> l -> l+gg = between $ comm0 "gg"++-- | Proportional-to \(\propto\).+propto :: LaTeXC l => l -> l -> l+propto = between $ comm0 "propto"++-- | Perpendicular \(\perp\). This is the infix version of 'bot'.+perp :: LaTeXC l => l -> l -> l+perp = between $ comm0 "perp"++-- | Approximate equality \(\approx\)+approx :: LaTeXC l => l -> l -> l+approx = between $ comm0 "approx"++-- | Generic equivalence relation \(\sim\).+sim :: LaTeXC l => l -> l -> l+sim = between $ comm0 "sim"++-- | Equivalence relation \(\simeq\). Sometimes used for approximate+-- equality or isomorphism.+simeq :: LaTeXC l => l -> l -> l+simeq = between $ comm0 "simeq"++-- | Congruence \(\cong\).+cong :: LaTeXC l => l -> l -> l+cong = between $ comm0 "cong"++-- | Parallel \(\parallel\).+parallel :: LaTeXC l => l -> l -> l+parallel = between $ comm0 "parallel"++-- | Identical \/ defined-as \/ equivalent \(\equiv\).+equiv :: LaTeXC l => l -> l -> l+equiv = between $ comm0 "equiv"++-- | Element-of \(\in\).+in_ :: LaTeXC l => l -> l -> l+in_ = between $ comm0 "in"++-- | Mirrored element-of \(\ni\).+ni :: LaTeXC l => l -> l -> l+ni = between $ comm0 "ni"++-- | Not element of \(\notin\).+notin :: LaTeXC l => l -> l -> l+notin = between $ comm0 "notin"++-- | Subset-of \(\subset\).+subset :: LaTeXC l => l -> l -> l+subset = between $ comm0 "subset"++-- | Subset-of-or-equal \(\subseteq\).+subseteq :: LaTeXC l => l -> l -> l+subseteq = between $ comm0 "subseteq"++-- | Superset-of \(\supset\).+supset :: LaTeXC l => l -> l -> l+supset = between $ comm0 "supset"++-- | Superset-of-or-equal \(\supseteq\).+supseteq :: LaTeXC l => l -> l -> l+supseteq = between $ comm0 "supseteq"++-- | Set intersection \(\cap\).+cap :: LaTeXC l => l -> l -> l+cap = between $ comm0 "cap"++-- | Set union \(\cup\).+cup :: LaTeXC l => l -> l -> l+cup = between $ comm0 "cup"++-- | Set minus \(\setminus\).+setminus :: LaTeXC l => l -> l -> l+setminus = between $ comm0 "setminus"++-- | Angle pointing downwards \(\vee\).+vee :: LaTeXC l => l -> l -> l+vee = between $ comm0 "vee"++-- | Angle pointing upwards \(\wedge\).+wedge :: LaTeXC l => l -> l -> l+wedge = between $ comm0 "wedge"++-- | Circled plus operator \(\oplus\).+oplus :: LaTeXC l => l -> l -> l+oplus = between $ comm0 "oplus"++-- | Circled minus operator \(\ominus\).+ominus :: LaTeXC l => l -> l -> l+ominus = between $ comm0 "ominus"++-- | Circled multiplication cross \(\otimes\).+otimes :: LaTeXC l => l -> l -> l+otimes = between $ comm0 "otimes"++-- | Circled slash \(\oslash\).+oslash :: LaTeXC l => l -> l -> l+oslash = between $ comm0 "oslash"++-- | Circled dot operator \(\odot\).+odot :: LaTeXC l => l -> l -> l+odot = between $ comm0 "odot"++-- | Disjoint sum operator \(\uplus\).+uplus :: LaTeXC l => l -> l -> l+uplus = between $ comm0 "uplus"++--- Accemts+{-+ , hat, tilde, bar, vec, widehat, widetilde+ , dot, ddot, dddot+ , overline, underline+ -}++-- | Add a hat accent above a symbol, like \(\hat{x}\).+hat :: LaTeXC l => l -> l+hat = comm1 "hat"++-- | Add a tilde accent above a symbol, like \(\tilde{y}\).+tilde :: LaTeXC l => l -> l+tilde = comm1 "tilde"++-- | Add a bar accent above a symbol, like \(\bar{z}\).+bar :: LaTeXC l => l -> l+bar = comm1 "bar"++-- | Add a vector arrow accent above a symbol, like \(\vec{v}\).+vec :: LaTeXC l => l -> l+vec = comm1 "vec"++-- | Add a wide hat accent above a symbol, like \(\widehat{w}\).+widehat :: LaTeXC l => l -> l+widehat = comm1 "widehat"++-- | Add a wide tilde accent above a symbol, like \(\widetilde{u}\).+widetilde :: LaTeXC l => l -> l+widetilde = comm1 "widetilde"++-- | Add a dot accent above a symbol, as used to denote a derivative,+-- like \(\dot{x}\).+dot :: LaTeXC l => l -> l+dot = comm1 "dot"++-- | Add a wide line accent above a symbol, like \(\overline{abc}\).+overline :: LaTeXC l => l -> l+overline = comm1 "overline"++---- Greek alphabet++-- | \(\alpha\) symbol.+alpha :: LaTeXC l => l+alpha = comm0 "alpha"++-- | \(\beta\) symbol.+beta :: LaTeXC l => l+beta = comm0 "beta"++-- | \(\gamma\) symbol.+gamma :: LaTeXC l => l+gamma = comm0 "gamma"++-- | \(\Gamma\) symbol.+gammau :: LaTeXC l => l+gammau = comm0 "Gamma"++-- | \(\delta\) symbol.+delta :: LaTeXC l => l+delta = comm0 "delta"++-- | \(\Delta\) symbol.+deltau :: LaTeXC l => l+deltau = comm0 "Delta"++-- | \(\epsilon\) symbol.+epsilon :: LaTeXC l => l+epsilon = comm0 "epsilon"++-- | \(\varepsilon\) symbol.+varepsilon :: LaTeXC l => l+varepsilon = comm0 "varepsilon"++-- | \(\zeta\) symbol.+zeta :: LaTeXC l => l+zeta = comm0 "zeta"++-- | \(\eta\) symbol.+eta :: LaTeXC l => l+eta = comm0 "eta"++-- | \(\theta\) symbol.+theta :: LaTeXC l => l+theta = comm0 "theta"++-- | \(\vartheta\) symbol.+vartheta :: LaTeXC l => l+vartheta = comm0 "vartheta"++-- | \(\Theta\) symbol.+thetau :: LaTeXC l => l+thetau = comm0 "Theta"++-- | \(\iota\) symbol.+iota :: LaTeXC l => l+iota = comm0 "iota"++-- | \(\kappa\) symbol.+kappa :: LaTeXC l => l+kappa = comm0 "kappa"++-- | \(\lambda\) symbol.+lambda :: LaTeXC l => l+lambda = comm0 "lambda"++-- | \(\Lambda\) symbol.+lambdau :: LaTeXC l => l+lambdau = comm0 "Lambda"++-- | \(\mu\) symbol.+mu :: LaTeXC l => l+mu = comm0 "mu"++-- | \(\nu\) symbol.+nu :: LaTeXC l => l+nu = comm0 "nu"++-- | \(\xi\) symbol.+xi :: LaTeXC l => l+xi = comm0 "xi"++-- | \(\Xi\) symbol.+xiu :: LaTeXC l => l+xiu = comm0 "Xi"++-- | \(\pi\) symbol.+pi_ :: LaTeXC l => l+pi_ = comm0 "pi"++-- | \(\varpi\) symbol.+varpi :: LaTeXC l => l+varpi = comm0 "varpi"++-- | \(\Pi\) symbol.+piu :: LaTeXC l => l+piu = comm0 "Pi"++-- | \(\rho\) symbol.+rho :: LaTeXC l => l+rho = comm0 "rho"++-- | \(\varrho\) symbol.+varrho :: LaTeXC l => l+varrho = comm0 "varrho"++-- | \(\sigma\) symbol.+sigma :: LaTeXC l => l+sigma = comm0 "sigma"++-- | \(\varsigma\) symbol.+varsigma :: LaTeXC l => l+varsigma = comm0 "varsigma"++-- | \(\Sigma\) symbol.+sigmau :: LaTeXC l => l+sigmau = comm0 "Sigma"++-- | \(\tau\) symbol.+tau :: LaTeXC l => l+tau = comm0 "tau"++-- | \(\upsilon\) symbol.+upsilon :: LaTeXC l => l+upsilon = comm0 "upsilon"++-- | \(\Upsilon\) symbol.+upsilonu :: LaTeXC l => l+upsilonu = comm0 "Upsilon"++-- | \(\phi\) symbol.+phi :: LaTeXC l => l+phi = comm0 "phi"++-- | \(\varphi\) symbol.+varphi :: LaTeXC l => l+varphi = comm0 "varphi"++-- | \(\Phi\) symbol.+phiu :: LaTeXC l => l+phiu = comm0 "Phi"++-- | \(\chi\) symbol.+chi :: LaTeXC l => l+chi = comm0 "chi"++-- | \(\psi\) symbol.+psi :: LaTeXC l => l+psi = comm0 "psi"++-- | \(\Psi\) symbol.+psiu :: LaTeXC l => l+psiu = comm0 "Psi"++-- | \(\omega\) symbol.+omega :: LaTeXC l => l+omega = comm0 "omega"++-- | \(\Omega\) symbol.+omegau :: LaTeXC l => l+omegau = comm0 "Omega"++---- Other symbols++-- | Plus-or-minus symbol \(\pm\). Also available as infix '+-'.+pm :: LaTeXC l => l+pm = comm0 "pm"++-- | Minus-or-plus symbol \(\mp\).+mp :: LaTeXC l => l+mp = comm0 "mp"++-- | A right-arrow, \(\to\).+to :: LaTeXC l => l+to = comm0 "to"++-- | A right-arrow for function definitions, \(\mapsto\).+mapsto :: LaTeXC l => l+mapsto = comm0 "mapsto"++-- | An implication arrow, \(\implies\).+implies :: LaTeXC l => l+implies = comm0 "implies"++-- | /For all/ symbol, \(\forall\).+forall_ :: LaTeXC l => l+forall_ = comm0 "forall"++-- | /Exists/ symbol, \(\exists\).+exists :: LaTeXC l => l+exists = comm0 "exists"++-- | Dagger symbol, \(\dagger\).+dagger :: LaTeXC l => l+dagger = comm0 "dagger"++-- | Double dagger symbol, \(\ddagger\).+ddagger :: LaTeXC l => l+ddagger = comm0 "ddagger"++-- | Infinity symbol, \(\infty\).+infty :: LaTeXC l => l+infty = comm0 "infty"++-- | Dotless letter i, \(\imath\).+imath :: LaTeXC l => l+imath = comm0 "imath"++-- | Dotless letter j, \(\jmath\).+jmath :: LaTeXC l => l+jmath = comm0 "jmath"++-- | Bottom symbol, \(\bot\). For the infix version see 'perp'.+bot :: LaTeXC l => l+bot = comm0 "bot"++++------------------------------------+------------- Arrows ---------------+-- | \(\uparrow\) symbol+uparrow :: LaTeXC l => l+uparrow = comm0 "uparrow"+-- | \(\downarrow\) symbol+downarrow :: LaTeXC l => l+downarrow = comm0 "downarrow"+-- | \(\Uparrow\) symbol+uparrow2 :: LaTeXC l => l+uparrow2 = comm0 "Uparrow"+-- | \(\Downarrow\) symbol+downarrow2 :: LaTeXC l => l+downarrow2 = comm0 "Downarrow"+-- | \(\updownarrow\) symbol+updownarrow :: LaTeXC l => l+updownarrow = comm0 "updownarrow"+-- | \(\Updownarrow\) symbol+updownarrow2 :: LaTeXC l => l+updownarrow2 = comm0 "Updownarrow"+-- | \(\leftarrow\) symbol+leftarrow :: LaTeXC l => l+leftarrow = comm0 "leftarrow"+-- | \(\rightarrow\) symbol+rightarrow :: LaTeXC l => l+rightarrow = comm0 "rightarrow"+-- | \(\leftrightarrow\) symbol+leftrightarrow :: LaTeXC l => l+leftrightarrow = comm0 "leftrightarrow"+-- | \(\Leftrightarrow\) symbol+leftrightarrow2 :: LaTeXC l => l+leftrightarrow2 = comm0 "Leftrightarrow"+-- | \(\Leftarrow\) symbol+leftarrow2 :: LaTeXC l => l+leftarrow2 = comm0 "Leftarrow"+-- | \(\Rightarrow\) symbol+rightarrow2 :: LaTeXC l => l+rightarrow2 = comm0 "Rightarrow"+-- | \(\longleftarrow\) symbol+longleftarrow :: LaTeXC l => l+longleftarrow = comm0 "longleftarrow"+-- | \(\longrightarrow\) symbol+longrightarrow :: LaTeXC l => l+longrightarrow = comm0 "longrightarrow"+-- | \(\Longleftarrow\) symbol+longleftarrow2 :: LaTeXC l => l+longleftarrow2 = comm0 "Longleftarrow"+-- | \(\Longrightarrow\) symbol+longrightarrow2 :: LaTeXC l => l+longrightarrow2 = comm0 "Longrightarrow"+-- | \(\longleftrightarrow\) symbol+longleftrightarrow :: LaTeXC l => l+longleftrightarrow = comm0 "longleftrightarrow"+-- | \(\Longleftrightarrow\) symbol+longleftrightarrow2 :: LaTeXC l => l+longleftrightarrow2 = comm0 "Longleftrightarrow"+-- | \(\nwarrow\) symbol+nwarrow :: LaTeXC l => l+nwarrow = comm0 "nwarrow"+-- | \(\nearrow\) symbol+nearrow :: LaTeXC l => l+nearrow = comm0 "nearrow"+-- | \(\swarrow\) symbol+swarrow :: LaTeXC l => l+swarrow = comm0 "swarrow"+-- | \(\searrow\) symbol+searrow :: LaTeXC l => l+searrow = comm0 "searrow"+-- | \(\longmapsto\) symbol+longmapsto :: LaTeXC l => l+longmapsto = comm0 "longmapsto"+-- | \(\hookleftarrow\) symbol+hookleftarrow :: LaTeXC l => l+hookleftarrow = comm0 "hookleftarrow"+-- | \(\hookrightarrow\) symbol+hookrightarrow :: LaTeXC l => l+hookrightarrow = comm0 "hookrightarrow"+-- | \(\leftharpoonup\) symbol+leftharpoonup :: LaTeXC l => l+leftharpoonup = comm0 "leftharpoonup"+-- | \(\rightharpoonup\) symbol+rightharpoonup :: LaTeXC l => l+rightharpoonup = comm0 "rightharpoonup"+-- | \(\leftharpoondown\) symbol+leftharpoondown :: LaTeXC l => l+leftharpoondown = comm0 "leftharpoondown"+-- | \(\rightharpoondown\) symbol+rightharpoondown :: LaTeXC l => l+rightharpoondown = comm0 "rightharpoondown"++-------------------------------------+------------ Math Fonts -------------++-- | Default math symbol font.+mathdefault :: LaTeXC l => l -> l+mathdefault = comm1 "mathdefault"++-- | Bold face, like \(\mathbf{Abc}\).+mathbf :: LaTeXC l => l -> l+mathbf = comm1 "mathbf"++-- | Roman, i.e. not-italic math, \(\mathrm{deF}\)+mathrm :: LaTeXC l => l -> l+mathrm = comm1 "mathrm"++-- | Calligraphic math symbols. Only works (reliably) with uppercase letters, like \(\mathcal{LMN}\).+mathcal :: LaTeXC l => l -> l+mathcal = comm1 "mathcal"++-- | Sans-serif math, \(\mathsf{xyz}\).+mathsf :: LaTeXC l => l -> l+mathsf = comm1 "mathsf"++-- | Typewriter font, \(\mathtt{ijk}\).+mathtt :: LaTeXC l => l -> l+mathtt = comm1 "mathtt"++-- | Italic math. Uses the same glyphs as 'mathdefault', but with spacings+-- intended for multi-character symbols rather than juxtaposition of single-character symbols.+mathit :: LaTeXC l => l -> l+mathit = comm1 "mathit"++
Text/LaTeX/Base/Parser.hs view
@@ -1,5 +1,5 @@ -{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE OverloadedStrings, CPP #-} -- | The /LaTeX/ parser. -- @@ -51,8 +51,12 @@ import Text.Parsec hiding ((<|>),many) import Text.Parsec.Error import Data.Char (toLower,digitToInt)+import Data.Functor(($>))+#if !MIN_VERSION_base(4,11,0) import Data.Monoid+#endif import Data.Maybe (fromMaybe)+import Data.Set(Set, fromList, member) import qualified Data.Text as T import Control.Applicative@@ -66,7 +70,7 @@ ------------------------------------------------------------------------ -- | Configuration for the LaTeX parser.-data ParserConf = ParserConf+newtype ParserConf = ParserConf { -- | This is the list of names of the environments such that -- their content will be parsed verbatim. verbatimEnvironments :: [String]@@ -123,19 +127,20 @@ ] -- Note: text stops on ']'; if the other parsers fail on the rest -- text2 handles it, starting with ']' - + ------------------------------------------------------------------------ -- Text ------------------------------------------------------------------------+nottext :: Set Char+nottext = fromList "$%\\{]}"+ text :: Parser LaTeX text = do mbC <- peekChar- let nottext :: [Char]- nottext = "$%\\{]}" case mbC of Nothing -> fail "text: Empty input."- Just c | c `elem` nottext -> fail "not text"- | otherwise -> TeXRaw <$> takeTill (`elem` nottext)+ Just c | c `member` nottext -> fail "not text"+ | otherwise -> TeXRaw <$> takeTill (`member` nottext) ------------------------------------------------------------------------ -- Text without stopping on ']'@@ -246,6 +251,9 @@ '\\' -> lbreak _ -> commS [x] +isSpecial :: Char -> Bool+isSpecial = (`elem` specials)+ ------------------------------------------------------------------------ -- Line break ------------------------------------------------------------------------@@ -331,24 +339,20 @@ -- Helpers ------------------------------------------------------------------------ -isSpecial :: Char -> Bool-isSpecial = (`elem` specials)- endCmd :: Char -> Bool endCmd c = notLowercaseAlph && notUppercaseAlph where c' = fromEnum c notLowercaseAlph = c' < fromEnum 'a' || c' > fromEnum 'z' notUppercaseAlph = c' < fromEnum 'A' || c' > fromEnum 'Z' - specials :: String specials = "'(),.-\"!^$&#{}%~|/:;=[]\\` " peekChar :: Parser (Maybe Char)-peekChar = Just <$> (try $ lookAhead anyChar) <|> pure Nothing+peekChar = Just <$> try (lookAhead anyChar) <|> pure Nothing atEnd :: Parser Bool-atEnd = (eof *> pure True) <|> pure False+atEnd = (eof $> True) <|> pure False takeTill :: (Char -> Bool) -> Parser Text takeTill p = T.pack <$> many (satisfy (not . p))
Text/LaTeX/Base/Pretty.hs view
@@ -13,26 +13,32 @@ import Text.LaTeX.Base.Syntax import Text.LaTeX.Base.Render-import Text.PrettyPrint.Free- ( Doc, text, char+import Prettyprinter+ ( Doc, pretty , backslash, line, softline, hardline , braces, brackets , indent, align, vsep , list, encloseSep- , renderSmart, displayS+ , LayoutOptions (..)+ , PageWidth (..)+ , layoutSmart )+import Prettyprinter.Render.String (renderString) import Data.Text (unpack,lines) #if !MIN_VERSION_base(4,8,0) import Data.Monoid (mconcat,mempty) #endif +text :: Text -> Doc ann+text = pretty+ -- | This function transforms a value of type 'LaTeX' to a 'Doc'. -- You can then choose how to print this 'Doc' value using -- the function from the "Text.PrettyPrint.Free" module. docLaTeX :: LaTeX -> Doc ()-docLaTeX (TeXRaw t) = text $ unpack t-docLaTeX (TeXComm n as) = backslash <> text n <> align (mconcat (fmap docTeXArg as)) <> softline-docLaTeX (TeXCommS n) = backslash <> text n <> softline+docLaTeX (TeXRaw t) = pretty $ unpack t+docLaTeX (TeXComm n as) = backslash <> pretty n <> align (mconcat (fmap docTeXArg as)) <> softline+docLaTeX (TeXCommS n) = backslash <> pretty n <> softline docLaTeX (TeXEnv n as b) = let a = FixArg $ fromString n in mconcat@@ -51,13 +57,13 @@ 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 "\\\\" <> maybe mempty (brackets . pretty . unpack . render) m <> ( if b then text "*" else mempty ) docLaTeX (TeXBraces b) = braces $ docLaTeX b docLaTeX (TeXComment t) = let ls = Data.Text.lines t in if null ls- then char '%' <> hardline- else (align $ vsep $ fmap (text . ("% "++) . unpack) ls) <> hardline+ then pretty '%' <> hardline+ else align (vsep $ fmap (pretty . ("% "++) . unpack) ls) <> hardline docLaTeX (TeXSeq l1 l2) = docLaTeX l1 <> docLaTeX l2 docLaTeX TeXEmpty = mempty @@ -68,9 +74,9 @@ if null ls then mempty else list $ fmap docLaTeX ls docTeXArg (SymArg l) = docTeXArg $ MSymArg [l]-docTeXArg (MSymArg ls) = encloseSep (char '<') (char '>') (char ',') $ fmap docLaTeX ls+docTeXArg (MSymArg ls) = encloseSep (pretty '<') (pretty '>') (pretty ',') $ fmap docLaTeX ls docTeXArg (ParArg l) = docTeXArg $ MParArg [l]-docTeXArg (MParArg ls) = encloseSep (char '(') (char ')') (char ',') $ fmap docLaTeX ls+docTeXArg (MParArg ls) = encloseSep (pretty '(') (pretty ')') (pretty ',') $ fmap docLaTeX ls -- | Pretty print a 'LaTeX' value. It produces a more human-friendly output than 'render'. --@@ -81,4 +87,7 @@ -- You should use 'renderFile' unless you really need to read the LaTeX file. -- prettyLaTeX :: LaTeX -> String-prettyLaTeX l = displayS (renderSmart 60 (docLaTeX l)) []+prettyLaTeX = renderString . layoutSmart layout . docLaTeX++layout :: LayoutOptions+layout = LayoutOptions $ AvailablePerLine 60 1
Text/LaTeX/Base/Render.hs view
@@ -22,15 +22,20 @@ , showFloat ) where -import Data.Text (Text,lines,unlines) import Text.LaTeX.Base.Syntax import Text.LaTeX.Base.Class import Data.String-import Data.Text.Encoding import Data.List (intersperse) import qualified Data.ByteString as B import Data.Word (Word8) import Numeric (showFFloat)+import Data.Text (Text,lines,unlines,dropWhileEnd)+import Data.Text.Encoding+import Data.Text.Lazy (toStrict)+import Data.Text.Lazy.Builder (Builder)+import qualified Data.Text.Lazy.Builder as Builder+import qualified Data.Text.Lazy.Builder.Int as Builder+import qualified Data.Text.Lazy.Builder.RealFloat as Builder -- | Class of values that can be transformed to 'Text'. -- You mainly will use this to obtain the 'Text' output@@ -47,9 +52,14 @@ -- class Show a => Render a where render :: a -> Text+ renderBuilder :: a -> Builder -- render = fromString . show+ renderBuilder = Builder.fromText . render +renderDefault :: Render a => a -> Text+renderDefault = toStrict . Builder.toLazyText . renderBuilder+ -- | This instance escapes LaTeX reserved characters. instance Render Text where render = protectText@@ -58,16 +68,25 @@ renderAppend :: Render a => [a] -> Text renderAppend = mconcat . fmap render +renderAppendBuilder :: Render a => [a] -> Builder+renderAppendBuilder = foldMap renderBuilder+ -- | Render every element of a list and append results, -- separated by the given 'Char'. renderChars :: Render a => Char -> [a] -> Text renderChars c = mconcat . intersperse (fromString [c]) . fmap render +renderCharsBuilder :: Render a => Char -> [a] -> Builder+renderCharsBuilder c = mconcat . intersperse (Builder.singleton c) . fmap renderBuilder+ -- | Render every element of a list and append results, -- separated by commas. renderCommas :: Render a => [a] -> Text renderCommas = renderChars ',' +renderCommasBuilder :: Render a => [a] -> Builder+renderCommasBuilder = renderCharsBuilder ','+ -- | Use this function to render a 'LaTeX' (or another -- one in the 'Render' class) value directly -- in a file.@@ -104,53 +123,61 @@ instance Render LaTeX where - render (TeXRaw t) = t+ renderBuilder (TeXRaw t) = Builder.fromText t - render (TeXComm name []) = "\\" <> fromString name <> "{}"- render (TeXComm name args) =+ renderBuilder (TeXComm name []) = "\\" <> fromString name <> "{}"+ renderBuilder (TeXComm name args) = "\\" <> fromString name- <> renderAppend args- render (TeXCommS name) = "\\" <> fromString name+ <> renderAppendBuilder args+ renderBuilder (TeXCommS name) = "\\" <> fromString name - render (TeXEnv name args c) =+ renderBuilder (TeXEnv name args c) = "\\begin{" <> fromString name <> "}"- <> renderAppend args- <> render c+ <> renderAppendBuilder args+ <> renderBuilder c <> "\\end{" <> fromString name <> "}" - render (TeXMath Dollar l) = "$" <> render l <> "$"- render (TeXMath DoubleDollar l) = "$$" <> render l <> "$$"- render (TeXMath Square l) = "\\[" <> render l <> "\\]"- render (TeXMath Parentheses l) = "\\(" <> render l <> "\\)"-- render (TeXLineBreak m b) = "\\\\" <> maybe mempty (\x -> "[" <> render x <> "]") m <> ( if b then "*" else mempty )+ renderBuilder (TeXMath Dollar l) = "$" <> renderBuilder l <> "$"+ renderBuilder (TeXMath DoubleDollar l) = "$$" <> renderBuilder l <> "$$"+ renderBuilder (TeXMath Square l) = "\\[" <> renderBuilder l <> "\\]"+ renderBuilder (TeXMath Parentheses l) = "\\(" <> renderBuilder l <> "\\)" - render (TeXBraces l) = "{" <> render l <> "}"+ -- It is not safe to simply say \\, if the text following it starts+ -- with a left square bracket or a star you will get an error or+ -- something unexpected. I think this is why you see "\\%\n" so+ -- often. Here I supply a zero "extra vertical space" argument.+ renderBuilder (TeXLineBreak m b) =+ "\\\\" <> (if b then "*" else mempty) <>+ "[" <> maybe (renderBuilder (Em 0.0)) renderBuilder m <> "]"+ renderBuilder (TeXBraces l) = "{" <> renderBuilder l <> "}" - render (TeXComment c) =+ renderBuilder (TeXComment c) = let xs = Data.Text.lines c in if null xs then "%\n"- else Data.Text.unlines $ fmap ("%" <>) xs+ else Builder.fromText $ Data.Text.unlines $ fmap ("%" <>) xs - render (TeXSeq l1 l2) = render l1 <> render l2- render TeXEmpty = mempty+ renderBuilder (TeXSeq l1 l2) = renderBuilder l1 <> renderBuilder l2+ renderBuilder TeXEmpty = mempty + render = renderDefault+ instance Render TeXArg where- render (FixArg l) = "{" <> render l <> "}"- render (OptArg l) = "[" <> render l <> "]"- render (MOptArg []) = mempty- render (MOptArg ls) = "[" <> renderCommas ls <> "]"- render (SymArg l) = "<" <> render l <> ">"- render (MSymArg []) = mempty- render (MSymArg ls) = "<" <> renderCommas ls <> ">"- render (ParArg l) = "(" <> render l <> ")"- render (MParArg []) = mempty- render (MParArg ls) = "(" <> renderCommas ls <> ")"+ renderBuilder (FixArg l) = "{" <> renderBuilder l <> "}"+ renderBuilder (OptArg l) = "[" <> renderBuilder l <> "]"+ renderBuilder (MOptArg []) = mempty+ renderBuilder (MOptArg ls) = "[" <> renderCommasBuilder ls <> "]"+ renderBuilder (SymArg l) = "<" <> renderBuilder l <> ">"+ renderBuilder (MSymArg []) = mempty+ renderBuilder (MSymArg ls) = "<" <> renderCommasBuilder ls <> ">"+ renderBuilder (ParArg l) = "(" <> renderBuilder l <> ")"+ renderBuilder (MParArg []) = mempty+ renderBuilder (MParArg ls) = "(" <> renderCommasBuilder ls <> ")"+ render = renderDefault -- Other instances @@ -159,12 +186,23 @@ showFloat x = showFFloat (Just 5) x [] instance Render Int where+ renderBuilder = Builder.decimal+ render = renderDefault+ instance Render Integer where+ renderBuilder = Builder.decimal+ render = renderDefault+ instance Render Float where- render = fromString . showFloat+ renderBuilder = Builder.formatRealFloat Builder.Fixed (Just 5)+ render = dropWhileEnd (== '.') . dropWhileEnd (== '0') . renderDefault instance Render Double where- render = fromString . showFloat+ renderBuilder = Builder.formatRealFloat Builder.Fixed (Just 5)+ render = dropWhileEnd (== '.') . dropWhileEnd (== '0') . renderDefault+ instance Render Word8 where+ renderBuilder = Builder.decimal+ render = renderDefault -- | 'Render' instance for 'Bool'. It satisfies @render True = "true"@ and @render False = "false"@. instance Render Bool where@@ -172,4 +210,5 @@ render _ = "false" instance Render a => Render [a] where- render xs = "[" <> renderCommas xs <> "]"+ renderBuilder xs = "[" <> renderCommasBuilder xs <> "]"+ render = renderDefault
Text/LaTeX/Base/Syntax.hs view
@@ -1,5 +1,5 @@ -{-# LANGUAGE CPP, DeriveDataTypeable, DeriveGeneric #-}+{-# LANGUAGE DeriveDataTypeable, DeriveGeneric #-} -- | LaTeX syntax description in the definition of the 'LaTeX' datatype. -- If you want to add new commands or environments not defined in@@ -10,7 +10,7 @@ , MathType (..) , LaTeX (..) , TeXArg (..)- , (<>)+ , (<>), between -- * Escaping reserved characters , protectString , protectText@@ -28,12 +28,8 @@ import Data.Text (Text,pack) import qualified Data.Text-import Data.Monoid-#if MIN_VERSION_base(4,9,0) import qualified Data.Semigroup as Semigroup-#endif import Data.String-import Control.Applicative import Control.Monad (replicateM) import Data.Functor.Identity (runIdentity) import Data.Data (Data)@@ -41,6 +37,7 @@ import Test.QuickCheck import Data.Hashable import GHC.Generics (Generic)+import Control.Applicative (liftA2) -- | Measure units defined in LaTeX. Use 'CustomMeasure' to use commands like 'textwidth'. -- For instance:@@ -99,29 +96,24 @@ -- Monoid instance for 'LaTeX'. --- | Method 'mappend' is strict in both arguments (except in the case when the first argument is 'TeXEmpty'). instance Monoid LaTeX where- mempty = TeXEmpty- mappend TeXEmpty x = x- mappend x TeXEmpty = x- -- This equation is to make 'mappend' associative.- mappend (TeXSeq x y) z = TeXSeq x $ mappend y z- --- mappend x y = TeXSeq x y---- Since GHC starting from 7.4 provides (<>) as synonym to 'mappend' (see "Data.Monoid"),--- we avoid an overlapping definition with a CPP conditional.-#if __GLASGOW_HASKELL__ < 704--- | Alias for 'mappend'.-(<>) :: Monoid a => a -> a -> a-(<>) = mappend-#endif+ mempty = TeXEmpty -#if MIN_VERSION_base(4,9,0)+-- | Appending is strict in both arguments (except when the first argument is 'TeXEmpty'). instance Semigroup.Semigroup LaTeX where- (<>) = mappend-#endif+ TeXEmpty <> x = x+ x <> TeXEmpty = x+ -- This equation is to make 'mappend' associative.+ TeXSeq x y <> z = TeXSeq x $ y <> z+ x <> y = TeXSeq x y +-- | Calling 'between' @c l1 l2@ puts @c@ between @l1@ and @l2@ and+-- appends them.+--+-- > between c l1 l2 = l1 <> c <> l2+between :: Monoid m => m -> m -> m -> m+between c l1 l2 = l1 <> c <> l2+ -- | Method 'fromString' escapes LaTeX reserved characters using 'protectString'. instance IsString LaTeX where fromString = TeXRaw . fromString . protectString@@ -175,7 +167,7 @@ matchCommand f (TeXComm str as) = let xs = concatMap (matchCommandArg f) as in if f str then (str,as) : xs else xs-matchCommand f (TeXCommS str) = if f str then [(str,[])] else []+matchCommand f (TeXCommS str) = [(str, []) | f str] matchCommand f (TeXEnv _ as l) = let xs = concatMap (matchCommandArg f) as in xs ++ matchCommand f l@@ -278,7 +270,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@@ -311,7 +303,7 @@ -- not getting too large. n <- choose (0,16 :: Int) case n of- 0 -> if inDollar then arbitraryLaTeX True else pure TeXEmpty+ 0 -> if inDollar then arbitraryLaTeX inDollar else pure TeXEmpty 1 -> do m <- choose (0,5) TeXComm <$> arbitraryName <*> vectorOf m arbitrary 2 -> TeXCommS <$> arbitraryName@@ -319,13 +311,13 @@ 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)+ else 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+ 6 -> TeXBraces <$> arbitraryLaTeX inDollar 7 -> TeXComment <$> arbitraryRaw- 8 -> TeXSeq <$> (if inDollar then arbitraryLaTeX True else arbitrary) <*> arbitrary+ 8 -> TeXSeq <$> arbitraryLaTeX inDollar <*> arbitraryLaTeX inDollar _ -> TeXRaw <$> arbitraryRaw instance Arbitrary TeXArg where
Text/LaTeX/Base/Types.hs view
@@ -37,18 +37,20 @@ labelName (Label str) = str instance Render Label where- render (Label str) = fromString str+ render (Label str) = fromString str instance IsString Label where- fromString = createLabel+ fromString = createLabel --- | Vertical position.-data Pos = Bottom | Center | Top deriving Show+-- | Vertical position. 'Here' and 'ForcePos' are used with @table@ environments.+data Pos = Bottom | Center | Top | Here | ForcePos deriving Show instance Render Pos where- render Bottom = "b"- render Center = "c"- render Top = "t"+ render Bottom = "b"+ render Center = "c"+ render Top = "t"+ render Here = "h"+ render ForcePos = "!" -- | Horizontal position. data HPos = HLeft | HCenter | HRight deriving Show
Text/LaTeX/Base/Warnings.hs view
@@ -27,6 +27,7 @@ #if !MIN_VERSION_base(4,8,0) import Data.Monoid #endif+import qualified Data.Semigroup as SG -- | List of possible warnings. data Warning =@@ -47,9 +48,11 @@ checkFromFunction :: (LaTeX -> [Warning]) -> TeXCheck checkFromFunction = TC +instance SG.Semigroup TeXCheck where+ TC tc1 <> TC tc2 = TC $ uncurry (<>) . (tc1 &&& tc2)+ instance Monoid TeXCheck where mempty = TC $ const []- mappend (TC tc1) (TC tc2) = TC $ uncurry mappend . (tc1 &&& tc2) -- | Check with 'checkLabels', 'checkClass' and 'checkDoc'. checkAll :: TeXCheck
Text/LaTeX/Base/Writer.hs view
@@ -1,5 +1,4 @@--{-# LANGUAGE TypeFamilies, CPP #-}+{-# LANGUAGE TypeFamilies #-} -- | The writer monad applied to 'LaTeX' values. Useful to compose 'LaTeX' values -- using the @do@ notation:@@ -55,13 +54,10 @@ ) where -- base-import Control.Monad (liftM, liftM2) import Control.Arrow+import Control.Applicative (liftA2) import Data.String-#if !MIN_VERSION_base(4,8,0)-import Data.Monoid-import Control.Applicative-#endif+import qualified Data.Semigroup as Semigroup -- transformers import Control.Monad.Trans.Writer import Control.Monad.IO.Class@@ -74,15 +70,14 @@ import Text.LaTeX.Base.Warnings (Warning,checkAll,check) -- | 'WriterT' monad transformer applied to 'LaTeX' values.-newtype LaTeXT m a =- LaTeXT { unwrapLaTeXT :: WriterT LaTeX m a }+newtype LaTeXT m a = LaTeXT { unwrapLaTeXT :: WriterT LaTeX m a } instance Functor f => Functor (LaTeXT f) where- fmap f = LaTeXT . fmap f . unwrapLaTeXT+ fmap f = LaTeXT . fmap f . unwrapLaTeXT instance Applicative f => Applicative (LaTeXT f) where- pure = LaTeXT . pure- (LaTeXT f) <*> (LaTeXT x) = LaTeXT $ f <*> x+ pure = LaTeXT . pure+ (LaTeXT f) <*> (LaTeXT x) = LaTeXT $ f <*> x -- | Type synonym for empty 'LaTeXT' computations. type LaTeXT_ m = LaTeXT m ()@@ -108,12 +103,10 @@ lift = LaTeXT . lift instance Monad m => Monad (LaTeXT m) where- return = LaTeXT . return (LaTeXT c) >>= f = LaTeXT $ do a <- c let LaTeXT c' = f a c'- fail = return . error instance MonadIO m => MonadIO (LaTeXT m) where liftIO = lift . liftIO@@ -138,12 +131,12 @@ -- > myLaTeX = execLaTeXT anExample -- execLaTeXT :: Monad m => LaTeXT m a -> m LaTeX-execLaTeXT = liftM snd . runLaTeXT+execLaTeXT = fmap snd . runLaTeXT -- | Version of 'execLaTeXT' with possible warning messages. -- This function applies 'checkAll' to the 'LaTeX' output. execLaTeXTWarn :: Monad m => LaTeXT m a -> m (LaTeX,[Warning])-execLaTeXTWarn = liftM (id &&& check checkAll) . execLaTeXT+execLaTeXTWarn = fmap (id &&& check checkAll) . execLaTeXT -- | This function run a 'LaTeXT' computation, -- lifting the result again in the monad.@@ -160,7 +153,7 @@ -- is to implement the 'LaTeXC' instance of 'LaTeXT', which -- is closely related. extractLaTeX_ :: Monad m => LaTeXT m a -> LaTeXT m LaTeX-extractLaTeX_ = liftM snd . extractLaTeX+extractLaTeX_ = fmap snd . extractLaTeX -- | With 'textell' you can append 'LaTeX' values to the -- state of the 'LaTeXT' monad.@@ -218,4 +211,6 @@ instance (Monad m, Monoid a) => Monoid (LaTeXT m a) where mempty = return mempty- mappend = liftM2 mappend++instance (Applicative m, Semigroup.Semigroup a) => Semigroup.Semigroup (LaTeXT m a) where+ (<>) = liftA2 (Semigroup.<>)
Text/LaTeX/Packages/AMSFonts.hs view
@@ -1,4 +1,6 @@ +{-# LANGUAGE CPP #-}+ -- | Module for the package @amsfonts@. module Text.LaTeX.Packages.AMSFonts ( -- * AMSFonts package@@ -6,14 +8,16 @@ -- * Fonts , mathbb, mathfrak -- * Number sets- , naturals, integers, rationals, reals+ , naturals, integers, rationals, reals, quaternions -- ** Complex numbers , complexes, trealPart, timagPart ) where import Text.LaTeX.Base.Class import Text.LaTeX.Base.Types+#if !MIN_VERSION_base(4,11,0) import Data.Monoid+#endif -- | AMSFonts package. -- Example:@@ -25,7 +29,7 @@ -- -- | This font is useful for representing sets like--- R (real numbers) or Z (integers). For instance:+-- \(\mathbb{R}\) (real numbers) or \(\mathbb{Z}\) (integers). For instance: -- -- > "The set of real numbers are represented by " <> mathbb "R" <> "." --@@ -37,29 +41,38 @@ mathbb :: LaTeXC l => l -> l mathbb = comm1 "mathbb" --- | Fraktur font.+-- | Fraktur font, like \(\mathfrak{abcXYZ}\). mathfrak :: LaTeXC l => l -> l mathfrak = comm1 "mathfrak" --- | Number sets-+-- | \(\mathbb{N}\) naturals :: LaTeXC l => l naturals = mathbb "N" +-- | \(\mathbb{Z}\) integers :: LaTeXC l => l integers = mathbb "Z" +-- | \(\mathbb{Q}\) rationals :: LaTeXC l => l rationals = mathbb "Q" +-- | \(\mathbb{R}\) reals :: LaTeXC l => l reals = mathbb "R" +-- | \(\mathbb{C}\) complexes :: LaTeXC l => l complexes = mathbb "C" +-- | \(\mathbb{H}\)+quaternions :: LaTeXC l => l+quaternions = mathbb "H"++-- | \(\Re\) trealPart :: LaTeXC l => l -> l trealPart z = comm0 "Re" <> z +-- | \(\Im\) timagPart :: LaTeXC l => l -> l timagPart z = comm0 "Im" <> z
Text/LaTeX/Packages/AMSMath.hs view
@@ -6,7 +6,13 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} #endif --- | \AMSMath\ support. Also numeric instances ('Num', 'Fractional' and 'Floating') for 'LaTeX' and 'LaTeXT'.+-- | <https://ctan.org/pkg/amsmath?lang=en amsmath> is a de-facto standard+-- package for maths in LaTeX. It is used in most scientific documents+-- and also available by default in MathJax.+-- +-- Note that many of the maths commands this module exports are actually defined+-- in LaTeX itself, and do not really require the @amsmath@ package.+-- See the "Text.LaTeX.Base.Math" module for this minimal command-set. module Text.LaTeX.Packages.AMSMath ( -- * AMSMath package amsmath@@ -18,8 +24,6 @@ -- ** Referencing , eqref , nonumber -- * Symbols and utilities- -- | The unicode approximations do, of course, not reliably represent how- -- LaTeX renders these symbols. -- ** Brackets / delimiters , autoParens@@ -46,11 +50,14 @@ , tsqrt -- ** Custom function symbols , operatorname- -- ** Summation \/ integration \/ differentiation+ -- ** Summation \/ integration \/ differentiation \/ relations , tsum , sumFromTo , prod , prodFromTo+ , coprod, coprodFromTo , integral , integralFromTo , partial, totald, partialOf, totaldOf+ , bigcup, bigcupFromTo+ , bigcap, bigcapFromTo -- ** Operator symbols -- *** Arithmetic , (+-), (-+)@@ -67,9 +74,14 @@ , propto , parallel , perp+ , approx+ , sim+ , simeq+ , cong -- *** Sets , in_ , ni , notin , subset , supset+ , subseteq , supseteq , cap , cup , setminus -- *** Misc operators@@ -104,7 +116,7 @@ -- ** Other symbols , pm , mp , to , mapsto, implies- , forall , exists+ , forall_ , exists , dagger, ddagger , infty , imath, jmath@@ -143,131 +155,12 @@ amsmath :: PackageName amsmath = "amsmath" --- | Inline mathematical expressions.-math :: LaTeXC l => l -> l-math = liftL $ TeXMath Dollar --- | Displayed mathematical expressions, i.e. in a seperate line / block.-mathDisplay :: LaTeXC l => l -> l-mathDisplay = liftL $ TeXMath Square----------------------------------------------------------------- Numeric instances for LaTeX and LaTeXT ----------------------------------------------------------------------------- LaTeX instances---- | The 'signum' method uses a custom 'operatorname' and will not be automatically translated by babel.--- This instance is defined in the "Text.LaTeX.Packages.AMSMath" module.-instance Num LaTeX where- (+) = between "+"- (-) = between "-"- (*) = (<>)- negate = (TeXEmpty -)- fromInteger = rendertex- abs = autoBrackets "|" "|"- signum = (operatorname "sgn" <>)---- | Division uses the LaTeX 'frac' command.--- This instance is defined in the "Text.LaTeX.Packages.AMSMath" module.-instance Fractional LaTeX where- (/) = frac- fromRational = rendertex . (fromRational :: Rational -> Double)---- | The 'asinh', 'atanh' and 'acosh' methods use custom 'operatorname's and will not be automatically translated by babel.--- This instance is defined in the "Text.LaTeX.Packages.AMSMath" module.-instance Floating LaTeX where- pi = pi_- exp = (texp <>)- sqrt = tsqrt Nothing- log = (tlog <>)- (**) = (^:)- logBase b x = (commS "log" !: b) <> x- sin = (tsin <>)- tan = (ttan <>)- cos = (tcos <>)- asin = (arcsin <>)- atan = (arctan <>)- acos = (arccos <>)- sinh = (tsinh <>)- tanh = (ttanh <>)- cosh = (tcosh <>)- asinh = (operatorname "arsinh" <>)- atanh = (operatorname "artanh" <>)- acosh = (operatorname "arcosh" <>)------------- LaTeXT instances--#if !MIN_VERSION_base(4,5,0)---- | Warning: this instance only exists for the 'Num' instance.--- This instance is defined in the "Text.LaTeX.Packages.AMSMath" module.-instance Eq (LaTeXT m a) where- _ == _ = error "Cannot use \"(==)\" Eq method with a LaTeXT value."---- | Warning: this instance only exists for the 'Num' instance.--- This instance is defined in the "Text.LaTeX.Packages.AMSMath" module.-instance Show (LaTeXT m a) where- show _ = error "Cannot use \"show\" Show method with a LaTeXT value."--#endif---- | Careful! Method 'signum' is undefined. Don't use it!--- This instance is defined in the "Text.LaTeX.Packages.AMSMath" module.-instance (Monad m, a ~ ()) => Num (LaTeXT m a) where- (+) = liftOp (+)- (-) = liftOp (-)- (*) = (>>)- negate = liftFun negate- fromInteger = fromLaTeX . fromInteger- abs = liftFun abs- signum = liftFun signum---- | Division uses the LaTeX 'frac' command.--- This instance is defined in the "Text.LaTeX.Packages.AMSMath" module.-instance (Monad m, a ~ ()) => Fractional (LaTeXT m a) where- (/) = liftOp (/)- fromRational = fromLaTeX . fromRational---- | Undefined methods: 'asinh', 'atanh' and 'acosh'.--- This instance is defined in the "Text.LaTeX.Packages.AMSMath" module.-instance (Monad m, a ~ ()) => Floating (LaTeXT m a) where- pi = pi_- exp = liftFun exp- sqrt = liftFun sqrt- log = liftFun log- (**) = liftOp (**)- logBase = liftOp logBase- sin = liftFun sin- tan = liftFun tan- cos = liftFun cos- asin = liftFun asin- atan = liftFun atan- acos = liftFun acos- sinh = liftFun sinh- tanh = liftFun tanh- cosh = liftFun cosh- asinh = liftFun asinh- atanh = liftFun atanh- acosh = liftFun acosh- -- | A reference to a numbered equation. Use with a 'label' defined in the -- scope of the equation refered to. eqref :: LaTeXC l => l -> l eqref = liftL $ \l -> TeXComm "eqref" [FixArg . TeXRaw $ render l] --- | Prevent an equation from being numbered, where the environment would by default do that.-nonumber :: LaTeXC l => l-nonumber = comm0 "nonumber"---- | A numbered mathematical equation (or otherwise math expression).-equation :: LaTeXC l => l -> l-equation = liftL $ TeXEnv "equation" []---- | The unnumbered variant of 'equation'.-equation_ :: LaTeXC l => l -> l-equation_ = liftL $ TeXEnv "equation*" []- -- | An array of aligned equations. Use '&' to specify the points that should -- horizontally match. Each equation is numbered, unless prevented by 'nonumber'. align :: LaTeXC l => [l] -> l@@ -284,681 +177,31 @@ ------------------------------------- ------- Symbols and utilities ------- --- | Surround a LaTeX math expression by parentheses whose height--- automatically matches the expression's. Translates to @\\left(...\\right)@.-autoParens :: LaTeXC l => l -> l-autoParens x = commS "left(" <> x <> commS "right)" --- | Like 'autoParens', but with square brackets. Equivalent to @'autoBrackets'\"[\"\"]\"@.-autoSquareBrackets :: LaTeXC l => l -> l-autoSquareBrackets x = commS "left[" <> x <> commS "right]"---- | Like 'autoParens', but with curly brackets.-autoBraces :: LaTeXC l => l -> l-autoBraces x = commS "left"<>"{" <> x <> commS "right"<>"}"---- | Like 'autoParens', but with angle brackets 〈 ... 〉. Equivalent to @'autoBrackets' 'langle' 'rangle'@.-autoAngleBrackets :: LaTeXC l => l -> l-autoAngleBrackets x = commS "left"<>langle <> x <> commS "right"<>rangle---- | Use custom LaTeX expressions as auto-scaled delimiters to surround math.--- Suitable delimiters include |...| (absolute value), ‖...‖ (norm,--- 'dblPipe'), ⌊...⌋ (round-off Gauss brackets, 'lfloor' / 'rfloor') etc..-autoBrackets :: LaTeXC l => LaTeX -> LaTeX -> l -> l-autoBrackets lBrack rBrack x- = commS "left" <> fromLaTeX lBrack <> x <> commS "right" <> fromLaTeX rBrack---- | Left angle bracket, 〈.-langle :: LaTeXC l => l-langle = comm0 "langle"---- | Right angle bracket, 〉.-rangle :: LaTeXC l => l-rangle = comm0 "rangle"---- | Left floor, ⌊.-lfloor :: LaTeXC l => l-lfloor = comm0 "lfloor"---- | Right floor, ⌋.-rfloor :: LaTeXC l => l-rfloor = comm0 "rfloor"---- | Left ceiling, ⌈.-lceil :: LaTeXC l => l-lceil = comm0 "lceil"---- | Right ceiling, ⌉.-rceil :: LaTeXC l => l-rceil = comm0 "rceil"---- | Double vertical line, used as delimiter for norms (‖ ... ‖).-dblPipe :: LaTeXC l => l-dblPipe = comm0 "|"---- | Superscript.-(^:) :: LaTeXC l => l -> l -> l-x ^: y = braces x <> raw "^" <> braces y---- | Subscript.-(!:) :: LaTeXC l => l -> l -> l-x !: y = braces x <> raw "_" <> braces y---- | Sub- and superscript, both stacked.-(!^) :: LaTeXC l => l -> (l,l) -> l-x !^ (y,z) = braces x <> raw "_" <> braces y <> raw "^" <> braces z------ Function symbols---- | Sine function symbol.-tsin :: LaTeXC l => l-tsin = comm0 "sin"---- | Arcsine function symbol.-arcsin :: LaTeXC l => l-arcsin = comm0 "arcsin"---- | Cosine function symbol.-tcos :: LaTeXC l => l-tcos = comm0 "cos"---- | Arccosine function symbol.-arccos :: LaTeXC l => l-arccos = comm0 "arccos"---- | Tangent function symbol.-ttan :: LaTeXC l => l-ttan = comm0 "tan"---- | Arctangent function symbol.-arctan :: LaTeXC l => l-arctan = comm0 "arctan"---- | Cotangent function symbol.-cot :: LaTeXC l => l-cot = comm0 "cot"---- | Arccotangent function symbol.-arccot :: LaTeXC l => l-arccot = comm0 "arccot"---- | Hyperbolic sine function symbol.-tsinh :: LaTeXC l => l-tsinh = comm0 "sinh"---- | Hyperbolic cosine function symbol.-tcosh :: LaTeXC l => l-tcosh = comm0 "cosh"---- | Hyperbolic tangent function symbol.-ttanh :: LaTeXC l => l-ttanh = comm0 "tanh"---- | Hyperbolic cotangent function symbol.-coth :: LaTeXC l => l-coth = comm0 "coth"---- | Secant function symbol.-sec :: LaTeXC l => l-sec = comm0 "sec"---- | Cosecant function symbol.-csc :: LaTeXC l => l-csc = comm0 "csc"---- | Exponential function symbol.-texp :: LaTeXC l => l-texp = comm0 "exp"---- | Logarithm function symbol.-tlog :: LaTeXC l => l-tlog = comm0 "log"---- | Natural logarithm symbol.-ln :: LaTeXC l => l-ln = comm0 "ln"---- | Root notation. Use @tsqrt (Just n) x@ for the @n@th root of @x@.--- When 'Nothing' is supplied, the function will output a square root.-tsqrt :: LaTeXC l => Maybe l -> l -> l-tsqrt Nothing = liftL $ \x -> TeXComm "sqrt" [FixArg x]-tsqrt (Just n) = liftL2 (\m x -> TeXComm "sqrt" [OptArg m, FixArg x]) n------ Custom Function Symbols--- | Defines a new function symbol.--- Note that function symbols defined in this way will not be automatically translated by babel.-operatorname :: LaTeXC l => l -> l-operatorname = comm1 "operatorname"------ Sum/Integral symbols---- | Sigma sumation symbol. Use 'sumFromTo' instead if you want to--- specify the limits of the sum.-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 x y = commS "sum" <> raw"_" <> braces x <> raw"^" <> braces y---- | Pi product symbol. Use 'prodFromTo' if you want to specify the--- limits of the product.-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 x y = commS "prod" <> raw"_" <> braces x <> raw"^" <> braces y---- | Integral symbol. Use 'integralFromTo' if you want to specify--- the limits of the integral.-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 x y = commS "int" <> commS "limits" <> raw"_" <> braces x <> raw"^" <> braces y---- | Partial-differentiation symbol ∂-partial :: LaTeXC l => l-partial = comm0 "partial"---- | Total-differentiation (or integration-variable) symbol d (non-italic!)-totald :: LaTeXC l => l-totald = mathrm "d"---- | Partial-differentiation of variable, e.g. /∂x/.-partialOf :: LaTeXC l => l -> l-partialOf v = comm0 "partial" <> v---- | Total-differentiation of variable, or integration over variable, e.g. d/x/.-totaldOf :: LaTeXC l => l -> l-totaldOf v = mathrm "d" <> v------ Operator symbols---- | Negative form of an operator.-notop :: LaTeXC l =>- (l -> l -> l)- -> l -> l -> l-notop op =- \l1 l2 ->- (l1 <> commS "not") `op` l2--infixl 6 +-, -+---- | Plus-or-minus operator (±). Also available as symbol 'pm'.-(+-) :: LaTeXC l => l -> l -> l-(+-) = between $ comm0 "pm"---- | Minus-or-plus operator (∓). Also available as symbol 'mp'.-(-+) :: LaTeXC l => l -> l -> l-(-+) = between $ comm0 "mp"---- | Centered-dot operator (⋅).-cdot :: LaTeXC l => l -> l -> l-cdot = between $ comm0 "cdot"---- | \"x-cross\" multiplication operator (×).-times :: LaTeXC l => l -> l -> l-times = between $ comm0 "times"---- | Division operator.-div_ :: LaTeXC l => l -> l -> l-div_ = between $ comm0 "div"---- | Fraction operator.-frac :: LaTeXC l => l -> l -> l-frac = liftL2 $ \p q -> TeXComm "frac" [FixArg p, FixArg q]- -- | Like 'frac' but smaller (uses subscript size for the numerator and denominator. tfrac :: LaTeXC l => l -> l -> l tfrac = liftL2 $ \p q -> TeXComm "tfrac" [FixArg p, FixArg q] -infixl 7 *: --- | Asterisk operator (*).------ > infixl 7 *:-(*:) :: LaTeXC l => l -> l -> l-(*:) = between $ comm0 "ast"---- | Star operator (★).-star :: LaTeXC l => l -> l -> l-star = between $ comm0 "star"---- | Ring operator (∘).-circ :: LaTeXC l => l -> l -> l-circ = between $ comm0 "circ"---- | Bullet operator (∙).-bullet :: LaTeXC l => l -> l -> l-bullet = between $ comm0 "bullet"--infixr 4 =: , /=:---- | Equal.------ > infixr 4 =:-(=:) :: LaTeXC l => l -> l -> l-(=:) = between "="---- | Not equal (≠).------ > infixr 4 /=:-(/=:) :: LaTeXC l => l -> l -> l-(/=:) = notop (=:)---- | Greater.-(>:) :: LaTeXC l => l -> l -> l-(>:) = between ">"---- | Greater or equal (≥).-(>=:) :: LaTeXC l => l -> l -> l-(>=:) = between $ comm0 "geq"---- | Lesser.-(<:) :: LaTeXC l => l -> l -> l-(<:) = between "<"---- | Lesser or equal (≤).-(<=:) :: LaTeXC l => l -> l -> l-(<=:) = between $ comm0 "leq"---- | Much less (≪).-ll :: LaTeXC l => l -> l -> l-ll = between $ comm0 "ll"---- | Much greater (≫).-gg :: LaTeXC l => l -> l -> l-gg = between $ comm0 "gg"---- | Proportional-to (∝).-propto :: LaTeXC l => l -> l -> l-propto = between $ comm0 "propto"---- | Perpendicular (⟂). This is the infix version of 'bot'.-perp :: LaTeXC l => l -> l -> l-perp = between $ comm0 "perp"---- | Parallel (‖).-parallel :: LaTeXC l => l -> l -> l-parallel = between $ comm0 "parallel"---- | Identical \/ defined-as \/ equivalent (≡).-equiv :: LaTeXC l => l -> l -> l-equiv = between $ comm0 "equiv"---- | Element-of (∈).-in_ :: LaTeXC l => l -> l -> l-in_ = between $ comm0 "in"---- | Mirrored element-of (∋).-ni :: LaTeXC l => l -> l -> l-ni = between $ comm0 "ni"---- | Not element of (∉).-notin :: LaTeXC l => l -> l -> l-notin = between $ comm0 "notin"---- | Subset-of (⊂).-subset :: LaTeXC l => l -> l -> l-subset = between $ comm0 "subset"---- | Superset-of (⊃).-supset :: LaTeXC l => l -> l -> l-supset = between $ comm0 "supset"---- | Set intersection (∩).-cap :: LaTeXC l => l -> l -> l-cap = between $ comm0 "cap"---- | Set union (∪).-cup :: LaTeXC l => l -> l -> l-cup = between $ comm0 "cup"---- | Set minus (∖).-setminus :: LaTeXC l => l -> l -> l-setminus = between $ comm0 "setminus"---- | Angle pointing downwards (∨).-vee :: LaTeXC l => l -> l -> l-vee = between $ comm0 "vee"---- | Angle pointing upwards (∧).-wedge :: LaTeXC l => l -> l -> l-wedge = between $ comm0 "wedge"---- | Circled plus operator (⊕).-oplus :: LaTeXC l => l -> l -> l-oplus = between $ comm0 "oplus"---- | Circled minus operator (⊖).-ominus :: LaTeXC l => l -> l -> l-ominus = between $ comm0 "ominus"---- | Circled multiplication cross (⊗).-otimes :: LaTeXC l => l -> l -> l-otimes = between $ comm0 "otimes"---- | Circled slash (⊘).-oslash :: LaTeXC l => l -> l -> l-oslash = between $ comm0 "oslash"---- | Circled dot operator (⊙).-odot :: LaTeXC l => l -> l -> l-odot = between $ comm0 "odot"----- Accemts-{-- , hat, tilde, bar, vec, widehat, widetilde- , dot, ddot, dddot- , overline, underline- -}---- | Add a hat accent above a symbol. -hat :: LaTeXC l => l -> l-hat = comm1 "hat"---- | Add a tilde accent above a symbol.-tilde :: LaTeXC l => l -> l-tilde = comm1 "tilde"---- | Add a bar accent above a symbol.-bar :: LaTeXC l => l -> l-bar = comm1 "bar"---- | Add a vector arrow accent above a symbol.-vec :: LaTeXC l => l -> l-vec = comm1 "vec"---- | Add a wide hat accent above a symbol.-widehat :: LaTeXC l => l -> l-widehat = comm1 "widehat"---- | Add a wide tilde accent above a symbol.-widetilde :: LaTeXC l => l -> l-widetilde = comm1 "widetilde"---- | Add a dot accent above a symbol, as used to denote a derivative.-dot :: LaTeXC l => l -> l-dot = comm1 "dot"---- | Add a dot accent above a symbol, as used to denote a second derivative.+-- | Add a dot accent above a symbol, as used to denote a second derivative,+-- like \(\ddot{y}\) ddot :: LaTeXC l => l -> l ddot = comm1 "ddot" --- | Add a triple dot accent above a symbol, as used to denote a third derivative.+-- | Add a triple dot accent above a symbol, as used to denote a third derivative,+-- like \(\dddot{z}\) dddot :: LaTeXC l => l -> l dddot = comm1 "dddot" --- | Add a wide line accent above a symbol.-overline :: LaTeXC l => l -> l-overline = comm1 "overline" ----- Greek alphabet --- | /α/ symbol.-alpha :: LaTeXC l => l-alpha = comm0 "alpha" --- | /β/ symbol.-beta :: LaTeXC l => l-beta = comm0 "beta"---- | /γ/ symbol.-gamma :: LaTeXC l => l-gamma = comm0 "gamma"---- | Γ symbol.-gammau :: LaTeXC l => l-gammau = comm0 "Gamma"---- | /δ/ symbol.-delta :: LaTeXC l => l-delta = comm0 "delta"---- | Δ symbol.-deltau :: LaTeXC l => l-deltau = comm0 "Delta"---- | /ϵ/ symbol.-epsilon :: LaTeXC l => l-epsilon = comm0 "epsilon"---- | /ε/ symbol.-varepsilon :: LaTeXC l => l-varepsilon = comm0 "varepsilon"---- | /ζ/ symbol.-zeta :: LaTeXC l => l-zeta = comm0 "zeta"---- | /η/ symbol.-eta :: LaTeXC l => l-eta = comm0 "eta"---- | /θ/ symbol.-theta :: LaTeXC l => l-theta = comm0 "theta"---- | /ϑ/ symbol.-vartheta :: LaTeXC l => l-vartheta = comm0 "vartheta"---- | Θ symbol.-thetau :: LaTeXC l => l-thetau = comm0 "Theta"---- | /ι/ symbol.-iota :: LaTeXC l => l-iota = comm0 "iota"---- | /κ/ symbol.-kappa :: LaTeXC l => l-kappa = comm0 "kappa"---- | /λ/ symbol.-lambda :: LaTeXC l => l-lambda = comm0 "lambda"---- | Λ symbol.-lambdau :: LaTeXC l => l-lambdau = comm0 "Lambda"---- | /μ/ symbol.-mu :: LaTeXC l => l-mu = comm0 "mu"---- | /ν/ symbol.-nu :: LaTeXC l => l-nu = comm0 "nu"---- | /ξ/ symbol.-xi :: LaTeXC l => l-xi = comm0 "xi"---- | Ξ symbol.-xiu :: LaTeXC l => l-xiu = comm0 "Xi"---- | /π/ symbol.-pi_ :: LaTeXC l => l-pi_ = comm0 "pi"---- | /ϖ/ symbol.-varpi :: LaTeXC l => l-varpi = comm0 "varpi"---- | Π symbol.-piu :: LaTeXC l => l-piu = comm0 "Pi"---- | /ρ/ symbol.-rho :: LaTeXC l => l-rho = comm0 "rho"---- | /ϱ/ symbol.-varrho :: LaTeXC l => l-varrho = comm0 "varrho"---- | /σ/ symbol.-sigma :: LaTeXC l => l-sigma = comm0 "sigma"---- | /ς/ symbol.-varsigma :: LaTeXC l => l-varsigma = comm0 "varsigma"---- | Σ symbol.-sigmau :: LaTeXC l => l-sigmau = comm0 "Sigma"---- | /τ/ symbol.-tau :: LaTeXC l => l-tau = comm0 "tau"---- | /υ/ symbol.-upsilon :: LaTeXC l => l-upsilon = comm0 "upsilon"---- | Υ symbol.-upsilonu :: LaTeXC l => l-upsilonu = comm0 "Upsilon"---- | /ϕ/ symbol.-phi :: LaTeXC l => l-phi = comm0 "phi"---- | /φ/ symbol.-varphi :: LaTeXC l => l-varphi = comm0 "varphi"---- | Φ symbol.-phiu :: LaTeXC l => l-phiu = comm0 "Phi"---- | /χ/ symbol.-chi :: LaTeXC l => l-chi = comm0 "chi"---- | /ψ/ symbol.-psi :: LaTeXC l => l-psi = comm0 "psi"---- | Ψ symbol.-psiu :: LaTeXC l => l-psiu = comm0 "Psi"---- | /ω/ symbol.-omega :: LaTeXC l => l-omega = comm0 "omega"---- | Ω symbol.-omegau :: LaTeXC l => l-omegau = comm0 "Omega"------ Other symbols---- | Plus-or-minus symbol (±). Also available as infix '+-'.-pm :: LaTeXC l => l-pm = comm0 "pm"---- | Minus-or-plus symbol (∓).-mp :: LaTeXC l => l-mp = comm0 "mp"---- | A right-arrow, →.-to :: LaTeXC l => l-to = comm0 "to"---- | A right-arrow for function definitions, ↦.-mapsto :: LaTeXC l => l-mapsto = comm0 "mapsto"---- | An implication arrow, =⇒.-implies :: LaTeXC l => l-implies = comm0 "implies"---- | /For all/ symbol, ∀.-forall :: LaTeXC l => l-forall = comm0 "forall"---- | /Exists/ symbol, ∃.-exists :: LaTeXC l => l-exists = comm0 "exists"---- | Dagger symbol, †.-dagger :: LaTeXC l => l-dagger = comm0 "dagger"---- | Double dagger symbol, ‡.-ddagger :: LaTeXC l => l-ddagger = comm0 "ddagger"---- | Infinity symbol.-infty :: LaTeXC l => l-infty = comm0 "infty"---- | Dotless letter i. Strictly speaking this is not a part of the AMSMath package, but it is defined here for convenience.-imath :: LaTeXC l => l-imath = comm0 "imath"---- | Dotless letter j. Strictly speaking this is not a part of the AMSMath package, but it is defined here for convenience.-jmath :: LaTeXC l => l-jmath = comm0 "jmath"---- | Bottom symbol ⟂. For the infix version see 'perp'.-bot :: LaTeXC l => l-bot = comm0 "bot"---------------------------------------------------- Math Fonts ----------------- | Default math symbol font.-mathdefault :: LaTeXC l => l -> l-mathdefault = comm1 "mathdefault"---- | Bold face.-mathbf :: LaTeXC l => l -> l-mathbf = comm1 "mathbf"---- | Roman, i.e. not-italic math.-mathrm :: LaTeXC l => l -> l-mathrm = comm1 "mathrm"- -- | Escape from math mode, into a normal-text box. -- Unlike 'mathrm', this won't squash spaces, i.e. you can write actual sentences. -- You can embed 'math' again within such a box. text :: LaTeXC l => l -> l text = comm1 "text" --- | Calligraphic math symbols.-mathcal :: LaTeXC l => l -> l-mathcal = comm1 "mathcal"---- | Sans-serif math.-mathsf :: LaTeXC l => l -> l-mathsf = comm1 "mathsf"---- | Typewriter font.-mathtt :: LaTeXC l => l -> l-mathtt = comm1 "mathtt"---- | Italic math. Uses the same glyphs as 'mathdefault', but with spacings--- intended for multi-character symbols rather than juxtaposition of single-character symbols.-mathit :: LaTeXC l => l -> l-mathit = comm1 "mathit"- ------------------------------------- ------------- Matrices -------------- @@ -978,7 +221,7 @@ -- Optional argument sets the alignment of the cells. Default (providing 'Nothing') -- is centered. ----- > ( M )+-- \[ \begin{pmatrix} 0 & 1 \\ 2 & 3 \end{pmatrix} \] -- pmatrix :: (Texy a, LaTeXC l) => Maybe HPos -> Matrix a -> l pmatrix = toMatrix "pmatrix"@@ -987,7 +230,7 @@ -- Optional argument sets the alignment of the cells. Default (providing 'Nothing') -- is centered. ----- > [ M ]+-- \[ \begin{bmatrix} 0 & 1 \\ 2 & 3 \end{bmatrix} \] -- bmatrix :: (Texy a, LaTeXC l) => Maybe HPos -> Matrix a -> l bmatrix = toMatrix "bmatrix"@@ -996,7 +239,7 @@ -- Optional argument sets the alignment of the cells. Default (providing 'Nothing') -- is centered. ----- > { M }+-- \[ \begin{Bmatrix} 0 & 1 \\ 2 & 3 \end{Bmatrix} \] -- b2matrix :: (Texy a, LaTeXC l) => Maybe HPos -> Matrix a -> l b2matrix = toMatrix "Bmatrix"@@ -1005,7 +248,7 @@ -- Optional argument sets the alignment of the cells. Default (providing 'Nothing') -- is centered. ----- > | M |+-- \[ \begin{vmatrix} 0 & 1 \\ 2 & 3 \end{vmatrix} \] -- vmatrix :: (Texy a, LaTeXC l) => Maybe HPos -> Matrix a -> l vmatrix = toMatrix "vmatrix"@@ -1014,7 +257,7 @@ -- Optional argument sets the alignment of the cells. Default (providing 'Nothing') -- is centered. ----- > || M ||+-- \[ \begin{Vmatrix} 0 & 1 \\ 2 & 3 \end{Vmatrix} \] -- v2matrix :: (Texy a, LaTeXC l) => Maybe HPos -> Matrix a -> l v2matrix = toMatrix "Vmatrix"@@ -1053,30 +296,22 @@ ------------------------------------- ----------- Math Spacing------------- --- | \quad space equal to the current font size (= 18 mu)-quad :: LaTeXC l => l-quad = comm0 "quad"---- | \qquad twice of \quad (= 36 mu) -qquad :: LaTeXC l => l-qquad = comm0 "qquad"---- | \, space equal to 3/18 of \quad (= 3 mu)+-- | @\,@ space equal to 3/18 of \quad (= 3 mu). \(a\,b\) thinspace :: LaTeXC l => l thinspace = comm0 "," --- | \: space equal to 4/18 of \quad (= 4 mu)+-- | @\:@ space equal to 4/18 of \quad (= 4 mu). \(a\:b\) medspace :: LaTeXC l => l medspace = comm0 ":" --- | \: space equal to 5/18 of \quad (= 5 mu)+-- | @\:@ space equal to 5/18 of \quad (= 5 mu). \(a\;b\) thickspace :: LaTeXC l => l thickspace = comm0 ";" --- | \! space equal to -3/18 of \quad (= -3 mu)+-- | @\!@ space equal to -3/18 of \quad (= -3 mu). \(a\!b\) negspace :: LaTeXC l => l negspace = comm0 "!" --- | \ (space after backslash) equivalent of space in normal text+-- | @\ @ (space after backslash) equivalent of space in normal text. \(a\ b\) space :: LaTeXC l => l space = comm0 " "
Text/LaTeX/Packages/AMSSymb.hs view
@@ -3,10 +3,35 @@ module Text.LaTeX.Packages.AMSSymb ( -- * AMSSymb package amssymb- -- * Fonts- , checkmark- ) where + -- * Arrows+ , vartriangleleft, vartriangleright + , leftleftarrows, rightrightarrows+ , rightleftarrows, leftrightarrows+ , upuparrows, downdownarrows+ , leftarrowtail, rightarrowtail+ , curvearrowleft, curvearrowright+ , twoheadleftarrow, twoheadrightarrow+ , rightleftharpoons+ , lsh2, rsh2+ , leftarrow3, rightarrow3+ , rightsquigarrow, leftrightsquigarrow+ , looparrowleft, looparrowright+ , circlearrowleft, circlearrowright+ , upharpoonleft, upharpoonright+ , downharpoonleft, downharpoonright+ , nleftarrow, nrightarrow+ , nleftarrow2, nrightarrow2+ , nleftrightarrow, nleftrightarrow2++ -- * Other+ , lll, ggg+ , gtrdot, lessdot+ , square, blacksquare + , lozenge, blacklozenge+ , checkmark, nexists+ ) where+ import Text.LaTeX.Base.Class import Text.LaTeX.Base.Types @@ -19,7 +44,164 @@ -- --- | /✔/ symbol.+-- | \(\vartriangleleft\) symbol.+vartriangleleft :: LaTeXC l => l+vartriangleleft = comm0 "vartriangleleft"++-- | \(\vartriangleleft\) symbol.+vartriangleright :: LaTeXC l => l+vartriangleright = comm0 "vartriangleright"++-- | \(\leftleftarrows\) symbol - double left arrows.+leftleftarrows :: LaTeXC l => l+leftleftarrows = comm0 "leftleftarrows"++-- | \(\rightrightarrows\) symbol - double right arrows+rightrightarrows :: LaTeXC l => l+rightrightarrows = comm0 "rightrightarrows"++-- | \(\rightleftarrows\) symbol - right arrow atop a left arrow+rightleftarrows :: LaTeXC l => l+rightleftarrows = comm0 "rightleftarrows"++-- | \(\leftrightarrows\) symbol - left arrow atop a right arrow.+leftrightarrows :: LaTeXC l => l+leftrightarrows = comm0 "leftrightarrows"++-- | \(\upuparrows\) symbol - double upward arrows.+upuparrows :: LaTeXC l => l+upuparrows = comm0 "upuparrows"++-- | \(\downdownarrows\) symbol - double downward arrows.+downdownarrows :: LaTeXC l => l+downdownarrows = comm0 "downdownarrows"++-- | \(\lll\) symbol - triple less than.+lll :: LaTeXC l => l+lll = comm0 "lll"++-- | \(\ggg\) symbol - triple greater than.+ggg :: LaTeXC l => l+ggg = comm0 "ggg"++-- | \(\leftarrowtail\) symbol - leftwards "mapsto"+leftarrowtail :: LaTeXC l => l+leftarrowtail = comm0 "leftarrowtail"++-- | \(\rightarrowtail\) symbol - rightwards "mapsto"+rightarrowtail :: LaTeXC l => l+rightarrowtail = comm0 "rightarrowtail"++-- | \(\curvearrowleft\) symbol - leftwards curved arrow+curvearrowleft :: LaTeXC l => l+curvearrowleft = comm0 "curvearrowleft"++-- | \(\curvearrowright\) symbol - rightwards curved arrow+curvearrowright :: LaTeXC l => l+curvearrowright = comm0 "curvearrowright"++-- | \(\twoheadleftarrow\) symbol - double head left arrow+twoheadleftarrow :: LaTeXC l => l+twoheadleftarrow = comm0 "twoheadleftarrow"++-- | \(\twoheadrightarrow\) symbol - double head right arrow+twoheadrightarrow :: LaTeXC l => l+twoheadrightarrow = comm0 "twoheadrightarrow"++-- | \(\checkmark\) symbol. checkmark :: LaTeXC l => l checkmark = comm0 "checkmark" +-- | \(\lozenge\) symbol - narrow diamond+lozenge :: LaTeXC l => l+lozenge = comm0 "lozenge"++-- | \(\blacklozenge\) symbol - filled narrow diamond+blacklozenge :: LaTeXC l => l+blacklozenge = comm0 "blacklozenge"++-- | \(\nexists\) symbol - does not exist+nexists :: LaTeXC l => l+nexists = comm0 "nexists"++-- | \(\lessdot\) symbol - less than with inner dot+lessdot :: LaTeXC l => l+lessdot = comm0 "lessdot"++-- | \(\gtrdot\) symbol - greater than with inner dot+gtrdot :: LaTeXC l => l+gtrdot = comm0 "gtrdot"++-- | \(\square\) symbol - square.+-- For the QED “tombstone”, see 'Text.LaTeX.Packages.AMSThm.qed' instead; it is normally the+-- same symbol but gives the suitable text alignment.+square :: LaTeXC l => l+square = comm0 "square"++-- | \(\blacksquare\) symbol - a filled square+blacksquare :: LaTeXC l => l+blacksquare = comm0 "blacksquare"++-- | \(\rightleftharpoons\) symbol+rightleftharpoons :: LaTeXC l => l+rightleftharpoons = comm0 "rightleftharpoons"+-- | \(\Lsh\) symbol+lsh2 :: LaTeXC l => l+lsh2 = comm0 "Lsh"+-- | \(\Rsh\) symbol+rsh2 :: LaTeXC l => l+rsh2 = comm0 "Rsh"+-- | \(\Lleftarrow\) symbol+leftarrow3 :: LaTeXC l => l+leftarrow3 = comm0 "Lleftarrow"+-- | \(\Rrightarrow\) symbol+rightarrow3 :: LaTeXC l => l+rightarrow3 = comm0 "Rrightarrow"+-- | \(\rightsquigarrow\) symbol+rightsquigarrow :: LaTeXC l => l+rightsquigarrow = comm0 "rightsquigarrow"+-- | \(\leftrightsquigarrow\) symbol+leftrightsquigarrow :: LaTeXC l => l+leftrightsquigarrow = comm0 "leftrightsquigarrow"+-- | \(\looparrowleft\) symbol+looparrowleft :: LaTeXC l => l+looparrowleft = comm0 "looparrowleft"+-- | \(\looparrowright\) symbol+looparrowright :: LaTeXC l => l+looparrowright = comm0 "looparrowright"+-- | \(\circlearrowleft\) symbol+circlearrowleft :: LaTeXC l => l+circlearrowleft = comm0 "circlearrowleft"+-- | \(\circlearrowright\) symbol+circlearrowright :: LaTeXC l => l+circlearrowright = comm0 "circlearrowright"+-- | \(\upharpoonleft\) symbol+upharpoonleft :: LaTeXC l => l+upharpoonleft = comm0 "upharpoonleft"+-- | \(\upharpoonright\) symbol+upharpoonright :: LaTeXC l => l+upharpoonright = comm0 "upharpoonright"+-- | \(\downharpoonleft\) symbol+downharpoonleft :: LaTeXC l => l+downharpoonleft = comm0 "downharpoonleft"+-- | \(\downharpoonright\) symbol+downharpoonright :: LaTeXC l => l+downharpoonright = comm0 "downharpoonright"+-- | \(\nleftarrow\) symbol+nleftarrow :: LaTeXC l => l+nleftarrow = comm0 "nleftarrow"+-- | \(\nrightarrow\) symbol+nrightarrow :: LaTeXC l => l+nrightarrow = comm0 "nrightarrow"+-- | \(\nLeftarrow\) symbol+nleftarrow2 :: LaTeXC l => l+nleftarrow2 = comm0 "nLeftarrow"+-- | \(\nRightarrow\) symbol+nrightarrow2 :: LaTeXC l => l+nrightarrow2 = comm0 "nRightarrow"+-- | \(\nleftrightarrow\) symbol+nleftrightarrow :: LaTeXC l => l+nleftrightarrow = comm0 "nleftrightarrow"+-- | \(\nLeftrightarrow\) symbol+nleftrightarrow2 :: LaTeXC l => l+nleftrightarrow2 = comm0 "nLeftrightarrow"
Text/LaTeX/Packages/AMSThm.hs view
@@ -9,6 +9,7 @@ , newtheorem , theorem , proof+ , qed , qedhere , TheoremStyle (..) , theoremstyle@@ -48,7 +49,13 @@ proof Nothing = liftL $ TeXEnv "proof" [] proof (Just n) = liftL2 (\m -> TeXEnv "proof" [OptArg m]) n --- | Insert the /QED/ symbol.+-- | Insert the /QED/ symbol \(\square\), as a concluding right-aligned terminator.+-- Note that within a 'proof' environment, this is automatically done at the end.+qed :: LaTeXC l => l+qed = comm0 "qed"++-- | Insert the /QED/ symbol. This is supposed to be used within a 'proof' environment,+-- to change the default behaviour of putting the \(\square\) at the end. qedhere :: LaTeXC l => l qedhere = comm0 "qedhere"
+ Text/LaTeX/Packages/Acronym.hs view
@@ -0,0 +1,258 @@+{-# LANGUAGE OverloadedStrings, CPP #-}++-- | Add acronyms to your documents using this module.+--+-- Define and render acronyms in a document, where the first occurrance is the+-- long variant, and the next ones are the shorter variant.+module Text.LaTeX.Packages.Acronym+ ( -- * Acronym package+ pacronym+ -- * Package options+ , footnote, nohyperlinks, printonlyused, withpage, smaller, dua, nolist+ -- * Types+ , Acronym(..)+ -- functions+ , ac, acf, acs, acl, acp, acfp, acsp, aclp, acfi, acsu, aclu, iac, iac2+ , ac', acf', acs', acl', acp', acfp', acsp', aclp', acfi', acsu', aclu', iac', iac2'+ , acresetall, acused+ , acroextra+ , acronym+ , acro, acro'+ , acroM, acroM'+ ) where++import Data.String(IsString(fromString))++import Text.LaTeX.Base.Class(LaTeXC, comm0, comm1, comm2, liftL, liftL2)+import Text.LaTeX.Base.Syntax(LaTeX(TeXComm, TeXEnv), TeXArg(FixArg, OptArg))+import Text.LaTeX.Base.Types(PackageName)+import Text.LaTeX.Base.Writer(LaTeXT)++-- | The 'pacronym' package.+--+-- > usepackage [] pacronym+pacronym :: PackageName+pacronym = "acronym"++-- | Redefines the `\acf` and `\acfp` commands making the full+-- name appear as a footnote+footnote :: LaTeXC l => l+footnote = "footnote"++-- | If hyperref is loaded, all acronyms will link to their glossary entry. With+-- the `nohyperlinks` option, these links are suppressed.+nohyperlinks :: LaTeXC l => l+nohyperlinks = "nohyperlinks"++-- | We need a marker which is set if the option `printonlyused` was used.+printonlyused :: LaTeXC l => l+printonlyused = "printonlyused"++-- | A marker which tells us to print page numbers.+withpage :: LaTeXC l => l+withpage = "withpage"++-- | The option `smaller` leads to a redefinition of `\acsfont`. We want to make+-- the acronym appear smaller. Since this should be done in a+-- context-sensitive way, we rely on the macro \textsmaller provided by the+-- `relsize` package. As `\RequiredPackage` cannot be used inside+-- `\DeclareOption`, we need a boolean variable.+smaller :: LaTeXC l => l+smaller = "smaller"++-- | The option `dua` stands for "don't use acronyms". It leads to a+-- redefinition of `\ac` and `\acp` making the full name appear all the time+-- and suppressing all acronyms but the explicitly requested by `\acf` and+-- `\acfp`.+dua :: LaTeXC l => l+dua = "dua"++-- | The option `nolist` stands for "don't write the list of acronyms".+nolist :: LaTeXC l => l+nolist = "nolist"++-- | An acronym type with a label, this is used to generate commands linked to+-- this acronym.+newtype Acronym = Acronym { acronymLabel :: String }++_acronymLabel :: IsString s => Acronym -> s+_acronymLabel = fromString . acronymLabel++_acronymC1 :: LaTeXC l => String -> Acronym -> l+_acronymC1 = (. _acronymLabel) . comm1++-- | Enter an acronym inside the text. The first time the acronym is used, it+-- will specify the full name, and between parenthesis, the short name. If you+-- specified the `footnote` option, it will print the short name, and add a+-- footnote with the long name. The next time, only the short time is printed.+ac :: LaTeXC l => Acronym -> l+ac = _acronymC1 "ac"++-- | You can use this command to later in the text again print the full name of+-- the acronym, this stands for "full acronym", it always prints the full+-- name, and the acronym between parenthesis.+acf :: LaTeXC l => Acronym -> l+acf = _acronymC1 "acf"++-- | This will enter the short version of the acronym inside the text.+acs :: LaTeXC l => Acronym -> l+acs = _acronymC1 "acs"++-- | This will enter the expanded version of the acronym in the text, without+-- mentioning the acronym between parenthesis.+acl :: LaTeXC l => Acronym -> l+acl = _acronymC1 "acl"++-- | This works the same way as `ac`, except that it will make the short and the+-- long forms into plurals.+acp :: LaTeXC l => Acronym -> l+acp = _acronymC1 "acp"++-- | This works the same way as `acf`, except tah it will make the short and+-- long forms into plurals.+acfp :: LaTeXC l => Acronym -> l+acfp = _acronymC1 "acfp"++-- | Works the same way as `acs`, but makes the short form into a plural.+acsp :: LaTeXC l => Acronym -> l+acsp = _acronymC1 "acsp"++-- | Works the same way as `acl`, but makes the long form into a plural.+aclp :: LaTeXC l => Acronym -> l+aclp = _acronymC1 "aclp"++-- | Prints the full name acronym in italics and the abbreviated form in an+-- upshaped form.+acfi :: LaTeXC l => Acronym -> l+acfi = _acronymC1 "acfi"++-- | Prints the short form of the acronym, and marks it as used.+acsu :: LaTeXC l => Acronym -> l+acsu = _acronymC1 "acsu"++-- | Prints the long form of the acronym and marks it as used.+aclu :: LaTeXC l => Acronym -> l+aclu = _acronymC1 "aclu"++-- | Works the same way as the `ac` command, but prefixes it with an appropriate+-- indefinite article.+iac :: LaTeXC l => Acronym -> l+iac = _acronymC1 "iac"++-- | Works the same way as the `ac` command, but prefixes it with an appropriate+-- upper case indefinite article.+iac2 :: LaTeXC l => Acronym -> l+iac2 = _acronymC1 "Iac"++-- | Enter an acronym inside the text. It will specify the full name, and+-- between parenthesis, the short name. If you specified the `footnote`+-- option, it will print the short name, and add a footnote with the long+-- name. This does not mark the acronym as used.+ac' :: LaTeXC l => Acronym -> l+ac' = _acronymC1 "ac*"++-- | You can use this command to later in the text again print the full name of+-- the acronym, this stands for "full acronym", it always prints the full+-- name, and the acronym between parenthesis. This does not mark the+-- acronym as used.+acf' :: LaTeXC l => Acronym -> l+acf' = _acronymC1 "acf*"++-- | This will enter the short version of the acronym inside the text.+-- This does not mark the acronym as used.+acs' :: LaTeXC l => Acronym -> l+acs' = _acronymC1 "acs*"++-- | This will enter the expanded version of the acronym in the text, without+-- mentioning the acronym between parenthesis. This does not mark the acronym+-- as used.+acl' :: LaTeXC l => Acronym -> l+acl' = _acronymC1 "acl*"++-- | This works the same way as `ac`, except that it will make the short and the+-- long forms into plurals. This does not mark the acronym as used.+acp' :: LaTeXC l => Acronym -> l+acp' = _acronymC1 "acp*"++-- | This works the same way as `acf`, except tah it will make the short and+-- long forms into plurals. This does not mark the acronym as used.+acfp' :: LaTeXC l => Acronym -> l+acfp' = _acronymC1 "acfp*"++-- | Works the same way as `acs`, but makes the short form into a plural. This+-- does not mark the acronym as used.+acsp' :: LaTeXC l => Acronym -> l+acsp' = _acronymC1 "acsp*"++-- | Works the same way as `acl`, but makes the long form into a plural. This+-- does not mark the acronym as used.+aclp' :: LaTeXC l => Acronym -> l+aclp' = _acronymC1 "aclp*"++-- | Prints the full name acronym in italics and the abbreviated form in an+-- upshaped form. This does not mark the acronym as used.+acfi' :: LaTeXC l => Acronym -> l+acfi' = _acronymC1 "acfi*"++-- | Prints the short form of the acronym, and marks it as used. This does not+-- mark the acronym as used.+acsu' :: LaTeXC l => Acronym -> l+acsu' = _acronymC1 "acsu*"++-- | Prints the long form of the acronym and marks it as used. This does not mark+-- the acronym as used.+aclu' :: LaTeXC l => Acronym -> l+aclu' = _acronymC1 "aclu*"++-- | Works the same way as the `ac` command, but prefixes it with an appropriate+-- indefinite article. This does not mark the acronym as used.+iac' :: LaTeXC l => Acronym -> l+iac' = _acronymC1 "iac*"++-- | Works the same way as the `ac` command, but prefixes it with an appropriate+-- upper case indefinite article. This does not mark the acronym as used.+iac2' :: LaTeXC l => Acronym -> l+iac2' = _acronymC1 "Iac*"++-- | The memory of the marco `ac` is flushed, afterwards, `ac` will print the+-- full name of any acronym, and the acronym within parenthesis.+acresetall :: LaTeXC l => l+acresetall = comm0 "acresetall"++-- | Marks an acronym as useed, as if it has been called with `ac`, but without+-- printing anything. In the future, only the short form of the acronym will+-- be printed. `acresetall` undoes this.+acused :: LaTeXC l => Acronym -> l+acused = _acronymC1 "acused"++-- | This can be used inside the `acro` part to add extra data to the list of+-- acrynyms, this will *not* be included when rendering the acronym in the+-- document itself.+acroextra :: LaTeXC l => l -> l+acroextra = comm1 "acroextra"++-- | Define an acronym environment to write the acronym definitions to.+acronym :: LaTeXC l => l -> l+acronym = liftL (TeXEnv "acronym" [])++-- | Define an acronym with a label and both a short, and a long name. This+-- returns the LaTeX code to define the acronym, and the `Acronym` object+-- to use in the rest of the code.+acro :: LaTeXC l => String -> l -> l -> (l, Acronym)+acro str l2 l3 = (liftL2 (\la lb -> TeXComm "acro" [FixArg (fromString str), OptArg la, FixArg lb]) l2 l3, Acronym str)++-- | The monadic variant of the `acro` function where the `Acronym` is returned+-- as a result of the definition.+acroM :: Monad m => String -> LaTeXT m () -> LaTeXT m () -> LaTeXT m Acronym+acroM str l2 l3 = uncurry (flip (fmap . const)) (acro str l2 l3)++-- | Define an acronym with a label, and only a long name. This returns the+-- LaTeX code to define the acronym, and the `Acronym` object to use in the+-- rest of the code.+acro' :: LaTeXC l => String -> l -> (l, Acronym)+acro' str l = (comm2 "acro" (fromString str) l, Acronym str)++-- | The monadic variant of the `acro'` function, where the `Acronym` is+-- returned as result of the definition.+acroM' :: Monad m => String -> LaTeXT m () -> LaTeXT m Acronym+acroM' str l2 = uncurry (flip (fmap . const)) (acro' str l2)
Text/LaTeX/Packages/Babel.hs view
@@ -77,7 +77,7 @@ -- If you are using more than one language, consider to use -- 'uselanguageconf'. uselanguage :: LaTeXC l => Language -> l-uselanguage ln = usepackage [texy ln] babel+uselanguage lang = usepackage [texy lang] babel -- | Language configuration. You may use one with 'uselanguageconf'. data LangConf = LangConf { mainLang :: Language , otherLangs :: [Language] }@@ -99,14 +99,15 @@ -- | Switch to a given 'Language'. selectlanguage :: LaTeXC l => Language -> l-selectlanguage ln = fromLaTeX $ TeXComm "selectlanguage" [FixArg $ texy ln]+selectlanguage lang = fromLaTeX $ TeXComm "selectlanguage" [FixArg $ texy lang] -- | Use a 'Language' locally. otherlanguage :: LaTeXC l => Language -> l -> l-otherlanguage ln = liftL $ TeXEnv "otherlanguage" [FixArg $ texy ln]+otherlanguage lang = liftL $ TeXEnv "otherlanguage" [FixArg $ texy lang] -- | The function 'foreignlanguage' takes two arguments; the second argument is a -- phrase to be typeset according to the rules of the language named in its first -- argument. foreignlanguage :: LaTeXC l => Language -> l -> l-foreignlanguage ln = liftL $ \l -> TeXComm "foreignlanguage" [OptArg $ texy ln, FixArg l]+foreignlanguage lang = liftL+ $ \l -> TeXComm "foreignlanguage" [OptArg $ texy lang, FixArg l]
+ Text/LaTeX/Packages/BibLaTeX.hs view
@@ -0,0 +1,237 @@+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE DeriveFunctor #-}+{-# LANGUAGE FlexibleContexts #-}++-- | <https://ctan.org/tex-archive/macros/latex/contrib/biblatex BibLaTeX>+-- is a reference-citation package using @.bib@ files (BibTeX) but no extra style-files.+--+module Text.LaTeX.Packages.BibLaTeX+ ( biblatex+ , addbibresource+ , cite+ , printbibliography+ -- * Automatic bibliography retrieval+ , documentWithDOIReferences+ , PlainDOI+ , citeDOI+ , textc+ , textC+ , DOIReference+ , ReferenceQueryT+ , applyDOIReferenceResolves+ , masterBibFile+ ) where++import Text.LaTeX.Base.Syntax hiding ((<>))+import Text.LaTeX.Base.Class (LaTeXC(..), liftL, fromLaTeX, comm0, raw)+import Text.LaTeX.Base.Render+import Text.LaTeX.Base.Types+import Text.LaTeX.Base.Commands (cite, footnote, document)++import Data.Char (toLower)+import qualified Data.Semigroup as SG+import GHC.Generics (Generic)+import qualified Data.Traversable as Tr++import qualified Data.Map as Map+import Data.Maybe (catMaybes)+import Data.Hashable (hash)+import Numeric (showHex)++import qualified Data.List as List++import Control.Applicative (liftA2)+import Control.Monad (forM)+import Control.Monad.IO.Class++import qualified Text.BibTeX.Entry as BibTeX+import qualified Text.BibTeX.Format as BibTeX+import qualified Text.BibTeX.Parse as BibTeX (file)+import qualified Text.Parsec.String as Parsec++-- | BibLaTeX package. Use it to import it like this:+--+-- > usepackage [] biblatex+biblatex :: PackageName+biblatex = "biblatex"++-- | Use a bibliography file as resource for reference information.+addbibresource :: LaTeXC l => FilePath -> l+addbibresource fp = fromLaTeX $ TeXComm "addbibresource" [FixArg $ TeXRaw $ fromString fp]++printbibliography :: LaTeXC l => l+printbibliography = comm0 "printbibliography"+++-- | All-inclusive preparation of a document containing DOI references.+-- Uses 'applyDOIReferenceResolves' under the hood.+documentWithDOIReferences :: (MonadIO m, LaTeXC (m ()), SG.Semigroup (m ()), r ~ DOIReference)+ => (r -> m (Maybe BibTeX.T)) -- ^ Reference-resolver function, for looking up BibTeX+ -- entries for a given DOI.+ -- If the DOI cannot be looked up (@Nothing@), we just+ -- include a footnote with a synopsis and the DOI in+ -- literal form. (Mostly intended to ease offline editing.)+ -> ReferenceQueryT r m () -- ^ The document content, possibly containing citations+ -- in DOI-only form.+ -> m () -- ^ LaTeX rendition. The content will already be wrapped+ -- in @\\begin…end{document}@ here and an+ -- automatically-generated @.bib@ file included, but+ -- you still need to 'usepackage' 'biblatex' yourself.+documentWithDOIReferences resolver docW = do+ (refsMap, docConts) <- applyDOIReferenceResolves resolver docW+ let bibfileConts = unlines $ BibTeX.entry . snd <$> Map.toList refsMap+ bibfileName = showHex (abs $ hash bibfileConts) $ ".bib"+ liftIO $ writeFile bibfileName bibfileConts+ () <- addbibresource bibfileName+ document docConts+ +-- | More manual version of 'documentWithDOIReferences', only retrieving suitable+-- BibTeX entries for the DOI-references contained in the document, but not+-- generating any @.bib@ files or wrapping the content in it.+applyDOIReferenceResolves :: (MonadIO m, LaTeXC (m ()), SG.Semigroup (m ()), r ~ DOIReference)+ => (r -> m (Maybe BibTeX.T)) -- ^ Reference-resolver function.+ -> ReferenceQueryT r m () -- ^ The document content.+ -> m ( Map.Map DOIReference BibTeX.T+ , m ()) -- ^ All the BibTeX entries found, and a version of the+ -- document with all its doi-references changed to point to+ -- the identifiers in that file.+applyDOIReferenceResolves resolver (ReferenceQueryT refq) = do+ (allRefs, (), useRefs) <- refq+ resolved <- fmap catMaybes . forM (allRefs[]) $ \r -> do+ r' <- resolver r+ return $ case r' of+ Just entry -> Just (r, entry)+ Nothing -> Nothing+ let refsMap = Map.fromList resolved+ return (refsMap, useRefs $ \r flavour -> case Map.lookup r refsMap of+ Just a -> let citeC = liftL $ \l -> (`TeXComm`[FixArg l]) $ case flavour of+ Flavour_cite -> "cite" + Flavour_Cite -> "Cite"+ Flavour_parencite -> "parencite"+ Flavour_Parencite -> "Parencite"+ Flavour_footcite -> "footcite"+ Flavour_Footcite -> "Footcite"+ Flavour_textcite -> "textcite"+ Flavour_Textcite -> "Textcite"+ Flavour_smartcite -> "smartcite"+ Flavour_Smartcite -> "Smartcite"+ in citeC . raw . fromString $ BibTeX.identifier a+ Nothing -> makeshift r+ )+ where makeshift :: (LaTeXC l, SG.Semigroup l) => DOIReference -> l+ makeshift (DOIReference doi synops) = footnote $+ fromLaTeX synops SG.<> ". DOI:" SG.<> fromString doi+ ++type PlainDOI = String++data DOIReference = DOIReference {+ _referenceDOI :: PlainDOI+ , _referenceSynopsis :: LaTeX+ } deriving (Generic, Show)+instance Eq DOIReference where+ DOIReference doi₀ _ == DOIReference doi₁ _ = doi₀ == doi₁+instance Ord DOIReference where+ compare (DOIReference doi₀ _) (DOIReference doi₁ _) = compare doi₀ doi₁++type DList r = [r] -> [r]++data CitationFlavour+ = Flavour_cite+ | Flavour_Cite+ | Flavour_parencite+ | Flavour_Parencite+ | Flavour_footcite+ | Flavour_Footcite+ | Flavour_textcite+ | Flavour_Textcite+ | Flavour_smartcite+ | Flavour_Smartcite+ deriving (Eq, Ord, Show)++newtype ReferenceQueryT r m a = ReferenceQueryT {+ runReferenceQueryT :: m (DList r, a, (r -> CitationFlavour -> m ()) -> m ())+ }+ deriving (Generic, Functor)++instance Applicative m => Applicative (ReferenceQueryT r m) where+ pure x = ReferenceQueryT . pure $ (id, x, const $ pure ())+ ReferenceQueryT refqf <*> ReferenceQueryT refqx = ReferenceQueryT $+ liftA2 (\(urefsf, f, refref)+ (urefsx, x, refrex)+ -> ( urefsf . urefsx+ , f x+ , \resolv -> mappend <$> refref resolv <*> refrex resolv ) )+ refqf refqx+instance Monad m => Monad (ReferenceQueryT r m) where+ return = pure+ ReferenceQueryT refsx >>= f+ = ReferenceQueryT $ refsx >>= \(urefsx, x, refrex)+ -> case f x of+ ReferenceQueryT refsfx+ -> (\(urefsfx,fx,refrefx)+ -> ( urefsx.urefsfx+ , fx+ , \resolve -> mappend <$> refrex resolve <*> refrefx resolve ))+ <$> refsfx+instance MonadIO m => MonadIO (ReferenceQueryT r m) where+ liftIO a = ReferenceQueryT $ (\r -> (id, r, const $ pure ())) <$> liftIO a++instance (Functor m, Monoid (m a), IsString (m ()), a ~ ())+ => IsString (ReferenceQueryT r m a) where+ fromString s = ReferenceQueryT $ (\a -> (id, a, const $ fromString s)) <$> mempty++instance (Applicative m, SG.Semigroup (m a), a ~ ())+ => SG.Semigroup (ReferenceQueryT r m a) where+ ReferenceQueryT p <> ReferenceQueryT q+ = ReferenceQueryT $ liftA2 (\(rp,(),ρp) (rq,(),ρq)+ -> (rp.rq,(),liftA2(liftA2 (SG.<>))ρp ρq)) p q++instance (Applicative m, SG.Semigroup (m a), Monoid (m a), a ~ ())+ => Monoid (ReferenceQueryT r m a) where+ mempty = ReferenceQueryT $ (\a -> (id, a, mempty)) <$> mempty+ mappend = (SG.<>)++instance (Applicative m, LaTeXC (m a), SG.Semigroup (m a), a ~ ())+ => LaTeXC (ReferenceQueryT r m a) where+ liftListL f xs = ReferenceQueryT $+ (\components -> case List.unzip3 components of+ (refs, _, rebuilds) -> ( foldr (.) id refs+ , ()+ , \resolve -> liftListL f $ ($ resolve)<$>rebuilds )+ ) <$> Tr.traverse runReferenceQueryT xs++citeDOI :: (Functor m, Monoid (m ()), IsString (m ()))+ => PlainDOI -- ^ The unambiguous document identifier.+ -> String -- ^ Synopsis of the cited work, in the form+ -- @"J Doe et al 1950: Investigation of a Foo"@;+ -- this is strictly speaking optional, the synopsis will /not/+ -- be included in the final document (provided the DOI+ -- can be properly resolved).+ -> ReferenceQueryT DOIReference m ()+citeDOI doi synops = ReferenceQueryT $ (\a -> ( (r :), a, \f -> f r Flavour_cite ))+ <$> mempty+ where r = DOIReference doi $ fromString synops++-- | Transform a citation into @\\textcite@, i.e. so that it can be used as a noun in a sentence.+textc :: Functor m => ReferenceQueryT DOIReference m () -> ReferenceQueryT DOIReference m ()+textc (ReferenceQueryT y) = ReferenceQueryT+ $ (\(r,m,a) -> (r, m, \f -> a (\x _ -> f x Flavour_textcite))) <$> y++-- | Transform a citation into @\\Textcite@, i.e. so that it can be used as the first word in a sentence.+textC :: Functor m => ReferenceQueryT DOIReference m () -> ReferenceQueryT DOIReference m ()+textC (ReferenceQueryT y) = ReferenceQueryT+ $ (\(r,m,a) -> (r, m, \f -> a (\x _ -> f x Flavour_Textcite))) <$> y++masterBibFile :: MonadIO m+ => FilePath -- ^ A @.bib@ file containing entries for all relevant literature.+ -> (DOIReference -> m (Maybe BibTeX.T))+ -- ^ Lookup-function, suitable for 'documentWithDOIReferences'.+masterBibFile master (DOIReference doi _) = do+ entries <- liftIO $ BibTeX.file `Parsec.parseFromFile` master+ return $ case entries of+ Right bibs -> List.find hasThisDOI bibs+ Left err -> error $ show err+ where hasThisDOI bib = (map toLower <$> List.lookup "doi" (BibTeX.fields bib))+ == Just (toLower<$>doi)
+ Text/LaTeX/Packages/Bigstrut.hs view
@@ -0,0 +1,37 @@+{-# LANGUAGE OverloadedStrings #-}++-- | An extension to the standard LaTeX tabular environment that+-- creates struts which (slightly) stretch the table row in which they+-- sit.++module Text.LaTeX.Packages.Bigstrut+ ( bigstrutp+ , bigstrut+ , bigstrutTop+ , bigstrutBottom+ ) where++import Text.LaTeX.Base.Syntax (LaTeX(TeXComm), TeXArg(OptArg))+import Text.LaTeX.Base.Class (LaTeXC, fromLaTeX)+import Text.LaTeX.Base.Types (PackageName)++-- | bigstrut package. Use it to import it like this:+--+-- > usepackage [] bigstrut+bigstrutp :: PackageName+bigstrutp = "bigstrut"++-- | 'bigstrutTop', 'bigstrutBottom' and 'bigstrut' produce a strut (a+-- rule with width 0) which is 'bigstrutjot' (2pt by default) higher,+-- lower, or both than the standard array/tabular strut. Use them in+-- table entries that are adjacent to 'hlines' to leave an extra bit+-- of space++bigstrut :: LaTeXC l => l+bigstrut = fromLaTeX $ TeXComm "bigstrut" []++bigstrutTop :: LaTeXC l => l+bigstrutTop = fromLaTeX $ TeXComm "bigstrut" [OptArg "t"]++bigstrutBottom :: LaTeXC l => l+bigstrutBottom = fromLaTeX $ TeXComm "bigstrut" [OptArg "b"]
Text/LaTeX/Packages/Color.hs view
@@ -1,5 +1,5 @@ -{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE OverloadedStrings, CPP #-} -- | Make your documents colorful using this module. --@@ -30,7 +30,9 @@ , normalcolor ) where -import Text.LaTeX.Base.Syntax+#if !MIN_VERSION_base(4,11,0)+import Text.LaTeX.Base.Syntax ((<>))+#endif import Text.LaTeX.Base.Class import Text.LaTeX.Base.Render import Text.LaTeX.Base.Types
Text/LaTeX/Packages/Graphicx.hs view
@@ -1,5 +1,4 @@--{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE OverloadedStrings, CPP #-} -- | This module allows you to use the LaTeX /graphicx/ library in order to -- insert graphics in a document and perform some transformations.@@ -28,6 +27,9 @@ import Text.LaTeX.Base.Types -- import Data.Char (toLower)+#if !MIN_VERSION_base(4,8,0)+import Data.Functor ((<$>))+#endif -- | The 'graphicx' package. --@@ -63,11 +65,11 @@ instance Render IGOption where render (IGWidth m) = "width=" <> render m render (IGHeight m) = "height=" <> render m- render (KeepAspectRatio b) = "keepaspectratio=" <> fromString (fmap toLower $ show b)+ render (KeepAspectRatio b) = "keepaspectratio=" <> fromString (toLower <$> show b) render (IGScale r) = "scale=" <> render r render (IGAngle a) = "angle=" <> render a render (IGTrim l b r t) = "trim=" <> renderChars ' ' [l,b,r,t]- render (IGClip b) = "clip=" <> fromString (fmap toLower $ show b)+ render (IGClip b) = "clip=" <> fromString (toLower <$> show b) render (IGPage p) = "page=" <> render p -- | Include an image in the document.@@ -76,7 +78,7 @@ -> FilePath -- ^ Image file -> l includegraphics opts fp = fromLaTeX $ TeXComm "includegraphics"- [ MOptArg $ fmap rendertex opts , FixArg $ TeXRaw $ fromString fp ]+ [ MOptArg $ fmap rendertex opts, FixArg $ TeXRaw $ fromString fp ] -- | Rotate the content by the given angle in degrees. rotatebox :: LaTeXC l => Float -> l -> l
Text/LaTeX/Packages/Hyperref.hs view
@@ -31,7 +31,6 @@ 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)@@ -144,7 +143,7 @@ -- | This package option sets the layout of PDF pages. pdfpagelayout :: LaTeXC l => PdfPageLayout -> l-pdfpagelayout l = packageOption "pdfpagelayout" . raw . pack . show $ l+pdfpagelayout = packageOption "pdfpagelayout" . raw . pack . show -- | Specification for how pages of a PDF should be displayed. data PdfPageLayout = SinglePage -- ^ Displays a single page; advancing flips the page.
+ Text/LaTeX/Packages/Lscape.hs view
@@ -0,0 +1,37 @@+{-# LANGUAGE OverloadedStrings #-}++module Text.LaTeX.Packages.Lscape+ ( -- * lscape package+ lscape+ -- * lscape commands+ , landscape+ -- * Package Options+ , pdftex+ ) where++import Text.LaTeX.Base.Syntax (LaTeX(TeXEnv))+import Text.LaTeX.Base.Class (LaTeXC, liftL)+import Text.LaTeX.Base.Types (PackageName)++-- | lscape package. Use it to import it like this:+--+-- > usepackage [] lscape+lscape :: PackageName+lscape = "lscape"++-- | This package option makes 'lscape' rotate the PDF paper – not+-- just the text on the page – when given the 'pdftex' option.+-- (Naturally, this works only with pdfLaTeX.) The result is that the+-- text is viewable online without the reader having to rotate his/her+-- head 90 degrees. The document still prints normally.+pdftex :: LaTeXC l => l+pdftex = "pdftex"++-- | All text within the 'landscape' environment is rotated through 90+-- degrees. The environment may span several pages. It works well+-- with, and was originally created for, use with 'longtable' to+-- produce long wide tables.+landscape :: LaTeXC l =>+ l -- ^ Text to be rotated+ -> l -- ^ Resulting rotated text.+landscape = liftL $ TeXEnv "landscape" []
+ Text/LaTeX/Packages/Multirow.hs view
@@ -0,0 +1,62 @@+{-# LANGUAGE OverloadedStrings #-}++-- | An extension to the standard LaTeX tabular environment which+-- provides a construction for table cells that span more than one row+-- of the table.++module Text.LaTeX.Packages.Multirow+ ( multirowp+ , BigStrutsCount(..)+ , multirow+ ) where++import qualified Data.Semigroup as SG ((<>))+import Data.Maybe (catMaybes)+import Text.LaTeX.Base.Syntax (LaTeX(TeXComm), TeXArg(FixArg, OptArg))+import Text.LaTeX.Base.Class (LaTeXC, liftL)+import Text.LaTeX.Base.Types (PackageName, Pos, Measure)+import Text.LaTeX.Base.Render (Render, render, rendertex)++-- | multirow package. Use it to import it like this:+--+-- > usepackage [] multirow+multirowp :: PackageName+multirowp = "multirow"++-- | Type of bigstruts count. It is mainly used if you’ve used the+-- bigstrut package. It is the total number of uses of bigstruts+-- within rows being spanned in a multirow.+data BigStrutsCount+ = BigStruts Int -- ^ Normal bigstruts+ | BigStrutsTop Int -- ^ Bigstruts in the top row+ | BigStrutsBottom Int -- ^ Bigstruts in the bottom row+ | BigStrutsTopBottom Int -- ^ Bigstruts in the top and bottom rows+ deriving (Show)++instance Render BigStrutsCount where+ render (BigStruts n) = render n+ render (BigStrutsTop n) = "t" SG.<> render n+ render (BigStrutsBottom n) = "b" SG.<> render n+ render (BigStrutsTopBottom n) = "tb" SG.<> render n++-- | 'multirow' sets a piece of text in a tabular or similar+-- environment, spanning multiple rows.++multirow :: LaTeXC l =>+ Maybe Pos -- ^ Optional vertical positioning of the text in the multirow block+ -> Double -- ^ Number of rows to span+ -> Maybe BigStrutsCount -- ^ Optinal total number of uses of bigstrut within the rows being spanned+ -> Measure -- ^ Width to which the text is to be set+ -> Maybe Measure -- ^ Optinal length used to raise or lower the text+ -> l -- ^ Actual text of the construct+ -> l+multirow mVPos nrows mBigstruts width mVMove =+ liftL (\l ->+ TeXComm "multirow" $ catMaybes [ fmap (OptArg . rendertex) mVPos+ , Just (FixArg . rendertex $ nrows)+ , fmap (OptArg . rendertex) mBigstruts+ , Just (FixArg . rendertex $ width)+ , fmap (OptArg . rendertex) mVMove+ , Just (FixArg l)+ ]+ )
Text/LaTeX/Packages/QRCode.hs view
@@ -14,7 +14,6 @@ , final ) where -import Text.LaTeX.Base (raw) import Text.LaTeX.Base.Syntax import Text.LaTeX.Base.Class import Text.LaTeX.Base.Render@@ -77,4 +76,4 @@ | otherwise = T.singleton c isSpecial :: Char -> Bool-isSpecial c = elem c ("#$&^_~% \\{}" :: String)+isSpecial c = c `elem` ("#$&^_~% \\{}" :: String)
Text/LaTeX/Packages/TikZ/PathBuilder.hs view
@@ -40,15 +40,12 @@ import Text.LaTeX.Base.Syntax (LaTeX) import Text.LaTeX.Packages.TikZ.Syntax import Control.Monad.Trans.State-#if !MIN_VERSION_base(4,8,0)-import Control.Applicative-#endif -data PathState = PS { currentPath :: TPath }+newtype PathState = PS { currentPath :: TPath } -- | Use a /path builder/ to construct a value of type 'TPath'. -- Use 'bpath' for this purpose.-data PathBuilder a = PB { pathBuilder :: State PathState a }+newtype PathBuilder a = PB { pathBuilder :: State PathState a } -- Instances @@ -73,16 +70,16 @@ -- | Line from the current point to the given one. line :: TPoint -> PathBuilder ()-line p = applyToPath $ (`Line`p)+line p = applyToPath (`Line` p) -- | Rectangle with the current point as one cornder and the given point -- as the opposite corner. rectangle :: TPoint -> PathBuilder ()-rectangle p = applyToPath $ (`Rectangle`p)+rectangle p = applyToPath (`Rectangle` p) -- | Circle with the given radius centered at the current point. circle :: Double -> PathBuilder ()-circle r = applyToPath $ (`Circle`r)+circle r = applyToPath (`Circle` r) -- | Ellipse with width and height described by the arguments and centered -- at the current point.
Text/LaTeX/Packages/TikZ/Syntax.hs view
@@ -151,7 +151,7 @@ -- point of @x@. deriving Show -data GridOption =+newtype GridOption = GridStep Step deriving Show
Text/LaTeX/Packages/Trees.hs view
@@ -1,18 +1,11 @@ -{-# LANGUAGE CPP #-}- -- | Tree definition with some class instances. module Text.LaTeX.Packages.Trees ( -- * Tree Tree (..) ) where -#if !MIN_VERSION_base(4,8,0)-import Data.Monoid-import Data.Foldable-import Data.Traversable-#endif-import Control.Applicative+import Control.Applicative (liftA2) -- | Tree datatype. data Tree a =@@ -29,4 +22,4 @@ instance Traversable Tree where sequenceA (Leaf fa) = Leaf <$> fa- sequenceA (Node mfa ts) = liftA2 Node (sequenceA mfa) $ sequenceA $ fmap sequenceA ts+ sequenceA (Node mfa ts) = liftA2 Node (sequenceA mfa) $ traverse sequenceA ts
license view
@@ -1,4 +1,4 @@-Copyright (c)2013, Daniel Díaz+Copyright (c)2023, Daniel Casanueva All rights reserved. @@ -13,7 +13,7 @@ disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Daniel Díaz nor the names of other+ * Neither the name of Daniel Casanueva nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission.
test/Main.hs view
@@ -1,15 +1,10 @@-{-# LANGUAGE CPP #-} import Text.LaTeX import Text.LaTeX.Base.Parser import Test.Tasty import qualified Test.Tasty.QuickCheck as QC--#if !MIN_VERSION_parsec(3,1,9)-instance Eq ParseError where- _ == _ = undefined-#endif+import Data.Either (isRight) main :: IO () main = defaultMain $ testGroup "HaTeX"@@ -21,8 +16,7 @@ \l1 l2 l3 -> l1 <> (l2 <> l3) == (l1 <> l2) <> (l3 :: LaTeX) ] , testGroup "Parser"- [ QC.testProperty "render . parse = id" $- \l -> let t = render (l :: LaTeX)- in fmap render (parseLaTeX t) == Right t+ [ QC.testProperty "isRight . parse . render" $+ \l -> isRight $ parseLaTeX (render (l :: LaTeX)) ] ]