2

How to do the following in LaTeX with TikZ?

enter image description here

7

Very primitive TikZ solution (still learning ;-)):

\documentclass{article}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
  \draw[gray]  (0,0) -- (0,6cm);
  \draw[gray,dashed] (0cm,6cm) -- (0,7cm);

  \fill ( 0,0cm) circle[radius=1mm,black];
  \fill ( 0,3cm) circle[radius=1mm,black];
  \fill ( 0,6cm) circle[radius=1mm,black];
  \node   at (0.5cm,3cm)  {$\mathbb{R}$} ;
  \node   at (0.5cm,6cm)  {$\mathbb{C}$} ;
  \node   at (0.5cm,0cm)  {$\mathbb{Q}$} ;
\end{tikzpicture}
\end{document}

enter image description here

Edit -- some improvement

\documentclass{article}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
  \coordinate (A) at (0,0); 
  \coordinate (B) at (0,3cm);
  \coordinate (C) at (0,6cm);
  \coordinate (D) at (0,7cm);
  \draw[gray,line width=1.5pt]  (A) -- (C);
  \draw[gray,dashed,line width=1.5pt] (C) -- (0,7cm);
  \fill (A) circle[radius=1mm,black];
  \fill (B) circle[radius=1mm,black];
  \fill (C) circle[radius=1mm,black];
  \node [xshift=0.5cm]  at (A)  {$\mathbb{Q}$} ;
  \node [xshift=0.5cm]  at (B)  {$\mathbb{R}$} ;
  \node [xshift=0.5cm]  at (C)  {$\mathbb{C}$} ;
  \node [xshift=0.5cm]  at (D)  {?};
\end{tikzpicture}
\end{document}
  • 1
    I love your first solution because of his semplicity. Thank you and happy new year! Another question. If I want change the colour of the circle how to do that? For instance, if I put red instead of black nothing happens. Thank you! – Andrea Leo Jan 1 '16 at 23:33
  • How about (for the first one): \foreach \x/\label in {% 0/$\mathbb{Q}$, 3/$\mathbb{C}$, 6/$\mathbb{R}$, 7/? }{ \ifnum\x<7 \node[fill=black, circle, inner sep=0, minimum size=2mm, label=0:\label] at (0,\x) {}; \else \node[inner sep=0, minimum size=2mm, label=0:\label] at (0,\x) {}; \fi } :P Even shorter! – Alenanno Jan 2 '16 at 0:41
7

Like this?

output

It is easy:

\documentclass[border=3mm,tikz]{standalone}
\usetikzlibrary{calc,chains}

    \usepackage{amssymb}
\begin{document}
    \begin{tikzpicture}[
node distance = 11mm,
  start chain = going above,
   set/.style = {shape=circle, fill= red,% fill determine color of fill
                 inner sep=2pt, outer sep=0pt,
                 label=right:$\mathbb{#1}$,
                 join= by -, on chain,
                 node contents={}}
                      ]
\node (q) [set=Q];
\node (r) [set=R];
\node (c) [set=C];
\draw (c) -- +(0,0.5);
\draw[dashed] ($(c)+(0,0.5)$) -- + (0,0.7) node[right] {?};
    \end{tikzpicture}
\end{document}

For nodes N positioning is used TikZ library chains, position of node with ? is used library calc. Text to nodes is added as labels with exception of nodes with ?.

Edit: Benefits of the above code is that the node style is determined in a single place;, also the placement is determined centrally by node distance. So any changes to the picture is easy to implement. For example, now I change the color of nodes and make them a bit smaller.

Probably this approach seems to be less intuitive or complicated for beginners. However, after drawing for example fifty similar pictures, the shown approach will show it's advantage. :-)

  • @AndreaLeo, thank you for your wishes. The same to you, and many happy (La)TeX-ing! – Zarko Jan 1 '16 at 23:53
  • As a matter of fact I am a beginner :) Thank you! your edit is very useful to me! Again, have a nice 2016! – Andrea Leo Jan 2 '16 at 11:45
5

Une solution assez simple (tu aurais pu essayer!)

A simple solution (you could have a try!)

enter image description here

\documentclass[a4paper,11pt]{article}                       
\usepackage[frenchb]{babel}                 
\usepackage[T1]{fontenc}    
\usepackage{amssymb }

\usepackage{tikz} 

\begin{document}

\begin{tikzpicture}


\node[circle,fill,inner sep=0,minimum size=2mm,label={right:$\mathbb Q$}](Q) at (0,0){};
\node[circle,fill,inner sep=0,minimum size=2mm,label={right:$\mathbb R$}](R) at (0,2){};
\node[circle,fill,inner sep=0,minimum size=2mm,label={right:$\mathbb C$}](C) at (0,4){};

\draw[thick,blue] (Q) --(R)-- (C);
\draw[thick,dashed,blue] (C)--++(0,1);
\end{tikzpicture}

\end{document}
5

A one-line solution for conciseness:

\documentclass[tikz,border=10pt]{standalone}
\usepackage{amssymb}
\begin{document}
\begin{tikzpicture}
  \path [draw, fill, every node/.style={right}] circle (1pt) node {$\mathbb{Q}$} -- ++(0,1) circle (1pt) node {$\mathbb{R}$} -- ++(0,1) circle (1pt) node {$\mathbb{C}$} -- ++(0,.25) edge [dashed] node [pos=1] {$?$} ++(0,.75) ;
\end{tikzpicture}
\end{document}

one-line solution

If the line should be grey but the circles black, then it is probably easier to use two lines:

\documentclass[tikz,border=10pt]{standalone}
\usepackage{amssymb}
\begin{document}
\begin{tikzpicture}
  \draw [draw=gray, every node/.style={right}] (0,0) node {$\mathbb{Q}$} -- ++(0,1)  node {$\mathbb{R}$} -- ++(0,1) node {$\mathbb{C}$} -- ++(0,.25) edge [dashed] node [pos=1] {$?$} ++(0,.75) ;
  \path [fill, draw] circle (1pt)  ++(0,1) circle (1pt)  ++(0,1) circle (1pt) ;
\end{tikzpicture}
\end{document}

two-liner

4

A PSTricks solution:

\documentclass{article}

\usepackage{pstricks}
\usepackage{amssymb}
\usepackage{mlist}

\newmset\setQ{Q}
\newcommand*\set[2]{\uput[0](0.05,#1){$#2$}}

\begin{document}

\begin{pspicture}(0.45,6)
  \psline[linecolor = gray](0.05,0.1)(0.05,4.8)
  \psline[linecolor = gray, linestyle = dashed](0.05,4.8)(0.05,5.9)
  \psdots[dotsize = 3pt 2](0.05,0.15)(0.05,2.075)(0.05,4)
  \uput[0](0.05,5.9){$?$}
  \set{4}{\setC}
  \set{2.075}{\setR}
  \set{0.15}{\setQ}
\end{pspicture}

\end{document}

output

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.