So I drew a few isosceles triangles aligned to each other with one being upside down but that upside down triangle created unwanted behavior (its corners started sticking out of line). All these triangles have same apex angle and same minimum size, which I (wrongfully) thought would be enough to eliminate inconsistencies between them.




{   calc,

    \begin{tikzpicture}         % BEGIN DEFINING OPTIONS
    [   every isosceles triangle node/.style=
        {   draw,
            inner sep=0mm,
            isosceles triangle apex angle=60,
            minimum size=20mm,
            outer sep=0mm,
            shape border uses incircle
        ,spy using outlines=    % SPY LINE; MARK NEXT LINE (PROBLEM WITH FORMATTING)
        {circle,                % SPY LINE; NO SPACE ALLOWED BETWEEN "{" AND "circle"?
            magnification=20,   % SPY LINE
            size=2cm,           % SPY LINE
            connect spies       % SPY LINE
        }                       % SPY LINE
    ]                           % END DEFINING OPTIONS

    \path node
    [   isosceles triangle,
        shape border rotate=90

    \path node
    [   isosceles triangle,
        shape border rotate=90,
        below=0mm of T_1.left corner,

    \path node
    [   isosceles triangle,
        shape border rotate=-90,
        right=0mm of T_2.apex,
        anchor=right corner

    \spy[red]on(T_3.right corner)   % SPY LINE
        in node at(3,0);            % SPY LINE



I was going to ask only this question but while formatting the code for submission, and adding spy functionality to zoom in on problematic area, I ran into a separate issue. As you might have noticed, I have a "MARK NEXT LINE (PROBLEM WITH FORMATTING)" comment in my code. For some reason I couldn't put space between "{" (opening brace) and the word "circle" which affected, although not much, the formatting of the code. I would like (if you will) to know why. The error message I have is

Package pgfkeys Error: I do not know the key '/tikz/ circle' and I am going to ignore it.
Perhaps you misspelled it.
  • 1
    Sometimes the TikZ parser strips spaces for you, but not always. There is no shape ` circle`. However, I'm guessing as you didn't include the text of the error message in your question. – cfr Sep 4 '17 at 1:45
  • I said sometimes. Here, it probably doesn't. – cfr Sep 4 '17 at 2:01
  • 1
    You can't get the triangles to fit perfectly in the way you want because you aren't taking account of the width of the lines. Either you have a double line width where the top one meets the bottom one - and their bases perfectly align - or you don't - and their bases don't align perfectly. But if you have a double line width, you have to adjust for the second upright triangle, too. – cfr Sep 4 '17 at 2:03

As the error message makes clear, TikZ looks for circle and there is no such shape. In some cases, spaces get trimmed away, but not always and not here. The parsing is, to say the least, complex, and the result cannot always be what you'd intuitively expect since that would cause less intuitive behaviour elsewhere. Generally, it does a pretty good job, but sometimes you need to remember that it is, after all, code and precise syntax matters.

The peculiar spy result is a function of the placement method used by TikZ and the non-zero line widths, combined with a disjunctively-drawn border path.

That is, the trouble is that your plan for tessellation does not take account of the line widths. Either you get gaps or bits jut out. Moreover, imprecision will make for raggedness anyway if you don't draw closed paths. You have closed paths around each shape, but not the borders of the combination.

One way around this is to draw the borders after creating the nodes. For example,

    every isosceles triangle node/.style={%
      inner sep=0mm, isosceles triangle apex angle=60, minimum size=20mm, outer sep=0mm, shape border uses incircle
    spy using outlines={%
      circle, magnification=20,  size=2cm, connect spies,
  \begin{scope}[every node/.append style={isosceles triangle}]
    \node [shape border rotate=90] (T_1) {};
    \node [anchor=right corner, shape border rotate=-90] (T_3) at (T_1.left corner) {};
    \node [anchor=apex, shape border rotate=90] (T_2) at (T_1.left corner) {};
  \draw (T_1.apex) -- (T_1.right corner) -- (T_3.apex) -- (T_2.left corner) -- (T_2.apex) edge (T_3.apex) edge (T_1.right corner) -- cycle;
  \spy[red]on(T_3.right corner) in node at(3,0);

tidier triangles

  • Is there a way to loop through these anchors while drawing lines to/from them instead of manually referencing each separately? – bp2017 Sep 4 '17 at 4:25
  • 1
    @bp2017 See 'Repeating things' in the manual for details of \foreach. But I don't think a loop really makes sense here as there aren't many of them. – cfr Sep 4 '17 at 13:00

It appears to me that the only issue with the triangles is that the line join is "miter join," and for that sort of line join on an acute angle (which this is), the very corner point sticks out beyond the 1/2-linewidth disk around the corner. I don't know whether your package allows you to change this, but all it would take in Illustrator/PostScript/etc. would be to set the line join to rounded instead or miter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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