1

It may look too broad, but each time I want to draw something using tikz, it turns just into the hell, cause I always have to keep in mind all the coordinates I want. Well, for the square like this

\draw (0,0) -- (4,0) -- (4,4) -- (0,4) -- (0,0);

Thats not a problem, but for complicated things it is really difficult. Is not there a way to easier the work?

M.Mass
  • 525
  • You can give the coordinates names and refer to the names instead of the numerical vector. – Johannes_B Jun 11 '17 at 07:11
  • 2
    If you show an example someone may find some hacks to improve the code clarity. – hzhr Jun 11 '17 at 07:40
  • Do you know the positioning library? See https://tex.stackexchange.com/questions/69439 for example. There you can use \node[above right] (AnotherNode) {Text}; – Dr. Manuel Kuehner Jun 11 '17 at 11:01
  • BTW, you should use cycle instead of repeating the last point, although the reason shows up better with acute triangles. – John Kormylo Jun 11 '17 at 15:36

2 Answers2

1

only two coordinates...

\draw (1,1) rectangle (3,4);
Henri Menke
  • 109,596
0

There are (selection):

  • macro definitions
  • lengths, counters,
  • named coordinates,
  • pics,
  • ...

For example:

\newcommand*{\MyLengthOfSquare}{4}
\draw
  (0, 0) coordinate (MyLowerLeftCornerOfSquare)
  rectangle (\MySquareLength, \MySquareLength)
  coordinate (MyUpperRightCornerOfSquare)
;

The named coordinates MyLowerLeftCornerOfSquare and MyUpperRightCornerOfSquare can then be used in the following TikZ commands.

Heiko Oberdiek
  • 271,626