Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am transferring a professor's .doc files to LaTeX so that we can do more sophisticated formatting and I ran across a problem.

I would like to recreate this number line in LaTeX.

number line

Help with which package to use and which commands to study would be a great help.

share|improve this question
    
see this: tex.stackexchange.com/questions/45006/… –  alfC Aug 20 '12 at 22:59
add comment

2 Answers 2

up vote 16 down vote accepted

You can use TikZ; the manual is great and contains numerous examples; in the following example, the basic constructs are \node and \draw:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
% a straight line segment
\draw (0.5,0) -- (10.5,0);
% the ticks and their labels
\foreach \x  in {1,...,10}
  \draw[xshift=\x cm] (0pt,2pt) -- (0pt,-1pt) node[below,fill=white] {\the\numexpr\x +112\relax};
% the thicker segment
\draw[ultra thick] (2.06,0) -- (8.94,0);
% the labels
\node[fill=white,draw=black,circle,inner sep=2pt,label=above:{$L_1=114.06$}] at (2.12,0) {};
\node[fill=white,draw=black,circle,inner sep=2pt,label=above:{$L_1=119.94$}] at (8.9,0) {};
\node at (5.5,-0.8) {$\mu$};
\end{tikzpicture}

\end{document}

enter image description here

And here's a variation using pgfplots (which internally uses TikZ and is very useful for plots):

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
  axis y line=none,
  axis lines=left,
  axis line style={-},
  xmin=112.5,
  xmax=121.5,
  ymin=0,
  ymax=1,
  xlabel=$\mu$,
  scatter/classes={o={mark=*}},
  restrict y to domain=0:1,
  xtick={113,114,...,121}
]
\addplot table [y expr=0,meta index=1, header=false] {
114.06 o
119.94 o
};
\node[coordinate,label=above:{$L_1=114.06$}] at (axis cs:114.06,0.05) {};
\node[coordinate,label=above:{$L_2=119.94$}] at (axis cs:119.94,0.05) {};
\end{axis}
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
    
What do the ymin and ymax do? –  soandos Aug 21 '12 at 4:06
    
@soandos >.>, the produced graph has a lower bound of 112.5 and an upper bound of 121.5, let's play "pin the tail on the observable." –  Jeff Langemeier Aug 21 '12 at 4:30
    
@JeffLangemeier As far as I can tell it slightly changes the height of L1 and L2 (tried 10,100,1000 for ymax) –  soandos Aug 21 '12 at 5:12
    
@soandos, And now I get red on my face, yes, the y bound handles the vertical, but since a line graph has no vertical it doesn't really do squat. Tired-dyslexia causes y and x confusion tonight, stellar. –  Jeff Langemeier Aug 21 '12 at 5:36
    
@JeffLangemeier don't sweat it –  soandos Aug 21 '12 at 5:38
show 5 more comments

You don't really need any extra packages for that kind of diagram, LaTeX can do that unaided:

enter image description here

\documentclass{article}

\begin{document}
\newcounter{nn}
\setlength\unitlength{2pt}

\begin{picture}(100,100)

\put(10,60){$L_1=114.06$}
\put(70,60){$L_2=119.94$}
\put(50,30){$\mu$}
\put(0,50){\line(1,0){100}}
\multiput(10,50)(10,0){9}{\line(0,1){5}}
\setcounter{nn}{113}%
\multiput(10,40)(10,0){9}{\makebox(0,0){\thenn\stepcounter{nn}}}

\thicklines
\put(20,50){\circle{3}}
\put(80,50){\circle{3}}

\linethickness{2pt}
\put(20,50){\line(1,0){60}}
\end{picture}

\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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