5

First of all, this is a great site it's taught me so much about latex and hopefully I can also learn how to draw diagrams.

The diagram is from a youtube video explaining complex numbers:

enter image description here

I imagine the code looks something like this:

\documentclass[11pt]{article} %allowed 12pt
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}

%text explaining the diagram goes here 

\begin{tikzpicture}
%\begin{centre}
 \draw[latex-latex] (-4.5,0) -- (4.5,0) ; %edit here for the axis
\foreach \x in  {-4,-3,-2,-1,0,1,2,3,4} % edit here for the number on vertical lines
\draw[shift={(\x,0)},color=black] (0pt,3pt) -- (0pt,-3pt);%mooves top daches, (left tilt, up hight)---(right tilte, down hight)

%up arrow for \sqrt {-1}\in \mathbb{C} 
\foreach \x in {-\infty \in \mathbb{Z} ,,-\sqrt {2}\in \mathbb{R},-\dfrac {1} {1}\in \mathbb{Q} ,0,1\in \mathbb{N},\dfrac {2} {4}\in \mathbb{Q},\pi\in\mathbb{R} ,\infty \in \mathbb{Z} } % edit here for the numbers at each position
%down arrow for -\sqrt {-1}\in \mathbb{C} 

\draw[shift={(\x,0)},color=black] (0pt,0pt) -- (0pt,-3pt) node[below]{$\x$};%mooves botom dashes
%\end{centre}

\end{tikzpicture}

%text after the diagram goes here

\end{document}

Thanks for the help, I've tried looking into the pgfmanual, but can't seem to find an example to follow.

6

Are you looking for something like this? Below I provide raw coding (i.e. I do not use cycles or anything like that). I don't understand if you want just that drawing or a macro to draw any picture you want in that style.

diagram of some complex numbers

\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[xscale = 1.5]

% draw axis
\draw [thick, ->] (0,0.25) -- (0,2.2);
\draw [thick, ->] (0,-0.65) -- (0,-2.2);
\draw [thick, <->] (-4.5,0) -- (4.5,0);

% draw lines in x axis
\draw (0,-0.2) -- (0,0.2); % zero
\draw (0.5,-0.2) -- (0.5,0.2); % 2/4 \in \mathbb{Q}
\draw (1.3,-0.2) -- (1.3,0.2); % 1 \in \mathbb{N}
\draw (-1,-0.2) -- (-1,0.2); % -1/1 \in \mathbb{Q}
\draw (3.14159265359,-0.2) -- (3.14159265359,0.2); % \pi \in \mathbb{R}
\draw (4,-0.2) -- (4,0.2);
\draw (-4,-0.2) -- (-4,0.2);
\draw (-2,-0.2) -- (-2,0.2); %-\sqrt(2) \in \mathbb{R}

% write math symbols
\node [below] at (0,-0.2) {$0$};
\node [below] at (0.5,-0.2) {$\frac{2}{4}\in\mathbb{Q}$};
\node [below] at (1.3,-0.2) {$1\in\mathbb{N}$};
\node [below] at (-1,-0.2) {$-\frac{1}{1}\in\mathbb{Q}$};
\node [below] at (3.14159265359,-0.2) {$\pi\in\mathbb{R}$};
\node [below] at (-2,-0.2) {$-\sqrt{2}\in\mathbb{R}$};
\node [above] at (4,0.2) {$\infty$};
\node [above] at (-4,0.2) {$-\infty$};
\node [right] at (0,1.5) {$\sqrt{-1} \in \mathbb{C}$};
\node [left] at (0,-1.5) {$-\sqrt{-1} \in \mathbb{C}$};

\end{tikzpicture}

\end{document}
  • Just the exact drawing is fine because I learn just by playing around with the code. What are cycles and how would it improve this code. If you have some resource/macro to learn how to do any picture in that style would be fantastic. Then maybe I'll be able to learn how to make the lines a bit more bold and make it look like the hand drawn version. – UniStuffz Jan 12 '17 at 8:56
  • I'm not that versed in TikZ, sadly. I have yet to read the manual, which I link here: ctan.org/pkg/pgf – Ignacio Correa Jan 12 '17 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.