Draw a Circle at a Location Tikz
Introduction
TikZ is probably the most complex and powerful tool to create graphic elements in LaTeX. Starting with a simple example, this commodity introduces some basic concepts: drawing lines, dots, curves, circles, rectangles etc.
Firstly, load the tikz
package by including the line \usepackage{tikz}
in the preamble of your certificate, then draw a graphic using the tikzpicture
environs.
\documentclass {article} \usepackage {tikz} \begin {document} \brainstorm {tikzpicture} \draw [grey, thick] (-1,2) -- (2,-iv); \draw [gray, thick] (-one,-1) -- (2,2); \filldraw [black] (0,0) circle (2pt) node[anchor=westward]{Intersection signal}; \terminate {tikzpicture} \end {document}
Open this example in Overleaf
This instance produces the post-obit output:
In this example two lines and one bespeak are drawn. To add a line the command \draw[gray, thick]
defines a graphic element whose colour is grayness
and with a thick
stroke. The line is actually defined by it's two endpoints, (-1,ii)
and (two,-four)
, joined by --
.
The signal is really a circle
fatigued by \filldraw[blackness]
, this command will not only draw the circle but make full it using black. In this control the centre point (0,0)
and the radius (2pt)
are alleged. Next to the bespeak is a node
, which is really a box containing the text intersection point
, and anchored at the west
of the point.
It's important to notice the semicolon ;
used at the terminate of each draw
command.
Note: The tikzfigure
surroundings can be enclosed inside a figure or similar environment. See the Inserting Images article for more information on this topic.
Basic elements: points, lines and paths
In this department we provide some examples showing how to create some basic graphic elements which can exist combined to create more elaborate figures.
\documentclass {commodity} \usepackage {tikz} \begin {document} \begin {tikzpicture} \draw (-2,0) -- (ii,0); \filldraw [gray] (0,0) circle (2pt); \describe (-2,-2) .. controls (0,0) .. (ii,-two); \draw (-ii,two) .. controls (-1,0) and (i,0) .. (2,ii); \end {tikzpicture} \stop {document}
Open this case in Overleaf
This example produces the following output:
There are three basic commands in this example:
-
\depict (-ii,0) -- (2,0);
: This defines a line whose endpoint are(-ii,0)
and(ii,0)
. -
\filldraw [grey] (0,0) circumvolve (2pt);
: The point is created equally a very smallgray
circle
centred at(0,0)
and whose radius is(2pt)
. The\filldraw
command is used to draw elements and fill them with a specific colour. See the adjacent section for more examples. -
\draw (-2,2) .. controls (-1,0) and (i,0) .. (2,ii);
: Draws a Bézier curve. At that place are iv points defining it:(-two,ii)
and(two,2)
are its endpoints,(-i,0)
and(1,0)
are control points that make up one's mind "how curved" information technology is. Yous can retrieve of these two points as "attractor points".
Basic geometric shapes: Circles, ellipses and polygons
Geometric figures tin can be constructed from simpler elements so allow's showtime with circles, ellipses and arcs.
\documentclass {commodity} \usepackage {tikz} \begin {document} \brainstorm {tikzpicture} \filldraw [color=red!60, fill up=red!5, very thick](-1,0) circle (1.5); \make full [blue!50] (2.5,0) ellipse (1.five and 0.5); \draw [ultra thick, ->] (6.five,0) arc (0:220:1); \end {tikzpicture} \terminate {certificate}
Open this example in Overleaf
This instance produces the post-obit output:
-
\filldraw[color=blood-red!threescore, fill=blood-red!5, very thick](-1,0) circle (one.5);
: This command was used in the previous section to describe a point, but in this instance there are some boosted parameters inside the brackets. These are explained below:-
color=ruddy!lx
: The color of the band around the circle is set to 60% red (lighter than "pure" red). Run across the reference guide for a list of the default colours bachelor in LaTdue eastX; besides, see Using colours in LaTeX to acquire how to create your own colours. -
fill up=crimson!5
: The circle is filled with an fifty-fifty lighter shade of ruby. -
very thick
: This parameter defines the thickness of the stroke. See the reference guide for a complete listing of values.
-
-
\make full[bluish!50] (2.5,0) ellipse (1.v and 0.v);
: To create an ellipse you lot provide a centre signal(2.5,0)
, and two radii: horizontal and vertical (1.v
and0.v
respectively). As well discover the commandfill
instead ofdraw
or filldraw, this is because, in this case, there's no need to command outer and inner colours. -
\draw[ultra thick, ->] (6.5,0) arc (0:220:i);
: This command will draw an arc starting at(6.5,0)
. The actress parameter->
indicates that the arc will have an arrow at the stop. In addition to the starting betoken you must provide three additional values: the starting and ending angles, and the radius; here, these iii parameter values are provided in the format(0:220:1)
.
In addition to curved geometric shapes you tin also create elements that utilize straight lines, using a similar syntax:
\documentclass {article} \usepackage {tikz} \begin {document} \begin {tikzpicture} \draw [blue, very thick] (0,0) rectangle (3,2); \depict [orange, ultra thick] (4,0) -- (six,0) -- (5.seven,2) -- cycle; \end {tikzpicture} \finish {document}
Open this instance in Overleaf
This example produces the following output:
-
\draw[blue, very thick] (0,0) rectangle (3,2);
: Rectangles are created by the special commandrectangle
. You have to provide two points, the first one is where the "pencil" begins to draw the rectangle and the second 1 is the diagonally contrary corner point. -
\draw[orange, ultra thick] (iv,0) -- (6,0) -- (5.7,2) -- cycle;
: To draw a polygon we describe a closed path of straight lines: a line from(4,0)
to(6,0)
and a line from(6,0)
to(v.7,ii)
. Thecycle
didactics ways that the beginning and finish points should coincide to create a "airtight" path (shape), which results in construction of the concluding line segment.
Diagrams
Nodes are probably the most versatile elements in TikZ. We've already used one 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/.way={circle, draw=green!lx, fill=greenish!5, very thick, minimum size=7mm}, squarednode/.style={rectangle, draw=red!60, fill=red!5, very thick, minimum size=5mm}, ] %Nodes \node [squarednode] (maintopic) {two}; \node [roundnode] (uppercircle) [above=of maintopic] {ane}; \node [squarednode] (rightsquare) [right=of maintopic] {three}; \node [roundnode] (lowercircle) [below=of maintopic] {4}; %Lines \describe [->] (uppercircle.south) -- (maintopic.n); \describe [->] (maintopic.east) -- (rightsquare.west); \depict [->] (rightsquare.south) .. controls +(down:7mm) and +(right:7mm) .. (lowercircle.east); \cease {tikzpicture} \end {document}
Open up this instance in Overleaf
This instance produces the following output:
There are essentially 3 commands in this figure: A node definition, a node declaration and lines that join two nodes.
-
roundnode/.manner={circle, depict=green!lx, fill=green!5, very thick, minimum size=7mm}
: Passed as a parameter to thetikzpicture
surround. Information technology defines a node that will be referenced asroundnode
: this node will exist a circle whose outer band will be drawn using the colourgreen!60
and will be filled usinggreen!5
. The stroke will bevery thick
and itsminimum size
is7mm
. The line beneath this defines a 2nd rectangle-shaped node calledsquarednode
, using like parameters. -
\node[squarednode] (maintopic) {2};
: This will create asquarednode
, as defined in the previous control. This node will take an id ofmaintopic
and will comprise the number2
. If you get out an empty space inside the braces no text will be displayed. -
[above=of maintopic]
: Notice that all just the first node have an additional parameter that determines its position relative to other nodes. For instance,[higher up=of maintopic]
means that this node should appear above the node namedmaintopic
. For this positioning arrangement to work you have to add\usetikzlibrary{positioning}
to your preamble. Without thepositioning
library, yous can apply the syntaxabove of=maintopic
instead, just thepositioning
syntax is more flexible and powerful: you can extend information technology to writeabove=3cm of maintopic
i.e. control the actual distance frommaintopic
. -
\draw[->] (uppercircle.southward) -- (maintopic.northward);
: An arrow-like straight line will exist drawn. The syntax has been already explained in the basic elements section. The only departure 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
parcel:
parameter | values | moving picture |
---|---|---|
color | white, black, red, green, blue, cyan, magenta, yellowish | |
thickness | ultra thin, very thin, sparse, thick, very thick, ultra thick |
More colours may be available in your FiftyaTeTen distribution. Encounter Using colours in LaTeX
Farther reading
For more information see:
- Using colours in LaTeX
- Pgfplots package
- Inserting Images
- Lists of tables and figures
- Positioning images and tables
- Cartoon diagrams directly in LaTeX
- The TikZ and PGF Packages Manual
- TikZ and PGF examples at TeXample.cyberspace
gustafsonpereadesen.blogspot.com
Source: https://www.overleaf.com/learn/latex/TikZ_package
0 Response to "Draw a Circle at a Location Tikz"
Post a Comment