MyNixOS website logo
Description

PGF backend for diagrams drawing EDSL.

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.

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.
Metadata

Version

1.4.2.1

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows