Draw Circle Around Letter in Tikz

Introduction

Tione thousandZ is probably the most complex and powerful tool to create graphic elements in LaTeX. Starting with a uncomplicated 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 document, then depict a graphic using the tikzpicture environment.

                        \documentclass            {article}            \usepackage            {tikz}            \begin            {document}            \brainstorm            {tikzpicture}            \draw            [grayness, thick]            (-i,ii) -- (2,-iv);            \draw            [gray, thick]            (-1,-1) -- (two,2);            \filldraw            [blackness]            (0,0) circle (2pt) node[anchor=west]{Intersection point};            \cease            {tikzpicture}            \stop            {document}          

 Open this example in Overleaf

This example produces the following output:

OLV2tikz1.png

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

The bespeak is actually a circle drawn by \filldraw[black], this command will not only describe the circumvolve but make full information technology using black. In this command the centre point (0,0) and the radius (2pt) are alleged. Next to the point is a node, which is actually a box containing the text intersection point, and anchored at the due west of the point.

It'south of import to notice the semicolon ; used at the end of each depict command.

Notation: The tikzfigure environment can be enclosed within a figure or similar environment. See the Inserting Images article for more information 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 than elaborate figures.

                        \documentclass            {article}            \usepackage            {tikz}            \begin            {document}            \begin            {tikzpicture}            \draw            (-2,0) -- (2,0);            \filldraw            [gray] (0,0) circumvolve (2pt);            \draw            (-2,-two) .. controls (0,0) .. (2,-2);            \draw            (-2,two) .. controls (-i,0) and (1,0) .. (2,2);            \end            {tikzpicture}            \end            {certificate}          

 Open this example in Overleaf

This instance produces the post-obit output:

OLV2tikz2.png

There are three basic commands in this example:

  • \draw (-2,0) -- (2,0); : This defines a line whose endpoint are (-2,0) and (2,0).
  • \filldraw [grayness] (0,0) circle (2pt); : The signal is created as a very small gray circumvolve 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 next section for more than examples.
  • \draw (-2,2) .. controls (-1,0) and (i,0) .. (2,2); : Draws a Bézier curve. In that location are iv points defining information technology: (-2,ii) and (2,two) are its endpoints, (-1,0) and (1,0) are control points that decide "how curved" it is. You can call back of these two points as "attractor points".

Basic geometric shapes: Circles, ellipses and polygons

Geometric figures can be constructed from simpler elements so let's start with circles, ellipses and arcs.

                        \documentclass            {article}            \usepackage            {tikz}            \brainstorm            {document}            \begin            {tikzpicture}            \filldraw            [color=red!60, fill=red!five, very thick](-ane,0) circle (1.five);            \fill            [bluish!50]            (2.five,0) ellipse (1.5 and 0.5);            \depict            [ultra thick, ->]            (6.five,0) arc (0:220:1);            \end            {tikzpicture}            \stop            {certificate}          

 Open this example in Overleaf

This example produces the following output:

TikzEx3.png

  • \filldraw[colour=carmine!60, fill up=red!5, very thick](-1,0) circle (1.five); : This command was used in the previous section to draw a point, but in this instance there are some additional parameters within the brackets. These are explained below:
    • color=red!60 : The colour of the ring effectually the circle is set to 60% red (lighter than "pure" crimson). See the reference guide for a list of the default colours available in LaTeX; as well, see Using colours in LaTeX to acquire how to create your own colours.
    • fill up=red!5 : The circle is filled with an fifty-fifty lighter shade of cherry-red.
    • very thick : This parameter defines the thickness of the stroke. Run across the reference guide for a complete list of values.
  • \fill[blue!50] (two.v,0) ellipse (1.5 and 0.five); : To create an ellipse you lot provide a centre point (2.5,0), and ii radii: horizontal and vertical (ane.5 and 0.v respectively). Besides discover the command fill instead of draw or filldraw, this is because, in this instance, there'south no need to control outer and inner colours.
  • \draw[ultra thick, ->] (half dozen.5,0) arc (0:220:1); : This control will draw an arc starting at (6.five,0). The extra parameter -> indicates that the arc will have an arrow at the end. In improver to the starting point you must provide iii boosted 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 can also create elements that use straight lines, using a like syntax:

                        \documentclass            {commodity}            \usepackage            {tikz}            \begin            {document}            \begin            {tikzpicture}            \draw            [blue, very thick]            (0,0) rectangle (3,2);            \draw            [orangish, ultra thick]            (4,0) -- (6,0) -- (5.seven,two) -- cycle;            \end            {tikzpicture}            \end            {document}          

 Open this example in Overleaf

This example produces the following output:

OLV2tikz4.png

  • \draw[blue, very thick] (0,0) rectangle (3,2); : Rectangles are created by the special control rectangle. You have to provide two points, the first one is where the "pencil" begins to describe the rectangle and the second one is the diagonally reverse corner point.
  • \draw[orange, ultra thick] (4,0) -- (six,0) -- (v.seven,2) -- cycle; : To depict a polygon we depict a closed path of straight lines: a line from (4,0) to (6,0) and a line from (6,0) to (5.seven,2). The cycle pedagogy means that the offset and stop points should coincide to create a "airtight" path (shape), which results in structure of the final line segment.

Diagrams

Nodes are probably the almost versatile elements in TikZ. We've already used i node in the introduction—to add some text to the figure. The side by side example uses nodes to create a diagram.

                        \documentclass            {article}            \usepackage            {tikz}            \usetikzlibrary            {positioning}            \begin            {document}            \begin            {tikzpicture}[ roundnode/.style={circle, draw=green!60, fill=greenish!5, very thick, minimum size=7mm}, squarednode/.style={rectangle, draw=red!threescore, fill up=red!v, very thick, minimum size=5mm}, ]            %Nodes            \node            [squarednode]            (maintopic)            {2};            \node            [roundnode]            (uppercircle)       [higher up=of maintopic]            {ane};            \node            [squarednode]            (rightsquare)       [correct=of maintopic]            {three};            \node            [roundnode]            (lowercircle)       [beneath=of maintopic]            {4};            %Lines            \depict            [->]            (uppercircle.south) -- (maintopic.north);            \draw            [->]            (maintopic.east) -- (rightsquare.westward);            \describe            [->]            (rightsquare.southward) .. controls +(down:7mm) and +(correct:7mm) .. (lowercircle.eastward);            \stop            {tikzpicture}            \end            {certificate}          

 Open this example in Overleaf

This example produces the following output:

OLV2tikz5.png

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

  • roundnode/.style={circle, draw=light-green!lx, fill=green!five, very thick, minimum size=7mm} : Passed equally a parameter to the tikzpicture environment. It defines a node that will be referenced as roundnode: this node volition exist a circle whose outer band will exist drawn using the colour green!lx and will exist filled using greenish!5. The stroke will exist very thick and its minimum size is 7mm. The line below this defines a second rectangle-shaped node called squarednode, using like parameters.
  • \node[squarednode] (maintopic) {two}; : This will create a squarednode, every bit divers in the previous command. This node will have an id of maintopic and will contain the number two. If you leave an empty infinite inside the braces no text will be displayed.
  • [above=of maintopic] : Observe that all simply the showtime node accept an additional parameter that determines its position relative to other nodes. For case, [above=of maintopic] means that this node should appear in a higher place the node named maintopic. For this positioning system to work you lot take to add \usetikzlibrary{positioning} to your preamble. Without the positioning library, y'all can utilize the syntax above of=maintopic instead, but the positioning syntax is more flexible and powerful: you tin can extend it to write above=3cm of maintopic i.east. control the bodily distance from maintopic.
  • \depict[->] (uppercircle.south) -- (maintopic.north); : An pointer-similar straight line volition be fatigued. The syntax has been already explained in the basic elements department. The only departure 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 colour and thickness parameters in the tikz parcel:

parameter values picture
color white, black, red, light-green, blueish, cyan, magenta, xanthous BasicColours.png
thickness ultra sparse, very thin, sparse, thick, very thick, ultra thick Thickness.png

More colours may exist available in your LaTdue eastX distribution. See Using colours in LaTeX

Further reading

For more data come across:

  • Using colours in LaTeX
  • Pgfplots bundle
  • 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.internet

cruzgoorrithle.blogspot.com

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

0 Response to "Draw Circle Around Letter in Tikz"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel