diagrams-pgf: PGF backend for diagrams drawing EDSL.

[ bsd3, graphics, library ] [ Propose Tags ]

This package provides a modular backend for rendering diagrams created with the diagrams EDSL using the TeX library PGF.

Support for rendering LaTeX, ConTeXt and plain TeX files.


[Skip to Readme]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.0.4, 0.1.0.5, 1.4, 1.4.1, 1.4.1.1, 1.4.2, 1.4.2.1
Dependencies base (>=4.4 && <4.13), bytestring (>=0.9 && <1.1), bytestring-builder (<1.1), colour, containers (>=0.3 && <0.7), diagrams-core (>=1.4 && <1.5), diagrams-lib (>=1.4 && <1.5), directory (>=1.0 && <1.4), filepath (>=1.2 && <1.5), hashable (>=1.1 && <1.3), JuicyPixels, mtl (>=2.1 && <3.0), optparse-applicative (>=0.13 && <0.15), process (>=1.0 && <1.7), split (>=0.1.2 && <0.3), texrunner (<=0.0.2), time (>=1.2 && <1.10), vector, zlib [details]
License BSD-3-Clause
Author Christopher Chalmers
Maintainer c.chalmers@me.com
Revised Revision 2 made by BrentYorgey at 2018-11-12T18:02:42Z
Category Graphics
Home page http://github.com/cchalmers/diagrams-pgf
Bug tracker http://github.com/cchalmers/diagrams-pgf/issues
Source repo head: git clone http://github.com/cchalmers/diagrams-pgf
Uploaded by BrentYorgey at 2016-10-27T05:13:37Z
Distributions NixOS:1.4.2.1
Reverse Dependencies 2 direct, 25 indirect [details]
Downloads 6777 total (28 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2016-10-28 [all 1 reports]

Readme for diagrams-pgf-1.4

[back to package description]

PGF diagrams backend

diagrams-pgf is a PGF backend for diagrams. Diagrams is a powerful, flexible, declarative domain-specific language for creating vector graphics, using the Haskell programming language.

PGF is a TeX macro package for generating graphics. It is platform- and format-independent and works together with the most important TeX backend drivers, including pdftex and dvips.

diagrams-pgf is a work in progress, it supports the basic features of diagrams with the following features:

  • LaTeX, ConTeXt and plain TeX support
  • direct PDF generation using a TeX distribution (e.g. texlive) via texrunner.

Usage

A simple example that uses diagrams-pgf to draw a square.

import Diagrams.Prelude
import Diagrams.Backend.PGF.CmdLine

b1 = square 20 # lwG 0.05

main = defaultMain (pad 1.1 b1)

Save this to file named square.hs and compile this program:

ghc --make square.hs

This will generate an executable which, when run produces a TeX (or PDF) file. Run the executable with the --help option to find out more about how to call it.

$ ./square --help
square

Usage: square [-?|--help] [-w|--width WIDTH] [-h|--height HEIGHT]
              [-o|--output OUTPUT] [-f|--format FORMAT] [-a|--standalone]
              [-r|--readable] [-l|--loop] [-s|--src ARG]
              [-i|--interval INTERVAL]
  Command-line diagram generation.

Available options:
  -?,--help                Show this help text
  -w,--width WIDTH         Desired WIDTH of the output image
  -h,--height HEIGHT       Desired HEIGHT of the output image
  -o,--output OUTPUT       OUTPUT file
  -f,--format FORMAT       l for LaTeX, c for ConTeXt, p for plain
                           TeX (default: LaTeX)
  -a,--standalone          Produce standalone .tex output
  -r,--readable            Indent lines
  -l,--loop                Run in a self-recompiling loop
  -s,--src ARG             Source file to watch
  -i,--interval INTERVAL   When running in a loop, check for changes every
                           INTERVAL seconds.

If no output file is given, output is send to stdout. Supported outputs are .tex and .pdf. PDF generation is done using texrunner.

$ ./Square -o square.tex
$ cat ./square.tex
\begin{pgfpicture}
  \pgfpathrectangle{\pgfpointorigin}{\pgfqpoint{22.0000px}{22.0000px}}
  \pgfusepath{use as bounding box}
  \begin{pgfscope}
    \begin{pgfscope}
      \pgfpathmoveto{\pgfqpoint{21.0000px}{1.0000px}}
      \pgfpathlineto{\pgfqpoint{21.0000px}{21.0000px}}
      \pgfpathlineto{\pgfqpoint{1.0000px}{21.0000px}}
      \pgfpathlineto{\pgfqpoint{1.0000px}{1.0000px}}
      \pgfpathlineto{\pgfqpoint{21.0000px}{1.0000px}}
      \pgfpathclose
      \definecolor{sc}{rgb}{0.0000,0.0000,0.0000}
      \pgfsetstrokecolor{sc}
      \pgfsetlinewidth{0.0132mm}
      \pgfusepath{stroke}
    \end{pgfscope}
  \end{pgfscope}
\end{pgfpicture}

Typesetting

pgf-diagrams allows typesetting TeX commands and can calculate the corresponding envelope. See the hbox example to see how get envelopes of text:

hbox

Missing features

The following features are not currently supported:

  • selecting fonts (italic and bold work)
  • gradients