banner



How To Draw A Rectangle In Latex

This tutorial gives a brief introduction in how to draw in LaTeX using the TikZ package. TikZ allows y'all to create and include vector graphics directly in your LaTeX document.

TikZ setup

In order to use TikZ you must include the package using the \usepackage{tikz} command. Within the document you create a new picture using \brainstorm{tikzpicture} and \end{tikzpicture}. Everything in between these two commands is interpreted as an image.

Drawing lines

You tin can use the \describe command to specify the coordinates of the line and -- to specify to draw a straight line. Coordinates are in centimeters by default.

\documentclass{article} \usepackage{tikz} \begin{document}     \brainstorm{tikzpicture}         \draw (0,0) -- (2,4);     \cease{tikzpicture} \end{document}            

You lot can specify a sequence of points for the line and draw multiple lines in ane picture. The filigree command draws a grid to meet where the points exactly are.

\documentclass{article} \usepackage{tikz} \brainstorm{certificate}     \brainstorm{tikzpicture}         \draw (0,0) grid (four,3);         \draw (0,0) -- (1,2) -- (3,iii) -- (4,ii);         \draw (2,0) -- (three,2);     \end{tikzpicture} \end{document}            

Scaling pictures

You tin can scale an image upward or down past using the calibration option.

\documentclass{article} \usepackage{tikz} \brainstorm{certificate}     \begin{tikzpicture}[calibration=0.five]         \draw (0,0) filigree (ii,2);         \draw (0,0) -- (1,1);     \end{tikzpicture}      \begin{tikzpicture}[scale=2]     	\draw (0,0) grid (2,two);     	\depict (0,0) -- (1,1);     \end{tikzpicture} \end{certificate}            

Drawing arrows

The draw command accepts several different options that change the appearance of the line endings.

\documentclass{commodity} \usepackage{tikz} \begin{document}     \begin{tikzpicture}     	\describe [->] (0,2) -- (1,3);     	\depict [<-] (one,2) -- (2,3);     	\describe [|->] (2,2) -- (three,three);         \draw [<->] (3,2) -- (4,3);         \draw [<->] (1,1) -- (1,0) -- (iii,0);     \terminate{tikzpicture} \end{document}            

Line thickness

You can change the thickness of every unmarried line so that it matches your requirements. You can use: ultra thin, very sparse, thin, semithick, thick, very thick and ultra thick.

\documentclass{article} \usepackage{tikz} \begin{document}     \begin{tikzpicture}     	\describe [<->] (0,4) -- (0,0) -- (four,0);     	\describe [thick] (0,three) -- (three,0);     	\draw [ultra thick] (0,0) -- (three,3);     	\depict [ultra sparse] (ii,0) -- (2,2) -- (0,2);     \terminate{tikzpicture} \end{document}            

You can specify your custom width using the line width selection of the \draw control. The default unit is pt.

\documentclass{article} \usepackage{tikz} \begin{document}     \begin{tikzpicture}     	\describe [<->, line width=i] (0,4) -- (0,0) -- (4,0);     	\draw [line width=0.5mm] (0,3) -- (three,0);     	\describe [line width=0.1cm] (0,0) -- (three,three);     	\draw [line width=0.i] (ii,0) -- (2,2) -- (0,2);     \finish{tikzpicture} \end{document}            

Coloring lines

You can requite every line a dissimilar color. There are several predefined ones but you lot can as well utilize your ain by adding \definecolor{mycolor}{rgb}{0,0.vi,0.v} in the preamble of your document.

\documentclass{commodity} \usepackage{tikz} \definecolor{mycolor}{rgb}{0,0.six,0.v} \begin{document}     \brainstorm{tikzpicture}     	\draw [thick, grey] (0,i) -- (ii,one);     	\describe [thick, mycolor] (0, 0.5) -- (2,0.five);     	\describe [thick, blue] (0,0) -- (ii,0);     \stop{tikzpicture} \end{document}            

Drawing shapes

You tin can draw shapes like rectangle, circle, stars, etc. There exist much more. The post-obit example depicts only a few.

\documentclass{article} \usepackage{tikz} \begin{document}     \begin{tikzpicture}         \draw [bluish] (0,0) rectangle (2,1);         \describe [crimson, thick] (2,one) circle [radius=0.v];         \depict [dark-green, ultra thick] (0,0.5) ellipse [ten radius = 0.5cm, y radius = 1cm];     \end{tikzpicture} \end{document}            

Source: https://verbosus.com/tikz-drawing-in-latex.html

Posted by: hoffmanvalinarts.blogspot.com

0 Response to "How To Draw A Rectangle In Latex"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel