Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to make Diagrams in AsciiArt style.

I've found Ditaa tool very usefull. I was happy to find, there is Eps output addoon for it.

What the easiest, but clear and elegant way (following KISS principle) do you suggest to

  • embed ditaa diagrams into Tex (LaTeX) documents?

Makefile with eps->pdf conversion and than including such pdf. Keep asciiart diagrams separated or integrate it somehow with Tex/LaTex (for asciidoc, I've found it easy).

I know it's more poweruser question, but related:

  • Unfortunatelly, I can figure out how to make it working with newest ditaa 0.9 (it's distributed with ditaa 0.6b)

I am new to group, so please forgive (kindly remind, I can delete it) if question is not appropriate.

I am Linux programmer, so command line, make, sed, awk and other tool can be combined.

share|improve this question
1  
Tikz can do a lot of great diagrams, too, natively! –  ℝaphink Aug 8 '11 at 13:16
1  
Simplest way (KISS) include the image as .png or .jpg with \includegraphics. –  Yiannis Lazarides Aug 8 '11 at 14:44
    
So, I would like to {\includegraphics}. But to have ditaa diagram embedded in TeX document, so while compiling it, picture is vectorized externally and resulting vector (DitaaEps) Eps version is included. –  Grzegorz Wierzowiecki Aug 8 '11 at 21:28
add comment

2 Answers

If you are an emacs user, you may consider using org-mode extension: http://orgmode.org/

I have been using org-mode for some to prepare documents and presentations in LaTeX/Beamer. You can use org-mode to generate both LaTeX files and html files.

To incorporate code from other languages (e.g. Python, Ruby, C++, ditaa, tikz, etc.), you will need to use the babel functionality: http://orgmode.org/worg/org-contrib/babel/
In particular, here, is an org-mode ditaa example from the babel extension.

share|improve this answer
    
I am Vim user - about org-mode, I've read on webpage. But thanks :). –  Grzegorz Wierzowiecki Aug 8 '11 at 21:18
1  
There is, from time to time, some talk on the org-mode mailing list about making a Vim clone. I believe some users have started such a project, for example the VimOrganizer, just FYI. –  cm2 Aug 8 '11 at 22:30
    
Thanks man. :). Even it's out of question , cause it doesn not solve vector rendering problem, it's interesting as editor tool :). –  Grzegorz Wierzowiecki Aug 10 '11 at 18:33
add comment

If you're interested in merely adding ascii-art diagrams to your document, you can dump the ascii-art content in the verbatim environment:

\documentclass{minimal}
​\begin{document}% Taken from http://ditaa.sourceforge.net/
\begin{verbatim}
    +--------+   +-------+    +-------+
    |        | --+ ditaa +--> |       |
    |  Text  |   +-------+    |diagram|
    |Document|   |!magic!|    |       |
    |     {d}|   |       |    |       |
    +---+----+   +-------+    +-------+
        :                         ^
        |       Lots of work      |
        +-------------------------+
​\end{verbatim}
\end{document}​​​​​​

The verbatim environment typesets its contents as-is using the \ttfamily font, keeping the alignment (whitespace).

Example of ditaa ascii-art code

If you're interested in a converted graphic/image (a ditaa-processed version of your ascii-art), then importing a PNG (or JPG/BMP) from your ditaa outpout would be easiest. This, however, comes with a loss of quality in the output. If the EPS add-on is readily available, then using it to produce EPS images (or even converted to PDF) would achieve the highest quality. Here's a graphic from the website illustrating the difference in quality when using rasterized vs vector graphics:

Difference in rasterized and vector graphics in ditaa output

Finally, TikZ/PGF and PStricks both provide a bounty of native drawing capabilities within (La)TeX. The TikZ/PGF documentation is filled with examples, as is many of the package documentations associated with PStricks. They each come with their own set of macros/commands that allow for drawing diagrams similar to those done by ditaa.

The advantage of using native packages as opposed to some external application (like ditaa) is that it provides the capability to alter an "image" within your (La)TeX code rather than using an external application as a stepping stone. Moreover, with (La)TeX being platform independent, such advantages of native programming add even more value.

share|improve this answer
    
I would like to use vector version of DitaaEps, but with Ditaa 0.9. –  Grzegorz Wierzowiecki Aug 8 '11 at 21:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.