2

I would like check if it is possible to draw a number line that is similar to the one shown. And if it is possible, how should I go about doing it? Thank you!

enter image description here

        \begin{tikzpicture}[



            letter/.style={circle, minimum size=5pt, inner sep=0, outer sep=0, fill=black, label=below:#1},

            number/.style={fill=white, pos=.5}
            ]

            \draw (0,0) --
                node(A)[letter=$0$,pos=.1]{}
                node(B)[letter=$\mu$,pos=.2]{}
                node(C)[letter=$\bar{c}$,pos=.7]{}
                node(D)[letter=$d$,pos=.9]{}
                  (8,0)
            ;

            \draw[ultra thick] (0.8,0) -- (5.6,0);    

        \end{tikzpicture}
  • 1
    Have you searched a bit on this site? What have you tried? – Werner Mar 17 '17 at 00:22
  • Hi Werner, yes I have, but the best I could do is the code shown above. Sorry I'm pretty new to this site, I'm not sure how to paste the code correctly. – Nicholas Mar 17 '17 at 09:29

2 Answers2

3

To get you started:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\foreach \x/\y in {0/0, 1/\mu, 4/\bar{c}, 5/d}
 \draw[ultra thick] (\x,0.25) -- (\x,-0.25) node[below]{$\y$};
\draw[ultra thick] (-0.5,0)--(5.5,0);
\end{tikzpicture}
\end{document}

enter image description here

For more information, see the pgf/tikz manual

Zarko
  • 296,517
JPi
  • 13,595
2

A simple solution with pstricks:

\documentclass[border=3pt]{standalone}
\usepackage{pstricks-add, auto-pst-pdf}%

\begin{document}

\begin{pspicture}
\psline(0,0)(10,0)
\dotnodes[dotstyle=|, dotscale= 1.5 4](1,0){O}(3,0){M}(7,0){C}(9,0){D}
\psset{labelsep=8pt, linejoin=1}
\nput{-90}{O}{$ 0 $}
\nput{-90}{M}{$ \mu $}
\nput{-90}{C}{$ \bar c $}
\nput[labelsep = 7pt]{-90}{D}{$ d $}
\pnodes[0,-0.8](1,0){O1}(7,0){C1}
\psbrace[braceWidthInner=5pt, braceWidthOuter=3pt, braceWidth=0.8pt, rot=90, nodesepA=-2pt, nodesepB=8pt,](O1)(C1){$ a $}
\end{pspicture}

\end{document} 

enter image description here

A variant with a ncbar connection, and a simpler code:

\documentclass[border=3pt, svgnames]{standalone}
\usepackage{pstricks-add, auto-pst-pdf}%

\begin{document}

\begin{pspicture}
\everypsbox{\strut}\psset{linejoin=1}
\psline(0,0)(10,0)
\dotnodes[dotstyle=|, dotscale= 1.5 4](1,0){O}(3,0){M}(7,0){C}(9,0){D}
\nput{-90}{O}{$ 0 $}
\nput{-90}{M}{$ μ$}
\nput{-90}{C}{$ \bar c $}
\nput{-90}{D}{$ d $}
\ncbar[linecolor=Tomato, nodesep=0.7, angle =-90]{*-*}{O}{C}\ncput*{$ a $}
\end{pspicture}

\end{document} 

enter image description here

Bernard
  • 271,350
  • Hi Bernard, thank you! Could I check if it is possible to change the brace to a solid line instead with solid circles at both end points? – Nicholas Mar 17 '17 at 10:59
  • Not sure I understand well, but I'll post a variant in a moment. – Bernard Mar 17 '17 at 11:23
  • i'd suggest also using \struts in the placement of the labels so their baselines are aligned vertically. – Werner Mar 17 '17 at 11:32
  • @Werner: Excellent suggestion! Thanks for reminding me. – Bernard Mar 17 '17 at 11:40
  • @Nicholas: Please see if the variant I posted suits what you want. – Bernard Mar 17 '17 at 12:00
  • Hi Bernard, yes that's what I wanted! However, I'm not sure why but I cannot run the code. I am always returned with

    "Package auto-pst-pdf Error:"shell escape" (or "write18") is not enabled:auto-pst-pdf will not work!.See the auto-pst-pdf package documentation for explanation.Type H for immediate help.... Or turn off auto-pst-pdf.}"

    Does this package have a conflict with some other packages?

    – Nicholas Mar 18 '17 at 07:54
  • @Nicholas: There's no conflict. To use pstricks code with pdflatex (which has no computing engine), you have to launch the compiler with the --enable-write18 switch (under MiKTeX) or -shell-escape (TeX Live, MacTeX). It will delegate the computations and cropping to ghostscript. Alternatively, you can compile with xelatex, but you have to give the dimensions of the pspicture environment: (0,-1.3)(10,0.2) – or give a rogh estimate, and use pdfcrop. – Bernard Mar 18 '17 at 10:08