diagrams / diagrams-builder

Utilities for creating diagram-building tools
Other
12 stars 15 forks source link

LaTeX package for embedded diagram code #1

Closed fryguybob closed 11 years ago

fryguybob commented 12 years ago

(Imported from http://code.google.com/p/diagrams/issues/detail?id=44. Original issue from byor...@gmail.com on September 2, 2011, 08:00:47 PM UTC)

It would be super-cool to provide a LaTeX package which allows you to embed diagrams code directly in a LaTeX document and have it rendered as part of the final output, without needing a preprocessor. In order to do this we need a command-line tool for turning diagrams code into images; see Issue 43.

I believe Ryan knows how to do this...

fryguybob commented 12 years ago

(Imported. Original comment by fryguy...@gmail.com on January 4, 2012, 04:21:23 PM UTC)

I have this working in my LaTeXGrapher project. TeX files look like this:

http://www.patch-tag.com/r/fryguybob/LaTeXGrapher/snapshot/current/content/pretty/tex/test.tex

and they can be built with:

$ pdflatex --shell-escape test.tex

The latexgrapher.sty works by treating the latexgrapher environment as a verbatim environment streaming that out to a temporary file then using the shell escape to compile that file with LaTeXGrapher and then run epstopdf. The latexgrapher environment is then expanded to an \includegraphics{...}. The style is not particularly complicated (heavily based on dot2texi.sty by Kjell Magne Fauske).

http://www.patch-tag.com/r/fryguybob/LaTeXGrapher/snapshot/current/content/pretty/tex/latexgrapher.sty

It should be easy to generalize this so that one style file could define the processing "pipeline" for a block of verbatim text. More complicated things that might be interesting would be showing code in listings along with the images and passing multiple blocks to an image building process but passing an additional value to distinguish which block is being processed (so you could have a later diagram using some previously defined parts). This might be best as a two pass process.

I think all of this should be fairly easy to do but it would be nice and somewhat safer if we have a diagrams tool that could take a file and an identifier (or possibly expression) and generate the output for that diagram.

fryguybob commented 12 years ago

(Imported. Original comment by fryguy...@gmail.com on January 4, 2012, 04:40:28 PM UTC)

The output from the test file mentioned can be found here:

http://www.cs.rochester.edu/u/ryates/temp/test.pdf

fryguybob commented 12 years ago

(Imported. Original comment by byor...@gmail.com on January 4, 2012, 06:30:34 PM UTC)

Cool!

"I think all of this should be fairly easy to do but it would be nice and somewhat safer if we have a diagrams tool that could take a file and an identifier (or possibly expression) and generate the output for that diagram."

-- I agree, and it should be easy to make such a tool for any particular backend (in fact, I essentially already have something very close to it for cairo). My difficulty was in coming up with a backend-agnostic way to do it. But perhaps I should not let perfect be the enemy of good and just package it up for cairo, and maybe we can figure out how to generalize it later.

fryguybob commented 12 years ago

(Imported. Original comment by byor...@gmail.com on March 12, 2012, 02:58:34 AM UTC)

Note that we now have the diagrams-builder project (http://www.patch-tag.com/r/byorgey/diagrams-builder). We still need to create an executable version of diagrams-builder (for a specific backend) that could be used by a LaTeX package.

byorgey commented 11 years ago

This is now done. See https://github.com/diagrams/diagrams-builder/blob/master/latex/diagrams-latex.sty and http://byorgey.wordpress.com/2012/08/28/creating-documents-with-embedded-diagrams/ .