How To Draw An Arc In Tikz Latex
TikZ is a package for LaTeX for drawing pictures. It is a frontend to the Portable Graphics Format (PGF) package and is inspired from metafont, pstricks, and the standard LaTeX flick environment. In TikZ, the user programs the picture with commands that draw element past chemical element.
The advantage of TikZ over imported graphics is that it uses fonts and line widths consistent with the rest of the LaTeX document. In contrast, imported graphics normally embed their fonts and rescaling the graphic also rescales line widths. Also, TikZ pictures are easier to adjust since the commands are part of the document.
Installation
To install TikZ/PGF:
- Debian or Ubuntu: install the pgf package
- MiKTeX: use the update wizard to install the pgf and xcolor packages.
Otherwise, download the latest version from http://sourceforge.cyberspace/projects/pgf, and follow the installation instructions in pgfmanual.pdf.
An Instance
Here is an example LaTeX document with a TikZ picture.
\documentclass[12pt]{article} \usepackage{tikz} \begin{document} This picture was drawn with TikZ: \brainstorm{tikzpicture}[calibration=one.5] % Draw thin grid lines with color forty% gray + threescore% white \draw [step=0.5,thin,gray!twoscore] (-i.4,-1.four) filigree (i.4,1.four); % Draw x and y axis lines \draw [->] (-1.5,0) -- (one.5,0) node [beneath] {$x$}; \draw [->] (0,-i.v) -- (0,1.5) node [left] {$y$}; % Describe a bluish circle at the origin of radius 1 \draw [semithick,blueish] (0,0) circle (ane); % Describe a triangle with vertices (0,0), (one,0), (1,0.seven) \draw [semithick,blue] (0,0) -- (1,0) -- (1,0.seven) -- cycle; \end{tikzpicture} \end{document}
TikZ Basics
A picture is contained in a tikzpicture environs. The various parts of the picture are specified with \depict commands. A \describe control consists of options (colour, line width, …) and a path, terminated by a semicolon:
\draw [ options ] path ;
All TikZ commands should end with a semicolon (;), beware that forgetting one can produce confusing mistake letters.
Paths
A path specifies a line, curve, or collection of lines and curves to be drawn. Here are some examples of dissimilar paths:
% A line. \describe (-five,0) -- (v,two); % A sequence of connected lines. \describe (-i,0) -- (1,0) -- (0,1) -- (0,-1); % A rectangle (specified by two corners). \draw (-2,-1) rectangle (2,one); % A circle. \draw [`*options*`] (4,0) circumvolve (0.five); The units for these are coordinates are cm, though they might not stand for to physical centimeters if the figure is scaled. You can also specify multiple primitives every bit a single path (not necessarily continued), for case the post-obit draws ii circles and a rectangle
\depict [blue,semithick] (-1,0) circle (0.5) (one,0) circle (0.5) (0,-0.25) rectangle (two,0.25); Such a path is useful when we want to employ the same cartoon options to multiple primitives.
Drawing Text
LaTeX code can exist added to a picture using a node. Nodes tin can hold text, math, includegraphics, and most other kinds of LaTeX code. For instance, the following specifies a node at coordinates (2,3):
\depict (2,three) node [ node options ] { LaTeX code };
Nodes also can exist specified on the vertices of a path.
\describe (-1,0) node [below] {Point $A$} -- (1,1) node [below] {Indicate $B$}; Specifying nodes this way is useful to annotate parts of a diagram and to label axes (as with the x and y axes in the first example).
Options
Options specify how to depict a path or node. TikZ is very flexible in this attribute and supports a great variety of effects. The typically useful cartoon options are
-
Add an arrowhead:
[->]
Similarly,[<-](reverse) or[<->](double-headed). -
Set line width:
[semithick]
Other widths:very thin,sparse,thick,very thick. -
Cartoon in color:
[blue] -
Specifying a mixed color:
[blue!30!red]
(30% blue + 70% red) -
Describe translucent objects:
[opacity=0.4]
Some other useful kind of pick are geometric transformations:
-
Translation:
[xshift=1cm,yshift=-0.5cm] -
Scaling:
[scale=1.2] -
Coordinate scaling, reflection:
[xscale=2.five,yscale=-i] -
Rotation:
[rotate=35]
More Examples
The post-obit examples demonstrate TikZ for some real globe figures. Full explanation of these examples is beyond the scope of this tutorial, but studying the example codes may produce helpful keywords for finding further information.
A wavy curve
This instance demonstrates the in and out options and accomplishing repeated elements with a \foreach loop.
\begin{tikzpicture}[calibration=0.8] % Draw equation as part of the TikZ pic \draw (-four,0) node {$P(x_n) = 0, \; north = 0, \ldots , Due north,$}; \draw (2,0.65) node {$P(x)$}; \draw [->,grey] (0,0) -- (vi.25,0) node [below] {\small $10$}; % Draw a wavy curve through the (x_n) \draw [semithick] (0,0.4) to [out=-forty,in=140] (0.5,0) to [out=-40,in=240] (1.5,0) to [out=60,in=160] (2.eight,0) to [out=-20,in=200] (4.5,0) to [out=20,in=200] (6,0.five); % Label the (x_n) with a loop \foreach \n/\x in {0/0.five, 1/i.5, 2/2.8, three/iv.5} { \make full (\x,0) circle (1.6pt) node [below=5pt] {$x_{ \northward }$}; } \finish{tikzpicture}
Figure illustrating cubic ENO
This picture shows how to write a multiline node with the text width option and more examples of \foreach. Also, some math is used in computing the command points such that the curves interpolate the data. Information technology uses a custom color gold; add together \definecolor{gold}{rgb}{0.85,0.65,0} to the preamble to reproduce.
% Ascertain the y values of the data \newcommand{\ya}{0.v} \newcommand{\yb}{0.1} \newcommand{\yc}{0.ane} \newcommand{\yd}{ii} \newcommand{\ye}{ii.1} \newcommand{\yf}{i.nine} \newcommand{\yg}{1.seven} \begin{tikzpicture}[calibration=1.ii] % Draw a gray box with 'Cubic ENO: Interpolate q_i with ...' \draw (-1,2.25) node [fill={gray!10},rounded corners,left,text width=32mm] {\footnotesize Cubic ENO: \\ Interpolate $q_i$ with \textcolor{ruby}{$ \mathcal {Due south}^a_i$}, \textcolor{aureate}{$ \mathcal {S}^b_i$}, or \textcolor{blueish}{$ \mathcal {South}^c_i$}}; % Fill/draw the interval q_i \make full [greyness!xv] (0,-0.fifteen) rectangle (ane,2.half dozen); \draw [gray,thin] (0,-0.15) -- (0,two.vi) (1,-0.15) -- (ane,two.half dozen); \describe [grayness] (0.5,two.6) node [above] {$q_i$}; % Describe x labels \depict [yshift=-0.15cm,beneath] \foreach \i in {-three,-2,-1,+2,+3} { (\i,0) node [gray] {$x_{i \i }$} } (0,0) node [black] {$x_i$} (one,0) node [black] {$x_{i+1}$}; % Draw Bezier curves, illustrating the 3 possible interpolations. % The control points are computed such that the curves interpolate. \draw [red,thick] (-2,\yb) .. controls (-1,-five*\yb/six+3*\yc-9*\yd/half-dozen+2*\ye/half-dozen) and (0,2*\yb/6-9*\yc/6+3*\yd-5*\ye/six) .. (1,\ye) (-1.5,0.25) node {$ \mathcal {S}^a_i$}; \draw [gold,thick] (-1,\yc) .. controls (0,-5*\yc/half dozen+3*\yd-9*\ye/6+two*\yf/6) and (1,2*\yc/6-9*\yd/vi+3*\ye-5*\yf/6) .. (2,\yf) (-0.v,ii) node {$ \mathcal {Southward}^b_i$}; \describe [blue,thick] (0,\yd) .. controls (1,-5*\yd/6+iii*\ye-nine*\yf/6+two*\yg/6) and (2,2*\yd/6-9*\ye/6+3*\yf-5*\yg/6) .. (3,\yg) (2.5,two.25) node {$ \mathcal {S}^c_i$}; % Depict datapoint markers \foreach \p in {(-3,\ya), (-2,\yb), (-ane,\yc), (0,\yd), (ane,\ye), (2,\yf), (iii,\yg)} { \fill \p circumvolve (1pt); } \cease{tikzpicture}
Braces
This picture show shows how to draw curly braces with the path decoration library. To include this library, add together
\usetikzlibrary{decorations.pathreplacing} to the preamble just afterward \usepackage{tikz}. The film also demonstrates naming nodes with the \node control.
\begin{tikzpicture}[scale=0.6] % Depict three filled circles for points a,x,b, and ascertain % them as TikZ nodes \node (a) at (0,ane) [fill up,circle,inner sep=one.2pt] {}; \node (10) at (1.eight,0.5) [draw,circumvolve,inner sep=1.2pt] {}; \node (b) at (four,ii) [fill,circumvolve,inner sep=1.2pt] {}; % Label the points \draw (a) node [in a higher place] {$a$} (10) node [to a higher place] {$x$} (b) node [above] {$b$}; % Describe a curvy line through a,ten,b \draw [thick] (a) to [out=-35,in=185] (x) (ten) to [in=248,out=v] (b); % Depict curly braces using path decoration \draw [gray,decorate,decoration={caryatid,amplitude=5pt}, xshift=-4pt,yshift=-9pt] (1.eight,0.5) -- (0,1) node [black,midway,below=4pt,xshift=-2pt] {\footnotesize $C_1$}; \describe [greyness,decorate,ornament={brace,aamplitude=5pt}, xshift=8pt,yshift=-11pt] (4,2) -- (i.8,0.5) node [black,midway,below=2pt,xshift=8pt] {\footnotesize $C_2$}; \end{tikzpicture}
Further Information
More than TikZ/PGF examples are available at texample. Besides run into the manual pgfmanual.pdf for both tutorial and detailed reference information (find it in texmf/physician/generic/pgf/pgfmanual.pdf or search the web).
Source: https://getreuer.info/tutorials/tikz-for-high-quality-latex-pictures/index.html
Posted by: eppsreck1993.blogspot.com

0 Response to "How To Draw An Arc In Tikz Latex"
Post a Comment