Captioned images / figures in LaTeX


Download 1.76 Mb.
bet2/5
Sana04.04.2023
Hajmi1.76 Mb.
#1327896
1   2   3   4   5
Bog'liq
Grafika bilan ishlash

    Bu sahifa navigatsiya:
  • Grids

Basic shapes


One of the simplest and most commonly used commands in TikZ is the \draw command. To draw a straight line we use this command, then we enter a starting co-ordinate, followed by two dashes before the ending co-ordinate. We then finish the statement by closing it with a semicolon.
\draw (0,0) -- (4,0);

We can then add more co-ordinates in like this to make it a square:
\draw (0,0) -- (4,0) -- (4,4) -- (0,4) -- (0,0);

However this isn't particularly good style. As we are drawing a line that ends up in the same place we started, it is better to finish the statement with the keyword cycle rather than the last co-ordinate.
\draw (0,0) -- (4,0) -- (4,4) -- (0,4) -- cycle;
To simplify this code further we can use the rectangle keyword after the starting co-ordinate and then follow it with the co-ordinate of the corner diagonally opposite.
\draw (0,0) rectangle (4,4);
We can also add lines that aren't straight. For example, this is how we draw a parabola:
\draw (0,0) parabola (4,4);

To add a curved line we use control points. We begin with our starting co-ordinate, then use two dots followed by the keyword controls and then the co-ordinates of our control points separated by an and. Then after two more dots we have the final point. These control points act like magnets attracting the line in their direction:
\draw (0,0) .. controls (0,4) and (4,0) .. (4,4);

We can then add a circle like this. The first co-ordinate is the circle's centre and the length in brackets at the end is the circle's radius:
\draw (2,2) circle (3cm);

This is how we draw an ellipse. This time the lengths in the brackets separated by an and, are the x-direction radius and the y-direction radius respectively:
\draw (2,2) ellipse (3cm and 1cm);

This is how we draw an arc. In the final bracket we enter the starting angle, the ending angle and the radius. This time they are separated by colons:
\draw (3,0) arc (0:75:3cm);

To customise the way these lines are drawn we add extra arguments into the \draw command. For example, we can edit the circle we drew so that the line is red, thick and dashed:
\draw[red,thick,dashed] (2,2) circle (3cm);


Grids


Very often when drawing diagrams we will want to draw a grid. To do this we use the \draw command followed by by some additional arguments. For example, we specify the grid step size using step= and a length. We've also specified the colour gray and told it to make the lines very thin. After these arguments we enter the co-ordinates of the bottom-left corner, followed by the keyword grid and then the co-ordinates of the top right-corner:
\draw[step=1cm,gray,very thin] (-2,-2) grid (6,6);

If we want to remove the outer lines around this grid we can crop the size slightly like this:
\draw[step=1cm,gray,very thin] (-1.9,-1.9) grid (5.9,5.9);


Download 1.76 Mb.

Do'stlaringiz bilan baham:
1   2   3   4   5




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling