Draw a Circle and Label It in Latex
Introduction
TikZ is probably the most complex and powerful tool to create graphic elements in 50aTeastwardX. Starting with a simple case, this commodity introduces some basic concepts: cartoon lines, dots, curves, circles, rectangles etc.
Firstly, load the tikz bundle past including the line \usepackage{tikz} in the preamble of your certificate, and so draw a graphic using the tikzpicture environment.
\documentclass {commodity} \usepackage {tikz} \begin {document} \begin {tikzpicture} \draw [gray, thick] (-1,ii) -- (2,-4); \describe [grayness, thick] (-1,-1) -- (ii,2); \filldraw [black] (0,0) circumvolve (2pt) node[ballast=due west]{Intersection point}; \cease {tikzpicture} \end {document}
Open this example in Overleaf
This instance produces the following output:
In this example 2 lines and one indicate are drawn. To add a line the command \depict[gray, thick] defines a graphic element whose colour is gray and with a thick stroke. The line is really defined by it's ii endpoints, (-1,2) and (ii,-4), joined by --.
The bespeak is really a circle drawn by \filldraw[blackness], this command will not only draw the circumvolve just fill up it using blackness. In this command the middle bespeak (0,0) and the radius (2pt) are alleged. Next to the signal is a node, which is actually a box containing the text intersection bespeak, and anchored at the west of the bespeak.
Information technology's of import to observe the semicolon ; used at the stop of each depict command.
Note: The tikzfigure environment tin can be enclosed within a effigy or similar surroundings. Come across the Inserting Images article for more than information on this topic.
Bones elements: points, lines and paths
In this section we provide some examples showing how to create some basic graphic elements which can be combined to create more elaborate figures.
\documentclass {commodity} \usepackage {tikz} \begin {document} \begin {tikzpicture} \draw (-two,0) -- (2,0); \filldraw [greyness] (0,0) circle (2pt); \depict (-2,-two) .. controls (0,0) .. (ii,-2); \draw (-2,2) .. controls (-i,0) and (i,0) .. (2,2); \end {tikzpicture} \cease {document}
Open this example in Overleaf
This example produces the post-obit output:
At that place are 3 basic commands in this example:
-
\describe (-2,0) -- (ii,0);: This defines a line whose endpoint are(-2,0)and(2,0). -
\filldraw [gray] (0,0) circle (2pt);: The point is created equally a very smallgraycirclecentred at(0,0)and whose radius is(2pt). The\filldrawcommand is used to describe elements and fill up them with a specific colour. See the next section for more examples. -
\draw (-2,2) .. controls (-ane,0) and (1,0) .. (2,2);: Draws a Bézier curve. There are 4 points defining it:(-2,two)and(2,2)are its endpoints,(-1,0)and(1,0)are control points that decide "how curved" information technology is. Y'all can remember of these 2 points every bit "attractor points".
Basic geometric shapes: Circles, ellipses and polygons
Geometric figures can be constructed from simpler elements then let's beginning with circles, ellipses and arcs.
\documentclass {commodity} \usepackage {tikz} \begin {document} \brainstorm {tikzpicture} \filldraw [colour=carmine!60, fill=red!v, very thick](-1,0) circle (1.5); \fill [bluish!50] (ii.5,0) ellipse (i.five and 0.v); \depict [ultra thick, ->] (half-dozen.5,0) arc (0:220:1); \end {tikzpicture} \terminate {document}
Open this example in Overleaf
This instance produces the following output:
-
\filldraw[colour=scarlet!60, fill=red!5, very thick](-ane,0) circle (i.5);: This control was used in the previous section to depict a point, but in this instance at that place are some additional parameters inside the brackets. These are explained beneath:-
color=red!sixty: The colour of the ring around the circle is ready to 60% ruby (lighter than "pure" crimson). Encounter the reference guide for a list of the default colours available in LaTeastwardX; likewise, meet Using colours in LaTeX to learn how to create your own colours. -
fill up=reddish!five: The circle is filled with an fifty-fifty lighter shade of ruby. -
very thick: This parameter defines the thickness of the stroke. Come across the reference guide for a complete list of values.
-
-
\fill[blue!50] (2.5,0) ellipse (1.5 and 0.5);: To create an ellipse y'all provide a centre betoken(2.5,0), and ii radii: horizontal and vertical (ane.vand0.fiverespectively). Too detect the commandfillinstead ofdepictor filldraw, this is because, in this case, there's no need to control outer and inner colours. -
\depict[ultra thick, ->] (six.5,0) arc (0:220:1);: This control will draw an arc starting at(6.5,0). The extra parameter->indicates that the arc volition accept an arrow at the stop. In add-on to the starting point yous must provide three additional values: the starting and ending angles, and the radius; here, these three parameter values are provided in the format(0:220:1).
In addition to curved geometric shapes you tin can also create elements that utilize directly lines, using a similar syntax:
\documentclass {article} \usepackage {tikz} \begin {document} \begin {tikzpicture} \draw [blue, very thick] (0,0) rectangle (iii,2); \describe [orange, ultra thick] (four,0) -- (half-dozen,0) -- (5.7,ii) -- cycle; \end {tikzpicture} \end {document}
Open up this instance in Overleaf
This example produces the post-obit output:
-
\depict[blue, very thick] (0,0) rectangle (3,2);: Rectangles are created by the special commandrectangle. You have to provide ii points, the outset one is where the "pencil" begins to draw the rectangle and the second one is the diagonally contrary corner betoken. -
\draw[orange, ultra thick] (4,0) -- (half dozen,0) -- (5.7,2) -- bicycle;: To draw a polygon we describe a closed path of straight lines: a line from(iv,0)to(half dozen,0)and a line from(6,0)to(5.7,ii). Thecycleteaching means that the start and end points should coincide to create a "closed" path (shape), which results in construction of the final line segment.
Diagrams
Nodes are probably the most versatile elements in TikZ. We've already used ane node in the introduction—to add together some text to the figure. The next example uses nodes to create a diagram.
\documentclass {article} \usepackage {tikz} \usetikzlibrary {positioning} \brainstorm {certificate} \begin {tikzpicture}[ roundnode/.style={circumvolve, depict=green!threescore, fill up=green!five, very thick, minimum size=7mm}, squarednode/.manner={rectangle, describe=red!threescore, fill=carmine!5, very thick, minimum size=5mm}, ] %Nodes \node [squarednode] (maintopic) {two}; \node [roundnode] (uppercircle) [above=of maintopic] {one}; \node [squarednode] (rightsquare) [right=of maintopic] {three}; \node [roundnode] (lowercircle) [below=of maintopic] {iv}; %Lines \depict [->] (uppercircle.s) -- (maintopic.northward); \draw [->] (maintopic.east) -- (rightsquare.west); \describe [->] (rightsquare.s) .. controls +(downward:7mm) and +(right:7mm) .. (lowercircle.east); \end {tikzpicture} \end {document}
Open this instance in Overleaf
This example produces the post-obit output:
There are essentially three commands in this figure: A node definition, a node declaration and lines that join two nodes.
-
roundnode/.style={circle, draw=dark-green!lx, fill=green!v, very thick, minimum size=7mm}: Passed equally a parameter to thetikzpicturesurround. It defines a node that will be referenced asroundnode: this node will exist a circle whose outer ring will be fatigued using the colorgreen!lxand volition be filled usinggreen!v. The stroke will bevery thickand itsminimum sizeis7mm. The line below this defines a 2nd rectangle-shaped node chosensquarednode, using similar parameters. -
\node[squarednode] (maintopic) {2};: This will create asquarednode, every bit divers in the previous command. This node will have an id ofmaintopicand volition contain the number2. If you leave an empty space within the braces no text will be displayed. -
[above=of maintopic]: Notice that all but the beginning node have an boosted parameter that determines its position relative to other nodes. For example,[higher up=of maintopic]means that this node should appear above the node namedmaintopic. For this positioning system to piece of work y'all have to add together\usetikzlibrary{positioning}to your preamble. Without thepositioninglibrary, you can use the syntaxabove of=maintopicinstead, but thepositioningsyntax is more flexible and powerful: you can extend information technology to writeabove=3cm of maintopici.e. command the bodily altitude frommaintopic. -
\draw[->] (uppercircle.south) -- (maintopic.north);: An pointer-like direct line will be drawn. The syntax has been already explained in the basic elements department. The but difference is the manner 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 | moving-picture show |
|---|---|---|
| color | white, black, crimson, green, blue, cyan, magenta, yellow | |
| thickness | ultra thin, very thin, thin, thick, very thick, ultra thick | |
More colours may be available in your LaTeastX distribution. See Using colours in LaTeX
Further reading
For more information run into:
- Using colours in LaTeX
- Pgfplots package
- Inserting Images
- Lists of tables and figures
- Positioning images and tables
- Cartoon diagrams direct in LaTeX
- The TikZ and PGF Packages Manual
- TikZ and PGF examples at TeXample.internet
bratcheryousbantor.blogspot.com
Source: https://www.overleaf.com/learn/latex/TikZ_package
0 Response to "Draw a Circle and Label It in Latex"
Post a Comment