Draw a Circle Arounda Node With Tik
Introduction
TiyardZ is probably the nigh complex and powerful tool to create graphic elements in LaTe10. Starting with a elementary case, this article introduces some basic concepts: drawing lines, dots, curves, circles, rectangles etc.
Firstly, load the tikz parcel by including the line \usepackage{tikz} in the preamble of your certificate, and so describe a graphic using the tikzpicture environs.
\documentclass {article} \usepackage {tikz} \begin {document} \begin {tikzpicture} \draw [grayness, thick] (-i,2) -- (2,-4); \draw [grayness, thick] (-1,-i) -- (2,two); \filldraw [black] (0,0) circle (2pt) node[anchor=westward]{Intersection betoken}; \end {tikzpicture} \end {document}
Open up this example in Overleaf
This example produces the following output:
In this example ii lines and i point are drawn. To add together a line the control \depict[gray, thick] defines a graphic element whose colour is gray and with a thick stroke. The line is actually divers past it'due south two endpoints, (-1,2) and (ii,-4), joined by --.
The point is really a circle fatigued past \filldraw[black], this command volition not only draw the circle but make full it using black. In this command the centre point (0,0) and the radius (2pt) are declared. Next to the bespeak is a node, which is really a box containing the text intersection indicate, and anchored at the west of the point.
It's important to discover the semicolon ; used at the end of each depict command.
Annotation: The tikzfigure environs can be enclosed inside a effigy or like environment. Run across the Inserting Images article for more data on this topic.
Bones elements: points, lines and paths
In this section we provide some examples showing how to create some bones graphic elements which tin can be combined to create more elaborate figures.
\documentclass {article} \usepackage {tikz} \begin {document} \begin {tikzpicture} \describe (-two,0) -- (2,0); \filldraw [greyness] (0,0) circle (2pt); \depict (-2,-2) .. controls (0,0) .. (2,-2); \draw (-2,two) .. controls (-1,0) and (1,0) .. (2,2); \end {tikzpicture} \end {document}
Open up this instance in Overleaf
This example produces the following output:
There are three basic commands in this example:
-
\describe (-2,0) -- (2,0);: This defines a line whose endpoint are(-ii,0)and(2,0). -
\filldraw [grey] (0,0) circumvolve (2pt);: The indicate is created as a very pocket-sizegraynesscirclecentred at(0,0)and whose radius is(2pt). The\filldrawcommand is used to draw elements and fill them with a specific colour. Run into the next section for more examples. -
\draw (-two,2) .. controls (-1,0) and (1,0) .. (2,2);: Draws a Bézier curve. In that location are iv points defining it:(-2,2)and(ii,two)are its endpoints,(-1,0)and(1,0)are control points that determine "how curved" it is. You can think of these 2 points as "attractor points".
Basic geometric shapes: Circles, ellipses and polygons
Geometric figures can be synthetic from simpler elements so let's first with circles, ellipses and arcs.
\documentclass {article} \usepackage {tikz} \begin {certificate} \begin {tikzpicture} \filldraw [color=red!sixty, fill=scarlet!five, very thick](-1,0) circle (1.5); \fill [blue!50] (2.5,0) ellipse (1.5 and 0.5); \draw [ultra thick, ->] (6.5,0) arc (0:220:1); \end {tikzpicture} \end {document}
Open this example in Overleaf
This instance produces the following output:
-
\filldraw[color=red!sixty, fill=blood-red!5, very thick](-one,0) circle (1.5);: This command was used in the previous section to draw a point, simply in this example there are some additional parameters inside the brackets. These are explained beneath:-
color=red!lx: The colour of the ring around the circumvolve is set to lx% red (lighter than "pure" red). Meet the reference guide for a listing of the default colours available in LaTeX; also, see Using colours in LaTeX to learn how to create your own colours. -
fill up=scarlet!5: The circumvolve is filled with an even lighter shade of red. -
very thick: This parameter defines the thickness of the stroke. Encounter the reference guide for a consummate listing of values.
-
-
\fill[blue!l] (2.5,0) ellipse (1.5 and 0.5);: To create an ellipse y'all provide a heart bespeak(2.5,0), and 2 radii: horizontal and vertical (1.5and0.fiverespectively). Likewise notice the controlfillinstead ofdrawor filldraw, this is because, in this instance, at that place's no need to control outer and inner colours. -
\draw[ultra thick, ->] (6.5,0) arc (0:220:1);: This command will draw an arc starting at(half dozen.5,0). The extra parameter->indicates that the arc will have an pointer at the end. In addition to the starting point you lot must provide three boosted values: the starting and ending angles, and the radius; here, these three parameter values are provided in the format(0:220:ane).
In addition to curved geometric shapes you tin can likewise create elements that use directly lines, using a similar syntax:
\documentclass {article} \usepackage {tikz} \brainstorm {certificate} \begin {tikzpicture} \depict [blue, very thick] (0,0) rectangle (3,2); \describe [orange, ultra thick] (4,0) -- (6,0) -- (v.7,2) -- cycle; \end {tikzpicture} \end {document}
Open up this example in Overleaf
This example produces the following output:
-
\depict[bluish, very thick] (0,0) rectangle (iii,two);: Rectangles are created by the special commandrectangle. You have to provide two points, the first i is where the "pencil" begins to draw the rectangle and the second one is the diagonally opposite corner point. -
\draw[orange, ultra thick] (4,0) -- (6,0) -- (5.7,2) -- bike;: To depict a polygon we draw a closed path of direct lines: a line from(iv,0)to(half dozen,0)and a line from(6,0)to(5.7,2). Thebikeinstruction means that the start and end points should coincide to create a "airtight" path (shape), which results in structure of the final line segment.
Diagrams
Nodes are probably the most versatile elements in TikZ. We've already used 1 node in the introduction—to add some text to the figure. The next example uses nodes to create a diagram.
\documentclass {article} \usepackage {tikz} \usetikzlibrary {positioning} \brainstorm {document} \begin {tikzpicture}[ roundnode/.style={circle, draw=green!threescore, make full=dark-green!v, very thick, minimum size=7mm}, squarednode/.style={rectangle, draw=red!60, fill=red!5, very thick, minimum size=5mm}, ] %Nodes \node [squarednode] (maintopic) {2}; \node [roundnode] (uppercircle) [above=of maintopic] {i}; \node [squarednode] (rightsquare) [right=of maintopic] {3}; \node [roundnode] (lowercircle) [beneath=of maintopic] {iv}; %Lines \draw [->] (uppercircle.south) -- (maintopic.due north); \draw [->] (maintopic.due east) -- (rightsquare.westward); \depict [->] (rightsquare.south) .. controls +(down:7mm) and +(correct:7mm) .. (lowercircle.east); \end {tikzpicture} \stop {document}
Open this case in Overleaf
This instance produces the following output:
There are essentially iii commands in this effigy: A node definition, a node declaration and lines that join ii nodes.
-
roundnode/.style={circumvolve, draw=light-green!60, fill=green!5, very thick, minimum size=7mm}: Passed as a parameter to thetikzpictureenvironment. It defines a node that volition be referenced asroundnode: this node volition be a circle whose outer ring will be fatigued using the colourgreenish!60and will be filled usinggreen!5. The stroke will bevery thickand itsminimum sizeis7mm. The line below this defines a second rectangle-shaped node chosensquarednode, using similar parameters. -
\node[squarednode] (maintopic) {2};: This will create asquarednode, as divers in the previous control. This node will have an id ofmaintopicand will comprise the number2. If you leave an empty space inside the braces no text will be displayed. -
[above=of maintopic]: Notice that all but the start node take an additional parameter that determines its position relative to other nodes. For instance,[to a higher place=of maintopic]means that this node should announced above the node namedmaintopic. For this positioning system to work y'all have to add\usetikzlibrary{positioning}to your preamble. Without thepositioninglibrary, you can use the syntaxhigher up of=maintopicinstead, just thepositioningsyntax is more flexible and powerful: you can extend information technology to writein a higher place=3cm of maintopici.e. control the actual altitude frommaintopic. -
\draw[->] (uppercircle.south) -- (maintopic.due north);: An pointer-like straight line will be fatigued. The syntax has been already explained in the basic elements section. The only difference is the mode in which we write the endpoints of the line: by referencing a node (this is why we named them) and a position relative to the node.
Reference Guide
Possible color and thickness parameters in the tikz package:
| parameter | values | picture |
|---|---|---|
| color | white, black, red, light-green, blueish, cyan, magenta, yellow | |
| thickness | ultra thin, very sparse, thin, thick, very thick, ultra thick | |
More than colours may be bachelor in your LaTeX distribution. See Using colours in LaTeX
Further reading
For more than information encounter:
- Using colours in LaTeX
- Pgfplots package
- Inserting Images
- Lists of tables and figures
- Positioning images and tables
- Drawing diagrams straight in LaTeX
- The TikZ and PGF Packages Transmission
- TikZ and PGF examples at TeXample.cyberspace
fernandesceshounce.blogspot.com
Source: https://www.overleaf.com/learn/latex/TikZ_package
Post a Comment for "Draw a Circle Arounda Node With Tik"