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 was looking at recent questions here and was surprized that people were drawing diagrams in LaTeX, when it can be done in SmartDraw, OpenOffice or other programs. Is there any benefit to using LaTeX for diagrams (at least for normal diagrams like a layered architecture)?

share|improve this question
2  
I don't understand your question... Are you talking about a diagram on its own? Just do as you like, I guess. Are you referring to diagrams inside a document? If you are using LaTeX, why would you want to produce a diagram in openoffice? –  Anke Mar 15 '13 at 8:54
    
Welcome to TeX.sx! –  texenthusiast Mar 15 '13 at 8:57
1  
it's fun/freedom to choose diagram consistency,quality and flexibility(natural water) instead of bottled water. Of course you too have a choice to make. –  texenthusiast Mar 15 '13 at 9:09
2  
If the diagram has to be exact, or if you will be making many diagrams that are fairly similar, get a program to draw it and don't do it by hand. Such a program could be LaTeX with TikZ or Asymptote, or for more complicated stuff use a real programming language (Python, Perl, C++, C, etc.) and output a TikZ or Asymptote picture. Otherwise draw by hand (Inkscape or OpenOffice). –  Benjamin McKay Mar 16 '13 at 12:55
1  
show 1 more comment

6 Answers

up vote 49 down vote accepted

LaTeX diagrams can be directly inserted in your LaTeX document, while you need to export them from other programs, which needs to be repeated every time you change the diagram. A big benefit of drawing your diagrams in LaTeX is also that you can use the same fonts as in the rest of your document and also ensure that the text is properly scaled. In addition you can use all the benefits of the (La)TeX typesetting system, like the great math support. If you import your diagram from OpenOffice or a similar tool the font may be different and not properly scaled and while such tools can also handle math, the result may look different.

A further benefit is that you can code/program your diagrams in LaTeX. Especially TikZ and PSTricks allow for loops and conditionals. Coordinates can be directly given, which is a great benefit for technical diagrams. I, for example, had several ADC diagrams with a programmable step size in my PhD thesis and actually coded a general form of the document which a copied several times and then only adjusted internal variables to get a different number of curves with different step sizes. Such things are not possible with drawing tools and then take much more time. Another example is my tikz-timing package for timing diagrams. There you can just state the logic levels and the diagram is drawn automatically. Before I wrote this package I got told to draw it manually using MS Visio, which is IMHO a pain, especially if you need to change the diagram later.

Drawing the diagrams using a drawing program might be quicker in some cases, especially if you are new to LaTeX, but usually the LaTeX diagrams looks better and is more consistant as a manual drawn one.

share|improve this answer
    
well done Martin. One more thing I recall is when your diagram has citation in it. Suppose you draw a Taxonomy that has several number of efforts. If we draw that outside the LaTex, we should put citations manually and for each change we should do all manual changing and modification. But, to novice latex lovers, it would be painful to start coding. Is there any tool to facilitate drawing in LaTex? –  Espanta Mar 15 '13 at 11:10
    
@Espanta -- There are export programs like inkscape2tikz. I suspect that the exported code is a very literal representation of the inkscape drawing, which might make turning it into 'programmable' code very difficult, but for one-off drawings, this might be a good approach. –  jon Mar 15 '13 at 13:03
1  
One more thing that doesn't warrant an answer on its own: LaTeX diagrams, being text files, are much more amenable to version control (of course you can add binary files to a version-control system as well; but most times you can't use the whole array of available functionality such as diffs and merges). –  Luigi Ballabio Mar 15 '13 at 14:34
add comment

To enforce Martin's answer, I would say that nowadays there are lots of specific drawing packages which are of help since:

  1. some of them cover a specific topic; for example pgfplots allows to draw plots, circuitikz circuits, tikz-cd commutative diagrams, sa-tikz switching architectures, bohr Bohr models;
  2. others provide facilities to make simpler for the user the drawing phase; for examples, in order to draw trees, one might use forest, tikz-qtree, qtree, xytree or just TikZ/PGF and to draw diagrams one might stand on fast-diagram, flowchart and smartdiagram.

Both lists are just examples I know: there are even more, also the ones belonging to the PSTricks family.

Having such a choice is very helpful: if one needs to do a specific thing, very likely he can find a package ready. This allows to reduce the time needed to find some pre-existing drawings to start with and all the relative stuff (are there some specific rules/conventions to be respected? is such an example valid or not?). Indeed, the specific packages are developed to respect specific rules/conventions (when there are) and, since there are lots of examples, it is very easy to start with. Consider, as a starting point, to have a look to some tags here: , , and .

Notice also that, adopting TikZ, there's the possibility to easily make animation in Beamer presentations; a practical example with sa-tikz: you find the code on http://cfiandra.github.com/Sa-TikZ/.

enter image description here

To make more clear this concept, here is an example with smartdiagram. Just changing a command makes the same diagram animated or not:

enter image description here

The interaction Beamer-TikZ really helps in save time since very often a TikZpicture from a standard document just needs few processing to be animated.

The code of the previous diagram:

\documentclass{beamer}
\usepackage{lmodern,smartdiagram}
\smartdiagramset{set color list={
  green!40!lime!80!black,
  cyan!80!blue,
  orange!50!red,
 },
 sequence item border color=gray!30!black,
}

\begin{document}
\begin{frame}[fragile]
\footnotesize{\verb!\smartdiagram[sequence diagram]{Select Style,Edit,Use}!}

\begin{center}
\smartdiagram[sequence diagram]{Select Style,Edit,Use}
\end{center}

\begin{center}
\smartdiagramanimated[sequence diagram]{Select Style,Edit,Use}
\end{center}

\footnotesize{\verb!\smartdiagramanimated[sequence diagram]{Select Style,Edit,Use}!}
\end{frame}
\end{document}
share|improve this answer
1  
Thank you Claudio, comprehensive and convincing. –  Espanta Mar 15 '13 at 17:46
add comment

The main advantages of drawing with LaTeX are consistency, control, development, and maintenance. In the following I'm asuming you're using TikZ.

  • The typeface in your pictures will be the same as that of the running text. (consistency)
  • The regular type size in the pictures will be the same as that of the running text. (consistency)
  • TikZ provides two ways to scale your pictures. One of them only scales the distance beteen the entities in the drawing but doesn't affect the type size and the line width. (consistency)
  • You can use styles to control the appearance of the entities in your pictures. For example, you can use a special line type to make certain elements stand out. Tha advantage is that you have a well-understood API, which is easy to use. You only have to implement the style once, and reuse it several times. (control, consistency, development)
  • You can develop/refine the styles. For example, if you haven't thought about the exact style for certain line elements, you can start with a rough style and start using the style. Later, you can refine the style and this will have a global effect. (control, maintenance, development)
  • If you decide you want to change the appearance of a certain type of line elements, you only have to change the definition on the style of the line type and this will have a global effect. (maintenance)
  • You can draw pictures incrementally. For example, when using beamer you can create a presentation that draws a complex diagram in steps. Rather than having one different drawing for each step, you can use beamer's incremental presentation tools and annotate which things should be drawn on which slide. (control)
  • You can use labels to reference positions in the drawing. This makes it easier to maintain your drawing. For example, if you decide to move a labelled node in the drawing all you have to do is change the node's position and all references to the node's label will still work properly. (maintenance)
  • TikZ provides relative and incremental coordinates, which let you define points relative to other points. Defining your pictures in terms of these coordinates makes it easier to maintain your pictures. For example, if you want to move a shape that's drawn with relative/incremental coordinates to a different position, all you have to do is change one coordinate (the one which the other coordinates are relative to). (maintenance)
  • TikZ separates the appearance and the content/structure of certain elements in your pictures. For example, a tree is a node with children. Each child is a leaf or a node with children. You define the structure of the tree in terms of nodes and children. The appearance of the tree is controlled with a style. Developing a drawing using techniques like this reduces errors and increases the consistency of your drawing. (development, mainentance)
share|improve this answer
    
Would you be so kind to mention how to go about point 7? (drawing pictures incrementally using beamer). I'm guessing you somehow use overlay specifications? As of now I am using this hack, which isn't very elegant. –  MHaaZ Jul 10 '13 at 17:03
    
@MHaaZ The question was more about the what, not about the how. If I start expanding on item 7 and explain how to do this, I feel the answer would be out of balance. FWIW most command take an optional argument for overlay specifications. E.g. \draw<2> ....; will only draw on slide 2. You can also use \only<3-5>{ .... }. Does that help? –  Marc van Dongen Jul 11 '13 at 10:27
    
I wasn't suggesting you modify your answer, but looking for exactly the kind of hint in the comments you have given me :) I didn't know TikZ drawing commands were overlay-specification-aware. Haven't found any reference to it on the TikZ nor beamer manuals yet... The only difficulty with doing that is that the incremental stages of the drawing will be positioned differently because they have different dimensions on every slide... –  MHaaZ Jul 15 '13 at 18:37
    
@MHaaZ Yes, you are right about the problem with the different sizes. I usually overcome this by defining some tight rectangle that encloses all the material on all the slides. \path (ll) rectangel (ur); –  Marc van Dongen Jul 17 '13 at 10:27
add comment

Martin and Claudio have made good points for coding figures in LaTeX, so I'd like to take the other stance and offer some tricks to help :)

I mostly use OmniGraffle to prepare figures; I consider that figures (like presentations) are visual artifacts and that its better to design them in a visual way. TikZ and Beamer are biased towards what's easy to express in code or using third-party packages, and so you might make compromises in shapes, or in placing elements in relation with their neighbors, that you just would not have to think about in a visual editor.

I tend to be very picky in the curves of arrows, of text, the distribution of negative space, and I often need to tweak nearly each element. There is no simple law for those tweaks, as it follows optical and subjective visual qualities.

Now of course, there are still the objections about font consistency, typesetting text to match the document, and exporting the graphics, but I have a few workarounds:

  • About font consistency, thankfully most documents I prepare are for scientific publications where the main fonts are often Times and Helvetica. Easy to pick the same font as the document.

  • For typesetting text or math, I can always use the great LaTeXit or the standalone package. It's imperfect because it requires to copy-paste if you change the text or math, but luckily I don't do that many figures with math.

  • For exporting, I configured Latexmk to automatically export the figures as needed from OmniGraffle. This is what really makes the whole approach viable for me.

share|improve this answer
    
yes, this is also feasible. –  Espanta Mar 15 '13 at 17:49
add comment

I don't know the exact graphical features of OpenOffice \& Co, but using LaTeX to do the diagrams allows you to literally 'program' the diagrams. I really like to use MS Excel to gather some facts and then to create the TeX/TikZ code using a few basic Excel functions. I doubt that OpenOffice features this.

See for example http://uweziegenhagen.de/?p=2488 where I created learning materials that can be switched between the show-answers and the dont-show-answers version with just a single word (draft).

This kind of templating is why I love LaTeX!

share|improve this answer
    
Open office is a simple drawing tools with very limited but simple features. It is very good for drawing layered architectures, taxonomy and so on. However, currently open office does not have any coding, as far as I know. Enough reasons I guess to start working on diagrams in LaTex. –  Espanta Mar 15 '13 at 11:11
add comment

If you can draw then that's great, good for you. But I cannot. For instance, I needed a diagram of a parallelogram generated by two first-octant vectors in three dimensions. I told the drawing program the coordinates, and instructed it to draw. The result looks perfectly acceptable and I was on to the next thing.

share|improve this answer
    
If you only have to draw one diagram them this should be fine but if you need several, then you'll soon end up in a big mess. For example, changing the style/size of your pictures requires n editing operations, where n is the number of diagrams. –  Marc van Dongen Mar 16 '13 at 12:55
    
Marc, I'm not sure if you are talking to me but I use Asymptote and import a style with thickness of the lines for vectors, arrow types, etc. –  Jim Hefferon Mar 17 '13 at 20:47
    
thanks guys. I think using different features of LaTex goes somehow to authors' need. I so far have never required to draw a dynamic diagram like the Benes network. This is the fact that needs make development. The most important thing to me is to accomplish the task with minimum effort ,time and highest accuracy and quality. Surely, this question and series of answers will help a lot of novice LaTexers to learn and decide what to do and not to do with LaTex. –  Espanta Mar 18 '13 at 2:38
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.