Javascript required
Skip to content Skip to sidebar Skip to footer

Drawing a Curvillinear Circle With Latex

Introduction

TikZ is probably the most complex and powerful tool to create graphic elements in LaTeX. Starting with a uncomplicated example, this article introduces some basic concepts: cartoon lines, dots, curves, circles, rectangles etc.

Firstly, load the tikz packet past including the line \usepackage{tikz} in the preamble of your document, then describe a graphic using the tikzpicture environment.

                        \documentclass            {commodity}            \usepackage            {tikz}            \brainstorm            {document}            \brainstorm            {tikzpicture}            \draw            [gray, thick]            (-ane,two) -- (ii,-4);            \draw            [gray, thick]            (-1,-1) -- (2,ii);            \filldraw            [black]            (0,0) circle (2pt) node[anchor=due west]{Intersection point};            \end            {tikzpicture}            \terminate            {document}          

 Open up this example in Overleaf

This instance produces the following output:

OLV2tikz1.png

In this instance two lines and one point are drawn. To add a line the command \describe[grayness, thick] defines a graphic element whose colour is gray and with a thick stroke. The line is actually defined past information technology'south two endpoints, (-ane,2) and (2,-4), joined by --.

The point is actually a circle drawn by \filldraw[black], this control volition not only draw the circle but fill up information technology using black. In this command the centre point (0,0) and the radius (2pt) are declared. Next to the point is a node, which is actually a box containing the text intersection bespeak, and anchored at the west of the point.

Information technology'south of import to notice the semicolon ; used at the end of each draw command.

Notation: The tikzfigure environs can be enclosed inside a effigy or similar environment. Run across the Inserting Images article for more data on this topic.

Basic elements: points, lines and paths

In this section nosotros provide some examples showing how to create some basic graphic elements which tin be combined to create more elaborate figures.

                        \documentclass            {commodity}            \usepackage            {tikz}            \begin            {certificate}            \brainstorm            {tikzpicture}            \draw            (-2,0) -- (2,0);            \filldraw            [grayness] (0,0) circle (2pt);            \draw            (-two,-ii) .. controls (0,0) .. (2,-two);            \describe            (-2,2) .. controls (-1,0) and (1,0) .. (2,2);            \cease            {tikzpicture}            \finish            {document}          

 Open this example in Overleaf

This instance produces the following output:

OLV2tikz2.png

At that place are three bones commands in this example:

  • \describe (-two,0) -- (2,0); : This defines a line whose endpoint are (-ii,0) and (ii,0).
  • \filldraw [gray] (0,0) circle (2pt); : The point is created every bit a very modest gray circumvolve centred at (0,0) and whose radius is (2pt). The \filldraw control is used to depict elements and fill them with a specific colour. See the side by side department for more than examples.
  • \draw (-ii,ii) .. controls (-1,0) and (1,0) .. (2,2); : Draws a Bézier curve. There are 4 points defining it: (-2,2) and (2,2) are its endpoints, (-1,0) and (1,0) are control points that determine "how curved" it is. Yous can think of these 2 points as "attractor points".

Basic geometric shapes: Circles, ellipses and polygons

Geometric figures tin be synthetic from simpler elements and so let'due south start with circles, ellipses and arcs.

                        \documentclass            {commodity}            \usepackage            {tikz}            \brainstorm            {document}            \begin            {tikzpicture}            \filldraw            [colour=red!60, fill=red!five, very thick](-one,0) circle (1.5);            \fill            [blue!50]            (ii.5,0) ellipse (1.5 and 0.five);            \draw            [ultra thick, ->]            (6.5,0) arc (0:220:1);            \finish            {tikzpicture}            \end            {document}          

 Open up this example in Overleaf

This example produces the following output:

TikzEx3.png

  • \filldraw[colour=red!threescore, fill=cerise!five, very thick](-one,0) circle (1.v); : This command was used in the previous section to draw a point, merely in this example there are some additional parameters inside the brackets. These are explained below:
    • colour=red!60 : The colour of the ring around the circle is set to sixty% red (lighter than "pure" cherry-red). See the reference guide for a list of the default colours bachelor in 50aTeX; as well, run into Using colours in LaTeX to larn how to create your ain colours.
    • fill=red!5 : The circle is filled with an even lighter shade of red.
    • very thick : This parameter defines the thickness of the stroke. See the reference guide for a consummate list of values.
  • \fill[blue!l] (ii.5,0) ellipse (ane.v and 0.5); : To create an ellipse you provide a centre bespeak (ii.5,0), and two radii: horizontal and vertical (1.5 and 0.5 respectively). Also notice the control fill instead of depict or filldraw, this is because, in this example, there's no need to control outer and inner colours.
  • \draw[ultra thick, ->] (6.5,0) arc (0:220:1); : This command will depict an arc starting at (6.5,0). The actress parameter -> indicates that the arc volition have an arrow at the stop. In addition to the starting signal you must provide three additional values: the starting and ending angles, and the radius; here, these 3 parameter values are provided in the format (0:220:1).

In add-on to curved geometric shapes you can too create elements that apply straight lines, using a similar syntax:

                        \documentclass            {article}            \usepackage            {tikz}            \brainstorm            {document}            \begin            {tikzpicture}            \draw            [blueish, very thick]            (0,0) rectangle (3,2);            \draw            [orangish, ultra thick]            (four,0) -- (half-dozen,0) -- (5.7,2) -- cycle;            \cease            {tikzpicture}            \stop            {document}          

 Open this instance in Overleaf

This case produces the following output:

OLV2tikz4.png

  • \describe[blue, very thick] (0,0) rectangle (3,ii); : Rectangles are created by the special command rectangle. You have to provide two points, the outset one is where the "pencil" begins to draw the rectangle and the second one is the diagonally contrary corner point.
  • \depict[orangish, ultra thick] (4,0) -- (vi,0) -- (five.7,two) -- cycle; : To draw a polygon we draw a closed path of straight lines: a line from (4,0) to (6,0) and a line from (half-dozen,0) to (five.7,2). The bike instruction ways that the start and end points should coincide to create a "closed" path (shape), which results in construction of the terminal 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/.style={circle, depict=greenish!60, fill=light-green!5, 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]            {1};            \node            [squarednode]            (rightsquare)       [right=of maintopic]            {3};            \node            [roundnode]            (lowercircle)       [below=of maintopic]            {4};            %Lines            \describe            [->]            (uppercircle.south) -- (maintopic.due north);            \describe            [->]            (maintopic.e) -- (rightsquare.due west);            \draw            [->]            (rightsquare.s) .. controls +(downwards:7mm) and +(correct:7mm) .. (lowercircle.eastward);            \stop            {tikzpicture}            \stop            {document}          

 Open this case in Overleaf

This example produces the following output:

OLV2tikz5.png

At that place are essentially three commands in this figure: A node definition, a node declaration and lines that join two nodes.

  • roundnode/.style={circle, describe=green!threescore, fill=light-green!five, very thick, minimum size=7mm} : Passed as a parameter to the tikzpicture environment. It defines a node that volition be referenced as roundnode: this node will exist a circumvolve whose outer band will be drawn using the colour green!60 and volition exist filled using greenish!5. The stroke will be very thick and its minimum size is 7mm. The line below this defines a second rectangle-shaped node called squarednode, using similar parameters.
  • \node[squarednode] (maintopic) {2}; : This will create a squarednode, as defined in the previous control. This node will have an id of maintopic and will contain the number ii. If you leave an empty space inside the braces no text will be displayed.
  • [above=of maintopic] : Find that all only the starting time node have an boosted parameter that determines its position relative to other nodes. For instance, [to a higher place=of maintopic] means that this node should appear above the node named maintopic. For this positioning organization to work you take to add together \usetikzlibrary{positioning} to your preamble. Without the positioning library, you can use the syntax above of=maintopic instead, but the positioning syntax is more flexible and powerful: you can extend information technology to write above=3cm of maintopic i.e. control the bodily distance from maintopic.
  • \draw[->] (uppercircle.south) -- (maintopic.north); : An pointer-like straight line will be 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 packet:

parameter values picture
color white, black, red, green, blue, cyan, magenta, yellow BasicColours.png
thickness ultra thin, very thin, thin, thick, very thick, ultra thick Thickness.png

More than colours may be bachelor in your FiftyaTeastward10 distribution. Run across Using colours in LaTeX

Farther reading

For more information see:

  • Using colours in LaTeX
  • Pgfplots parcel
  • Inserting Images
  • Lists of tables and figures
  • Positioning images and tables
  • Drawing diagrams directly in LaTeX
  • The TikZ and PGF Packages Manual
  • TikZ and PGF examples at TeXample.net

athertonluder1970.blogspot.com

Source: https://www.overleaf.com/learn/latex/TikZ_package