diagrams-pgf-0.1.0.3: PGF backend for diagrams drawing EDSL.

Copyright(c) 2015 Christopher Chalmers
LicenseBSD-style (see LICENSE)
Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellNone
LanguageHaskell2010

Diagrams.Backend.PGF.Surface

Contents

Description

A Surface defines how a pgfpicture should be placed and compiled. Surfaces are used for rendering a .tex or .pdf using functions from PGF.

Surfaces are also used in Hbox for querying envelopes of text.

Surfaces for Latex, Context and plain Tex are provided and reexported by Diagrams.Backend.PGF. Lenses here allow these to be adjusted as required.

Synopsis

Surface definition

data Surface Source

Constructors

Surface 

Fields

_texFormat :: TexFormat

Format for the PGF commands

_command :: String

System command to be called.

_arguments :: [String]

Auguments for command.

_pageSize :: Maybe (V2 Int -> String)

Command to change page size from dimensions of image. (in bp)

_preamble :: String

Preamble for document, should import pgfcore.

_beginDoc :: String

Begin document.

_endDoc :: String

End document.

Instances

data TexFormat Source

The TexFormat is used to choose the different PGF commands nessesary for that format.

Constructors

LaTeX 
ConTeXt 
PlainTeX 

Online rendering with surfaces

surfOnlineTex :: Surface -> OnlineTex a -> a Source

Get the result of an OnlineTex using the given surface.

surfOnlineTexIO :: Surface -> OnlineTex a -> IO a Source

Get the result of an OnlineTex using the given surface.

Predefined surfaces

latexSurface :: Surface Source

Default surface for latex files by calling pdflatex.

Sample output

command: pdflatex

% preamble
documentclass{article}
usepackage{pgfcore}
pagenumbering{gobble}

% pageSize
pdfpagewidth=100bp
pdfpageheight=80bp
textheight=80bp
pdfhorigin=-76.6bp
pdfvorigin=-52.8bp

% beginDoc
begin{document}

<Latex pgf code>

% endDoc
end{document}

contextSurface :: Surface Source

Default surface for latex files by calling pdflatex.

Sample output

command: context --pipe --once

% preamble
usemodule[pgf]
setuppagenumbering[location=]

% pageSize
definepapersize[diagram][width=100bp,height=80bp]
setuppapersize[diagram][diagram]
setuplayout
  [ topspace=0bp
  , backspace=0bp
  , header=0bp
  , footer=0bp
  , width=100bp
  , height=80bp
  ]

% beginDoc
starttext

<Context pgf code>

% endDoc
stoptext

plaintexSurface :: Surface Source

Default surface for latex files by calling pdflatex.

Sample output

command: pdftex

% preamble
input eplain
beginpackages
usepackage{color}
endpackages
input pgfcore
deffrac2{{begingroup 2}}nopagenumbers

% pageSize
pdfpagewidth=100bp
pdfpageheight=80bp
pdfhorigin=-20bp
pdfvorigin=0bp

% beginDoc


pgf code

% endDoc
bye

Lenses

texFormat :: Lens' Surface TexFormat Source

Format for the PGF commands.

command :: Lens' Surface String Source

System command to call for rendering PDFs for OnlineTex.

arguments :: Lens' Surface [String] Source

List of arguments for the command.

pageSize :: Lens' Surface (Maybe (V2 Int -> String)) Source

Specify the page size for the tex file.

preamble :: Lens' Surface String Source

Preamble for the tex document. This should at least import pgfcore.

beginDoc :: Lens' Surface String Source

Command to begin the document. (This normally doesn't need to change)

endDoc :: Lens' Surface String Source

Command to end the document. (This normally doesn't need to change)