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 think the figure is very simple.

example

Nevertheless, I can't figure out how to do it. Any help?

share|improve this question
    
Related (but more advanced usage) question: Creating a line of given length with variable number of “snags” equally separated (TikZ)? –  Peter Grill Apr 21 '12 at 19:03
add comment

2 Answers

up vote 10 down vote accepted

A very basic approach just to show the concept.

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{tikz}

\begin{document}
  \begin{tikzpicture}
    \draw (0,0) -- (6,0);
    \foreach \x/\xtext in {0/a,1/b,3/c,6/d}{
      \draw (\x cm,-2pt) -- (\x cm,2pt) node[above] {\xtext};
    }
  \end{tikzpicture}
\end{document}

For details you should take a look into the »pgf/tikZ« user guide.


enter image description here

share|improve this answer
add comment

I prefer an answer instead of a long comment but I want to say that it's preferable to use the same method to work with dimensions

If you wrote \draw (0,0) -- (6,0); then the code would be :

 \documentclass{minimal}
 \usepackage{tikz}
 \begin{document}
  \begin{tikzpicture}
    \draw (0,0) -- (6,0);
    \foreach \x/\xtext in {0/a,1/b,3/c,6/d}{
      \draw (\x ,-.08) -- (\x,0.08) node[above] {\xtext};
    }
  \end{tikzpicture} 

A problem can appear if later you use scale = 2 or x= 2 cm, y = 2 cm or if you want to use big numbers.

Why is important :

 \documentclass{minimal}
 \usepackage{tikz}
 \begin{document}
 \begin{tikzpicture}
  \draw (0,0)--(600,0);
 \end{tikzpicture}
\end{document} 

gives an error Latex Error : ... Dimension too large.

 \documentclass{minimal}
 \usepackage{tikz}
 \begin{document}
 \begin{tikzpicture}[x=0.01 cm]
  \draw (0,0)--(600 cm,0);
\end{tikzpicture}
\end{document} 

gives the same error

but

 \documentclass{minimal}
 \usepackage{tikz}
 \begin{document}
 \begin{tikzpicture}[x=0.01 cm]
    \draw (0,0)--(600,0);
  \end{tikzpicture}
 \end{document} 
\end{document} 

is correct. a dim is limited by 16 384 pt near 5.75 m but TeX can work with big numbers, the next code compiles but you can't replace x=0.00001 cm by x=0.000001 cm

\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[x=0.00001 cm]
 \coordinate (x) at (600000,0);
  \draw (0,0)--(x);
\end{tikzpicture}
\end{document} 
share|improve this answer
    
A very interesting aspect. Good to know. –  Thorsten Donig Apr 22 '12 at 10:09
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.