Quick Diagrams with SmartDiagrams

It all started with a question on TeX.SX: Namely, is there any quick way to draw diagrams from a list of items, similar to the ‘Smart Art’ feature in PowerPoint 2010?

It wasn’t long before the package smartdiagram was born as a response, using TikZ to do the actual drawings. The basic syntax is:

\usepackage{smartdiagram}
\smartdiagram[diagram type]{list of comma-separated items}

Here are some examples (based on material from here):

\smartdiagram[circular diagram]{Assess,Plan,Implement,Renew}

\smartdiagram[flow diagram]{Assess,Plan,Implement,Renew}
\smartdiagram[buggle diagram]{Planning Cycle,Assess,Plan,Implement,Renew}

If you happen to be preparing a Beamer presentation, replacing the \smartdiagram command with \smartdiagramanimated will result in an automatically ‘animated’ diagram, with each item in the list appearing one at a time as you advance through the slides:

See the manual for other digram types and customisation options (colours, shapes, sizes, etc).

DIA + Lyx

Before I discover DIA, I used Microsoft Visio for schematic drawing to be included into my documents. The schematic drawn has to be exported into a graphic file, in which I prefer .png format. Then only it can be included in .tex document as a graphic.
Then I found DIA. You can search the web for more info on the software itself. In short, it is an open source software Lyx as well. What I found to be helpful is that, DIA has an extension to convert .dia files, where you save the schematic drawing, into graphic files in the format of .png which can be called directly by Lyx.
What I have to do is, draw whatever schematic that I want, save it in .dia format. Then in Lyx, insert the graphic as usual. At the graphic file name field, insert the .dia file name. Lyx will treat that as the graphic file where you can resize etc. similar to any graphic files included using the method. 
Another setting to be done is that to let Lyx know where to fine the DIA extension to convert .dia file to .png file so that Lyx can call it upon generating final document. The setting can be found under menu Tools > Preferences and under File Handling > Converters tab. Under From format pulldown menu, search for DIA and under To format pulldown menu, search for PNG. In Converter field, insert this
dia -e $$o -t png $$i

and click Add button. That is it. Now you can use .dia file directly to include graphic into you document. Happy trying. See you soon.

Diagramming Applications

This post answers the question

So how do I create high-resolution line drawings for use in LaTeX? Journal publishers request PDF or EPS with at least 800dpi.

Najmi’s post on Drawing diagram; the cryptic way covered tikz, ditaa and graphviz. (I myself swear by tikz.) However these may be too geeky for most people’s tastes. So here’s a list of free, open source, GUI-based diagramming applications that can produce PDF or EPS files.

  • OpenOffice Draw is a diagramming/drawing program that can save to PDF format. It’ a part of the OpenOffice suite. Personally I find it a bit clunky, but if you already have OpenOffice and don’t want to install new programs, it’ a good choice. Available on Linux and Windows. Mac users should look for NeoOffice instead.
  • Dia is an old favorite among Linux users, but some people might think it looks a bit rough. It does a very good job, though, with lots of elements and icons for UML diagrams, networking diagrams, ciruits, etc, etc etc. Dia supports saving to EPS files, and is available for Linux, Windows and Mac.
  • yEd. You know, I actually like yEd. A lot. The interface is easy to use, and there are also elements for UML, “people”, machines and more — in colour. (There’s even an iPod icon!) The output it produces does look more modern and polished then Dia. yEd supports saving to SVG, EPS and PDF, and is available on Linux, Windows and Mac.

Migrating to LaTeX: Producing High-resolution Line Drawings

Recently I was asked this question by not 1, but 3 people, so I guess that makes for a valid blog post!

I’m now migrating my paper/presentation to LaTeX from Microsoft Word/Powerpoint. It feels great! But is there any way I can transfer my existing line drawings over as high-resolution PDF or EPS? The publisher is asking for 800-1200 dpi.

Of course you can. I’ll outline what has worked for me below.

As for the question

So how do I create high-resolution line drawings for use in LaTeX if not the drawing tools in Word?

See the posts on Diagramming Applications and Drawing diagram; the cryptic way instead.

Mac OS X 10.5 Preview

If you’re on a Mac, first print your drawing diagram as a PDF. Open the PDF in Preview. Click the Select button on the Toolbar, and draw a rectangle around your drawing diagram. Then go to Tools menu and select Crop, or just hit Command-K. Save your cropped drawing back as a PDF.

OpenOffice Draw

If you have OpenOffice, you can try copying-and-pasting your drawing objects over to OpenOffice Draw, change the page size (Format > Page…) to fit the drawing just right, then export the drawing to PDF. However, elements and formattings often get distorted when copied over to OODraw, so personally I’d go for the procedures described next.

PDF Freeware Tools

Disclaimer: The tools described in this section are mainly for use in Windows, and are free-of-charge, but not all are open source.
Big thanks to Kevin Klement for pointing me toward PDFCreator and BRISS, true FOSS solutions!

Convert Your Drawing to PDF
First get PDFCreator. Once installed, you will be able to produce PDF out of any documents that is printable.

In your Word or Powerpoint document, select/highlight your line drawing, and go to File > Print. Choose “PDFCreator” as your printer, and select “Selection” or (“Current Page”) as the page range. You should also open the Print Properties, click on the Advanced button, and make sure that Print Quality is set to a sufficiently high dpi (e.g. 1200).

Click OK to print, and you will be prompted to enter any metadata (author, title, etc) you would like about the PDF. Save the PDF. You now have a high-resolution line drawing PDF, but it needs to be cropped to remove the surrounding white space.

First, install PDF995. You’ll need the 2 files from Pdf995 2-Step Download, i.e. the “Printer Driver” and the “Free Converter”. (A warning though: PDF995 is adware.)

In your Word or Powerpoint document, select/highlight your line drawing, and go to File > Print. Choose “PDF995” as your printer, and select “Selection” as the page range.

When you click OK you will be asked to enter a file name to save your PDF to. Bear with the annoying advertisement that pops up for 10 seconds.

Cropping Your PDF
You have a few choices.

  • Photoshop. If you’re one of the lucky souls to have a copy of Photoshop, you can use it to do the job. Just remember to set the Resolution to 800 or 1200 when you open the PDF in Photoshop. Crop, and then save the file back as PDF.
  • GIMP. But chances are that you don’t have Photoshop. GIMP can also open PDF files, and you’ll also be able to specify a sufficiently high resolution when you open it and then crop it. However, while GIMP can save it as an EPS (fine if that’s what you need), it cannot save/export to PDF format. And GIMP rasterises the file before saving (as Kevin pointed out), which defeats the purpose, really. So the winner really goes to…
  • BRISS, which needs a JRE to run. Unzip the BRISS zip file, and double-click on briss-.jar to launch. Load your diagram drawing PDF file, and draw a rectangle around the drawing objects. Click Crop PDF, and you’re done after saving the file.
  • PDF-cropper. You will need .NET 3.5 and GhostScript, so download and install those first before installing PDF-cropper.

    (Theoretically, you can use the GhostScript on command line to crop your PDF, but that involves figuring out the crop box and margins yourself, which I suspect not many people enjoy. Hence PDF-copper.)

    In PDF-cropper, go to the Configure menu and set the path to GhostScript binaries (usually C:\Program Files\GS\GS8.6x\bin), as well as your fixed output folder. Now load all your PDF files containing your drawings (PDF-cropper processes them by batch.) You can choose to crop off all surrounding white space around your drawings, or leave 5mm or 10mm space around them. Click the Action button, and the automatically cropped PDFs will be saved in the fixed output folder you specified.

Congratulations, you should now have high-resolution line drawings in PDF (or EPS) format, that are suitable for journal publication. Now just to include them in your LaTeX file with \includegraphics[width=...]{filename}.

Drawing diagram; the cryptic way

Well, this is not-so-latex stuffs, but I just want to share with you guys…

I managed to tried out 3 applications:

Let’s see for Tikz;

%modified from texample.net
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{mindmap,trees}
\usepackage{verbatim}

\begin{document}
\pagestyle{empty}

\begin{tikzpicture}
\path[mindmap,concept color=red!50!black,text=white]
node[concept] {Hidup}
[clockwise from=0]
child[concept color=green!60!blue]
{
node[concept] {Pertimbangan}
[clockwise from=90]
child { node[concept] {cari duit} }
child { node[concept] {buat amal ibadat} }
child { node[concept] {belajar sungguh-sungguh} }
child { node[concept] {bina keluarga bahagia} }
}
child[concept color=orange] {
node[concept] {research}
[clockwise from=-30]
child { node[concept] {jurnal} }
child { node[concept] {artikel} }
};
\end{tikzpicture}\end{document}

will produce

then how about ditaa;

Raw source snapshot:


will produce:


and finally graphviz;

Source, the “dot” file:

digraph process{
node [color=blue,fontcolor=black,font=helvetica,]
nodesep=1.5
A[label=”Machine Object (MO)”]
B[label=”Portable Object (PO)”]

C[label=”developer”]
D[label=”translator”]
E[label=”tools”]
F[label=”POedit”]
G[label=”kbabel”]

C->B[label=”prepares PO”,style=dashed]
C->A[label=”compiles MO”,style=dashed]
C->B->D [label=”send PO files/i18n”,fontcolor=red]
D->B->C[label=”return translated files/l10n”,fontcolor=green ]
D->E[label=”translate using”,fontcolor=blue,style=dashed]
E->F
E->G
}

returns;