4

Here's a nifty question! I would like to create a similar diagram to the one below, but I do not have the slightest clue how. Latex is all very new to me but I have managed to use Tikz to scribe number lines and basic commutation diagrams. Any answer will be gratefully received.

enter image description here

  • 3
    Your actual code will be gratefully received. Because it's easier for us to copy some code and start editing than start from zero. Also so that we know that you tried something rather than come here to ask us to make you that drawing. – Manuel Mar 11 '14 at 15:57
  • Yow! I'm not meaning to leach off the Latex community here! I've tried looking at similar questions on the stack exchange but my manipulation of the code has resulted in error after error. Like I said I'm new to latex, reaching the week and a half anniversary now baby!!! – user47753 Mar 11 '14 at 16:05
  • Put your wrong code we can fix it for you. But starting from scratch is not fun. – percusse Mar 11 '14 at 16:09
  • 1
    ...we call that a minimal working example (MWE), although it may not always require the "working" part. – Werner Mar 11 '14 at 16:13

2 Answers2

8

Using polar relative coordinates it is easy to build a path in a triangular grid, such as:

\draw    (0,0) -- ++(0:1) -- ++(120:1) -- ++(0:1) -- 
    ++(-120:1) -- ++(0:1) -- ++(120:2);

Each coordinate is given in the form (angle:distance) relative to the previous one (this is what ++ is for). This draws the path:

simple path

Using again polar relative coordinates we can add some "big dots" at strategic places:

\filldraw (0:0) circle(2pt) ++(0:2) ++(120:1) circle(2pt);

giving:

simple path with dots

Now we have the basic building block of your figure. Simply repeat it six times, rotating 60 degrees each time. This is the complete code:

\begin{tikzpicture}
\foreach \angle in {0,60,...,300} {
  \begin{scope}[rotate=\angle]
  \draw (0,0) -- ++(0:1) -- ++(120:1) -- ++(0:1) -- ++(-120:1)
        -- ++(0:1) -- ++(120:2);
  \filldraw (0:0) circle(2pt) ++(0:2) ++(120:1) circle(2pt);
  \end{scope}
}
\end{tikzpicture}

Result

The labels can be easily placed using again polar coordinates. This is left as exercise to the reader ;-)

JLDiaz
  • 55,732
3

There are of course many different ways to get diagrams into TeX documents. Here is a version of the diagram drawn with Metapost (follow the link if interested).

enter image description here

prologues := 3;
outputtemplate := "%j%c.eps";

beginfig(1);

r := 4cm;
path hexagon; 
hexagon = for theta = 0 step 60 until 359: right scaled r rotated theta -- endfor cycle;

draw hexagon;
for i = 0 upto 2: 
  draw point  i     of hexagon -- point  i+3   of hexagon; 
  draw point 2i+1/2 of hexagon -- point 2i+5/2 of hexagon;
  draw point 2i+3/2 of hexagon -- point 2i+7/2 of hexagon;
endfor

dotlabel.urt (btex $L_1-L_3$ etex, point  1/2 of hexagon);
dotlabel.top (btex $L_2-L_3$ etex, point  3/2 of hexagon);
dotlabel.ulft(btex $L_2-L_1$ etex, point  5/2 of hexagon);
dotlabel.llft(btex $L_3-L_1$ etex, point  7/2 of hexagon);
dotlabel.bot (btex $L_3-L_2$ etex, point  9/2 of hexagon);
dotlabel.lrt (btex $L_1-L_2$ etex, point 11/2 of hexagon);

fill fullcircle scaled 3; 
label("0",right scaled 10 rotated 30);

endfig;
end.

Notes: The first thing defined is a variable r for the radius. It's often easier to define your drawing relative to one key dimension. Then we define a hexagonal path; note how MP lets you put a for loop inside an assignment.

Because we defined the path with six hops it is six units long and we can use the point x of path syntax to refer to all the other points we need. And as you can see we are not confined to whole numbers.

The dotlabel macro is convenient for the six outer labels, but because of the grid, the label for the origin needs to be done separately.

Thruston
  • 42,268
  • The OP is welcome to leach (or possibly learn) as much as he or she likes from this example, by the way. I'm quite happy to give 15 mins or so of my time to this useful site. – Thruston Mar 13 '14 at 11:07