Tikz

From TORI
Jump to: navigation, search

Tikz is graphical extension of Latex

Tikz, if supported by the current Latex software, can be used to generate picture for the latex documents; this way seems to be more efficient, than generation of EPS and the including.

Some examples are suggested below.

Standalone

\documentclass{standalone}
%\documentclass[12pt]{article}
\usepackage{tikz}                                 
\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (1,1);
%\node [draw,minimum size=25pt] at (-1,0.5) {A};
\put(.5,.5){a} 
\end{tikzpicture}
  
\begin{tikzpicture}
\draw [help lines] (-2,-2) grid (2,2);
\node [draw] at (-1,1.5) {A};
\node [draw] at (0,1.5) {a};
\node [draw,minimum size=25pt] at (-1,0.5) {A};
\node [draw,minimum size=25pt] at (0,0.5) {a};
\node [draw,minimum width=3cm] at (0,-0.5) {Node B};
\node [draw,minimum height=8mm] at (-1,-1.5) {Node B};
\end{tikzpicture}                                                               

\end{document}

Color

The goal of the example below is to reveal wether tikz conflicts with xcolor. No conflit is detected. An also to check placement of text into the tikz figure.

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{xcolor}

\begin{document}

This picture was drawn with TikZ\\
https://getreuer.info/tutorials/tikz-for-high-quality-latex-pictures/index.html
:

{\color[rgb]{1,0.2,0.3} test}
{\color[HTML]{ff0000} test}
{\color[HTML]{00ff00} test}
test

\begin{tikzpicture}[scale=2]
% Draw thin grid lines with color 40% gray + 60% white
\draw [step=0.5,thin,gray!40] (-1.4,-1.4) grid (1.4,1.4);

% Draw x and y axis lines
\draw [->] (-1.5,0) -- (1.5,0) node [below] {$x$};
\draw [->] (0,-1.5) -- (0,1.5) node [left] {$y$};

% Draw a blue circle at the origin of radius 1
\draw [semithick,blue] (0,0) circle (1);
%\draw [semithick,#00f] (0,0) circle (1);
%\draw [semithick,{HTML}{09E}](0,0) circle (1);
%\draw [semithick,\color[rgb]{1,0.2,0.3}] (0,0) circle (1);
%\draw [semithick,\color[rgb]{1,0.2,0.3}] (0,0) circle (1);
%\draw [semithick,\color[html]{aa0000}] (0,0) circle (1);
%\draw [semithick,\color[html]{a00}] (0,0) circle (1);
% Draw a triangle with vertices (0,0), (1,0), (1,0.7)
{\color[HTML]{00ff00} 
\draw [semithick] (0,0) circle (1);
}

\draw [semithick,blue] (0,0) -- (1,0) -- (1,0.7) -- cycle;

%\draw (2,3) node [center] {LaTeX code};
\draw (-1,0) node [below] {Point $A$} -- 
      (1,1) node [below] {Point $B$};

\draw (-1,0) node [above] {above} -- 
      (1,1) node [above] {above};

\draw (-1,0) node [left] {left} -- 
      (1,1) node [right] {right};

\end{tikzpicture}

\end{document}

Grid

\documentclass{article}
\usepackage{xcolor}
\usepackage{tikz}
\begin{document}
https://www.verbosus.com/tikz-drawing-in-latex.html
\begin{tikzpicture}
\draw (0,0) grid (7,2);
{\color[HTML]{00aa00}
\draw (0,0) -- (1,2) -- (3,3) -- (4,2);
}
\draw (2,0) -- (3,2);
\end{tikzpicture}
\end{document}

References