The diagrams-pgf package

[Tags:bsd3, library]

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]

Properties

Versions 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
Dependencies base (>=4.4 && <4.10), bytestring (>=0.9 && <1.1), bytestring-builder (<1.1), colour, containers (>=0.3 && <0.6), diagrams-core (==1.4.*), diagrams-lib (==1.4.*), 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.*), process (>=1.0 && <1.5), split (>=0.1.2 && <0.3), texrunner (<=0.0.2), time (>=1.2 && <1.7), vector, zlib [details]
License BSD3
Author Christopher Chalmers
Maintainer c.chalmers@me.com
Category Graphics
Home page http://github.com/cchalmers/diagrams-pgf
Bug tracker http://github.com/cchalmers/diagrams-pgf/issues
Source repository head: git clone http://github.com/cchalmers/diagrams-pgf
Uploaded Thu Oct 27 05:13:37 UTC 2016 by BrentYorgey
Updated Thu Dec 8 19:14:10 UTC 2016 by BrentYorgey to revision 1
Distributions NixOS:1.4
Downloads 714 total (30 in the last 30 days)
Votes
0 []
Status Docs available [build log]
Last success reported on 2016-10-28 [all 1 reports]

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Readme for diagrams-pgf

Readme for diagrams-pgf-1.4

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