Tikz Latex

Tikz Latex




🛑 ALL INFORMATION CLICK HERE 👈🏻👈🏻👈🏻

































Tikz Latex
\usepackage { tikz } % in preamble

\usetikzlibrary { ⟨list of libraries separated by commas⟩ } % general syntax, in preamble

\usetikzlibrary { arrow,pattern, snakes } % in preamble

\tikz [⟨options⟩] { ⟨tikz commands⟩ }

\begin { tikzpicture } [⟨options⟩]
⟨tikz commands⟩
\end { tikzpicture }

\path [draw] % Draw the line/curve
\path [fill] % Fill the area under the curve
\path [fill,draw] % Fill as well as draw the lines (boarders)
\path [pattern] %
\path [shade] % a variation on filling that changes colors smoothly from one to another
\path [shade,draw] % shade as well a draw
\path [clip] % all subsequent drawings up to the end of the current scope are clipped against the current path and the size of subsequent paths will not be important for the picture size
\path [use as bounding box]

\draw (1,0) -- (0,0) -- (0,1) -- cycle;

\draw (0,0) -- (2,0) (0,1) -- (2,1);

\draw (0,0) .. controls (1,1) .. (4,0)
(5,0) .. controls (6,0) and (6,1) .. (5,2);

\draw (0,0) to (3,2);
\draw (0,0) to[out=90,in=180] (3,2);
\draw (0,0) to[bend right] (3,2);

\draw (0,0) circle [radius=1.5];
\draw (0,0) circle (2cm); % old syntax with round brackets instead of square brackets
\draw (0,0) circle [x radius=1.5cm, y radius=10mm];
\draw (0,0) circle (1.2cm and 8mm); % old syntax
\draw (0,0) circle [x radius=1cm, y radius=5mm, rotate=30];
\draw [rotate=30] (0,0) ellipse (20pt and 10pt); % old syntax

\draw (0,0) arc (0:270:8mm);
\draw (0,0) arc (0:315:1.75cm and 1cm);
\filldraw [fill=cyan, draw=blue] (0,0) -- (12mm,0mm) arc (0:30:12mm) -- (0,0);

\draw (0,0) arc[radius = 8mm, start angle= 0, end angle= 270];
\draw (0,0) arc[x radius = 1.75cm, y radius = 1cm, start angle= 0, end angle= 315];

\draw [help lines] (0,0) grid (2,3);
\draw [step=0.5, gray, very thin] (-1.4,-1.4) grid (1.4,1.4);
\draw (0,0) parabola (1,1.5) parabola[bend at end] (2,0);
\draw (0,0) sin (1,1) cos (2,0) sin (3,-1) cos (4,0) sin (5,1);

\draw [red, dashed, very thick, rotate=30] (1,0) -- (0,0) -- (0,1);

\draw [->] (0,0) -- (30:20pt);
\draw [<->] (1,0) arc (180:30:10pt);
\draw [<<->] (2,0) -- ++(0.5,10pt) -- ++(0.5,-10pt) -- ++(0.5,10pt);

\draw (0,0) rectangle (1,1);
\shade [top color=yellow, bottom color=black] (0,0) rectangle (2,-1);
\filldraw [fill=green!20!white, draw=green!40!black] (0,0) rectangle (2,1);

%% syntax
%% \node[options] (Name of node) at (coordinates) {Text to appear};
% Example for usage
\node [red,rectangle] at (0,0) { Some text } ; % To place some text only
\node (A) at (0,0) {} ; % To define a new coordinate

\begin { tikzpicture }
\node (A) at (0,0) [thick,blue, circle,fill=blue!50] { Encoder } ; % node A
\node (B) at (3,0) [thick,blue,rectangle,fill=green!80!black] { Decoder } ; % node B
\draw [->,ultra thick] (A)--(B); % line joining node A and B
\end { tikzpicture }

\draw (0,0) node { a } -- (1,1) node { b } ;
\path (0,0) node { a } -- (1,1) node { b } ;

\draw [dotted]
(0,0) node { 1st node }
-- (1,1) node { 2nd node }
-- (0,2) node { 3rd node }
-- cycle;

\fill [fill=yellow]
(0,0) node { 1st node }
-- (1,1) node[circle,inner sep=0pt,draw] { 2nd node }
-- (0,2) node[fill=red!20,draw,double,rounded corners] { 3rd node } ;

\draw (0,0) -- (3,1)
node[pos=0] { 0 } node[pos=0.5] { 1/2 } node[pos=0.9] { 9/10 } ;

\node [] () at () { } ;
\coordinate [] () at ();

\path (0,0) node(x) {}
(3,1) node(y) {} ;
\draw (x) -- (y);

\coordinate (x) at (0,0);
\coordinate (y) at (3,1);
\draw (x) -- (y);

\filldraw
(0,0) circle (2pt) node[align=left, below] { test 1 \\ is aligned left } --
(4,0) circle (2pt) node[align=center, below] { test 2 \\ is centered } --
(8,0) circle (2pt) node[align=right, below] { test 3 \\ is right aligned } ;

\path (0,0) node(x) { Hello World! }
(3,1) node[circle,draw](y) { $ \int _ 1 ^ 2 x \mathrm d x $ } ;
\draw [->,blue] (x) -- (y);
\draw [->,red] (x) -| node[near start,below] { label } (y);
\draw [->,orange] (x) .. controls +(up:1cm) and +(left:1cm) .. node[above,sloped] { label } (y);

\draw [very thick] (0.5,0.5) .. controls (2,1).. (2.5,2.5)
node foreach \p in { 0,0.25,...,1 } [circle,fill=red,pos= \p ,inner sep=0pt,minimum size=1.5mm] {} ;
\node [left] at (.5,.30) { A } ;
\node [right] at (2.5,2.5) { B } ;
\path [ultra thick,latex-latex] (2,0) --(0,0)--(0,1.5);

\begin { tikzpicture }
\clip (1,1) circle (2);
\draw [red,fill] (0,0) rectangle (3,3);
\end { tikzpicture }

\begin { tikzpicture } [
mycircle/.style= { circle, draw=green!60, fill=green!5, ultra thick, minimum size=7mm } ,
myline/.style= { dotted, blue!60,-> } ,
]
\draw [myline] (0,0)node[mycircle] { $ \pi $ } to[out=45,in=135] (5,1) node[mycircle] { 3.414... } ;
\end { tikzpicture }

\begin { tikzpicture } [
mycircle/.style= { circle, draw=green!60, fill=green!5, ultra thick, minimum size=7mm } ,
myline/.style= { dotted, blue!60,-> } ,
]
\draw [myline] (0,0)node[mycircle] { $ \pi $ } to[out=45,in=135] (5,1) node[mycircle] { 3.414... } ;
% following drawing in the scope is shifted along y by 2cm
\begin { scope } [yshift=2cm]
\draw [myline] (0,0)node[mycircle] { $ \pi $ } to[out=45,in=135] (5,1) node[mycircle] { 3.414... } ;
\end { scope }
\end { tikzpicture }

\foreach \x in { 0,...,9 }
\draw ( \x ,0) circle (0.4);

\begin { frame }
\newcount\p
\animatevalue <3-10> { \p }{ 0 }{ 100 }
\begin { tikzpicture }
\path (0,0)rectangle(0.75 \paperwidth ,-0.75 \paperheight );
\path [draw] (0,0)..controls +(30:2) and +(40:2)..+(4,-1) node [pos= \p /100,sloped,above] { a } ;

\end { tikzpicture }
\end { frame }

% Define two layers (names could be changed)
\pgfdeclarelayer { background }
\pgfdeclarelayer { foreground }
%% Define there order of layer, here background is the bottom most and foreground is the topmost layer
\pgfsetlayers { background,main,foreground }

%% Whatever you draw here is drawn in the main layer
\draw (1,0) circle (2);

\begin { pgfonlayer }{ foreground } %% draw the curves that should be placed in foreground/top layer
\draw (0,0) arc (0:120:1);
\begin { pgfonlayer }

\begin { pgfonlayer }{ background } %% draw the curves that should be placed in background/bottm layer
\draw (0,0) rectangle(2,2);
\begin { pgfonlayer }

\usetikzlibrary { tikz }
\usetikzlibrary { patterns } %% in the beginning of tex file

\begin { document }
\begin { tikzpicture }
\draw [pattern=dots, pattern color=blue] (0,0) rectangle ++(1,1);
\draw [pattern=grid, pattern color=blue] (0,1) rectangle ++(1,1);
\draw [pattern=crosshatch, pattern color=blue] (0,2) rectangle ++(1,1);
\draw [pattern=crosshatch dots, pattern color=blue] (0,3) rectangle ++(1,1);
\draw [pattern=fivepointed stars, pattern color=blue] (0,4) rectangle ++(1,1);
\draw [pattern=sixpointed stars, pattern color=blue] (0,5) rectangle ++(1,1);

\draw [pattern=vertical lines, pattern color=blue] (0,6) rectangle ++(1,1);
\draw [pattern=horizontal lines, pattern color=blue] (0,7) rectangle ++(1,1);
\draw [pattern=north east lines, pattern color=blue] (0,8) rectangle ++(1,1);
\draw [pattern=north west lines, pattern color=blue] (0,9) rectangle ++(1,1);
\end { tizpicture }
\end { document }

\usetikzlibrary { snakes }
\begin { tikzpicture } [thick]
\draw [snake=bumps] (0,0) -- (3,0); % Semicircle/bumps along the line.
\draw [snake=zigzag] (0,1)-- (3,1); % a zig-zag pattern
\draw [snake=saw] (0,2) -- (3,2); % saw type line
\draw [snake=brace] (0,3)-- (3,3); % a brace between two points
\draw [snake=coil,segment length=4pt] (0,4)-- (3,4); % like a coil
\draw [snake=coil,segment aspect=0] (0,5) -- (3,5); % like a sinusoidal wave
\draw [snake=snake] (0,6) -- (3,6); % sinusoidal wave (similar to coil)
\draw [snake=expanding waves,segment angle=7] (0,7)-- (3,7); % like a expaning wavefront
\draw [snake=border,segment angle=-45] (0,8) -- (3,8); % slanted lines along the path
\draw [snake=triangles] (0,9) -- (3,9); % Triangles along the path
\draw [snake=tiks] (0,10) -- (3,10); % vertical tiks along the path
\draw [snake=crosses] (0,11) -- (3,11); % crosses along the path
\end { tikzpicture }

\coordinate (A) at (2,3);
\coordinate (B) at (1.5,2.5);
\coordinate (B) at ( $ ( A ) + ( B ) $ )
\coordinate (B) at ( $ ( A ) - ( B ) $ )
\coordinate (B) at ( $ ( A ) + 2 *( A ) $ )

\coordinate (A) at (0,0);
\coordinate (B) at (90:3);
\coordinate (B) at (0:4);
\coordinate (Ap) at ( $ ( B )! 0 . 5 !( C ) $ );
\coordinate (Bp) at ( $ ( A )! 0 . 5 !( C ) $ );
\coordinate (Cp) at ( $ ( A )! 0 . 5 !( B ) $ );
\draw (A)--(B)--(C)--cycle
(A)--(Ap)
(B)--(Bp)
(C)--(Cp);

\usetikzlibrary { calc }
\begin { tikzpicture }
\draw [help lines] (0,0) grid (3,3);
\coordinate (a) at (rnd,rnd);
\coordinate (b) at (3-rnd,3-rnd);
\draw (a) -- (b);
\node (c) at (1,2) { x } ;
\draw let \p 1 = ( $ ( a )!( c )!( b ) - ( c ) $ ),
\n 1 = { veclen( \x 1, \y 1) }
in circle [at=(c), radius= \n 1];
\end { tikzpicture }

\usepackage { tikz }
\usetikzlibrary { intersections }

\begin { document }
\begin { tikzpicture }
\draw [name path=line,smooth] (0,5)--(1.5,5);
\draw [name path=curve,smooth] (1.5,6) to[out=270,in=90] (0,3);
\draw [name intersections={of=line and curve}] (intersection-1) circle[radius=0.1];
\end { tikzpicture }
\end { document }

\begin { tikzpicture }
\draw [name path=grid] [xstep=3,ystep=2] (0,0) grid (9,8);
\draw [->, name path=line] (2,1) -- (7,7);
\draw [name intersections={of=grid and line, sort by=line, name=i, total=\t}]
\foreach \s in { 1,..., \t }{ (i- \s ) node { \s }} ;
\end { tikzpicture }

\pgfmathparse { add(75,6) } \pgfmathresult

\draw [domain=xmin:xmax] plot ( \x , { function } );

\draw [help lines] (-2,0) grid (2,4);
\draw [->] (-2.2,0) -- (2.2,0);
\draw [->] (0,0) -- (0,4.2);
\draw [green, thick, domain=-2:2] plot ( \x , { 4- \x*\x } );
\draw [domain=-2:2, samples=50] plot ( \x , { 1+cos(pi* \x r) } );

\documentclass { article }
\usepackage { tikz }
\begin { document }
\begin { tikzpicture }
\draw [thick,rounded corners=8pt] (0,0) -- (0,2) -- (1,3.25)
-- (2,2) -- (2,0) -- (0,2) -- (2,2) -- (0,0) -- (2,0);
\end { tikzpicture }
\end { document }

\documentclass { article }
\usepackage { tikz }
\begin { document }
\begin { tikzpicture } [scale=3]
\draw [step=.5cm, gray, very thin] (-1.2,-1.2) grid (1.2,1.2);
\filldraw [fill=green!20,draw=green!50!black] (0,0) -- (3mm,0mm) arc (0:30:3mm) -- cycle;
\draw [->] (-1.25,0) -- (1.25,0) coordinate (x axis);
\draw [->] (0,-1.25) -- (0,1.25) coordinate (y axis);
\draw (0,0) circle (1cm);
\draw [very thick,red] (30:1cm) -- node[left,fill=white] { $ \sin \alpha $ } (30:1cm |- x axis);
\draw [very thick,blue] (30:1cm |- x axis) -- node[below=2pt,fill=white] { $ \cos \alpha $ } (0,0);
\draw (0,0) -- (30:1cm);
\foreach \x / \xtext in { -1, -0.5/- \frac { 1 }{ 2 } , 1 }
\draw ( \x cm,1pt) -- ( \x cm,-1pt) node[anchor=north,fill=white] { $ \xtext $ } ;
\foreach \y / \ytext in { -1, -0.5/- \frac { 1 }{ 2 } , 0.5/ \frac { 1 }{ 2 } , 1 }
\draw (1pt, \y cm) -- (-1pt, \y cm) node[anchor=east,fill=white] { $ \ytext $ } ;
\end { tikzpicture }
\end { document }

\documentclass { article }
\usepackage { tikz }
\begin { document }
\begin { tikzpicture }
\draw (-1,0) to[bend left] (1,0);
\draw (-1.2,.1) to[bend right] (1.2,.1);
\draw [rotate=0] (0,0) ellipse (100pt and 50pt);
\end { tikzpicture }
\end { document }

\documentclass { article }
\usepackage { tikz }
\begin { document }
\begin { tikzpicture } [domain=0:4]
\draw [very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9);
\draw [->] (-0.2,0) -- (4.2,0) node[right] { $ x $ } ;
\draw [->] (0,-1.2) -- (0,4.2) node[above] { $ f ( x ) $ } ;
\draw [color=red] plot ( \x , \x ) node[right] { $ f ( x ) = x $ } ;
\draw [color=blue] plot ( \x , { sin( \x r) } ) node[right] { $ f ( x ) = \sin x $ } ;
\draw [color=orange] plot ( \x , { 0.05*exp( \x ) } ) node[right] { $ f ( x ) = \frac { 1 }{ 20 } \mathrm e^x $ } ;
\end { tikzpicture }
\end { document }



Last edited 18 days ago by Ajmalkoti


One way to draw graphics directly with TeX commands is PGF/TikZ . Ti k Z can produce portable graphics in both PDF and PostScript formats using either plain (pdf)TEX, (pdf)Latex or ConTEXt. It comes with very good documentation and an extensive collection of examples: http://www.texample.net/tikz/

PGF ("portable graphics format") is the basic layer, providing a set of basic commands for producing graphics, and Ti k Z ("Ti k Z ist kein Zeichenprogramm" or "Ti k Z is not a Drawing program") is the frontend layer with a special syntax, making the use of PGF easier. Ti k Z commands are prevalently similar to Metafont, the option mechanism is similar to PsTricks syntax.

While the previous systems ( picture , epic , pstricks or metapost ) focus on the how to draw, Ti k Z focuses more on the what to draw. One could say that Ti k Z is to picture as LaTeX is to TeX. It's recommended to use it if your LaTeX distribution includes it.

Other packages building on top of Ti k Z (e.g., for drawing electrical circuits) can be found here: https://www.ctan.org/topic/pgf-tikz

In the following some basics of Ti k Z are presented.

Using Ti k Z in a LaTeX document requires the tikz package which can be loaded by adding following command in preamble of latex document :

This will provide basic functionalities, and also load the pgf package automatically. For special features special libraries must be included. It requires following in the preamble part of the code.

A list of common libraries is following

The figures are drawn in the main body part the Tex document. There are two ways to use it

The entire figure can be scaled using the

or different for height and width, e.g:

Coordinates are specified in round brackets in an arbitrary TEX dimension either using Cartesian coordinates (comma separated), e.g. 1cm in the x direction and 2pt in the y direction

In the first row of table the Cartesian coordinates (comma separated) are shown.
In the second row the polar coordinates (colon separated), e.g. 1cm in 30 degree direction

Relative coordinates to the previous given point are given by adding one or two plus signs in front of the coordinate. With " ++ " the last point of the path becomes the current position, with " + " the previous point stays the current path position. Example: 2 standard units to the right of the last point used:

The coordinates can be associated with a name, e.g. A= (2,3), in many ways as stated following

A path is a series of straight and curved line segments (in a simplified explanation). The instruction has to end with a semicolon.

One instruction can spread over several lines, or several instructions can be put on one line.


Options for path actions are e.g: " draw ", " fill ", " pattern ", " shade ", " clip " , " use as bounding box ". These may be used as following
Above command can also be written equivalently as " \draw ", " \fill ", " \filldraw ", " \pattern ", " \shade ", " \shadedraw ", " \clip ", " \useasboundingbox " . These commands are explained in details in subsequent section

Geometric path options: " rotate= ", " xshift= ", " yshift= ", " scale= ", " xscale= ", " yscale= ".

The most common way is to specify just the color name or " color= ". In this case it will color the boarders/area according to the command (\draw,\fill) used.

There can be different elements in a drawing so it may require specifying them separately for which one may use

" draw= ", " draw opacity= "

" fill= ", "fill opacity = "

" text= ", " text opacity= "

Predefined colors: red, green, blue, cyan, magenta, yellow, black, gray, darkgray, lightgray, brown, lime, olive, orange, pink, purple, teal, violet and white.

The opacity factor values can be in range of 0 (=fully transparent) to 1 (=fully opaque).

Line width options: " line width= ", and abbreviations " ultra thin " for 0.1pt, " very thin " for 0.2pt, " thin " for 0.4pt (the default width), " semithick " for 0.6pt, " thick " for 0.8pt, " very thick " for 1.2pt, " ultra thick " for 1.6pt.

Line end, line join options: " line cap= ", " arrows=- ", " rounded corners ", " rounded corners= ", " line join= ".

Line pattern options: " dash pattern= " (e.g. " dash pattern=on 2pt off 3pt on 4pt off 4pt "), " dash phase=⟨dash phase⟩ ", " solid ", " dashed ", " dotted ", " dashdotted ", " densely dotted ", " loosely dotted ", " double ".


Options for filling paths are e.g. " fill= ", " pattern= ", " pattern color= "

The draw command can be used in several ways with different options. A few examples are provided as follows.

or first vertical then horizontal, use

(The syntax for a bend to the right may seem a little counter-intuitive. Think of it as an instruction to veer to the right at the beginning of the path and then smoothly curve to the end point, not as saying that the path curves to the right throughout its length.)

The line has many attributes which can be altered according requirement. For example in following example we chose the line color as red, line pattern as dashed, and the line width as very thick.

Examples for changing the arrow tips

very thin,
thin
semi thick
thick
very thick
ultra thick

For rectangles a special syntax exists. Use a move-to operation to one corner and after " rectangle " the coordinates of the diagonal corner. The last one becomes the new current point.

The fill color " green!20!white " means 20% green and 80% white mixed together.

A node is used to place some text at given coordinate. Nodes are not part of the path itself, they are added to the picture after the path has been drawn.

The node can be placed inside rectangle or circle or other simple shapes. A node can be placed in several ways

Different options are available, some of which are described in below table. A few examples are provided later for their better explanation.

Note: The size of node = max(minimum width, inner sep). To achieve smaller size, you must reduce both.

A few examples are given below to explain the options


Writing text along a given path using the node command is shown as a simple example:

To place nodes on a line or a curve use the " pos= " option, where fraction is a floating point number between 0 representing the previous coordinate and 1 representi
Pretty Young Teen Porno
Homemade Sleeping Sex
Hot Nude Women Sex Videos

Report Page