add tag
Anonymous 8503
![image.png](/image?hash=d7ac477c993d383b71865ddcfe17ea325cd16d2ba414775af6d34f35e9163962). 

I tried
```
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture}
    \path (0,0)  coordinate (A) 
 (2, 0)  coordinate (B) 
  (0,-1)  coordinate (C) 
  (3,-1)  coordinate (D) 
  (0,-2)  coordinate (E) 
  (4,-2)  coordinate (F) 
  (0,-3)  coordinate (M) 
  (6,-3)  coordinate (N);
  \draw (A) -- (B) (C) -- (D) (E) -- (F) (M) -- (N);
  \end{tikzpicture}
\end{document}
```

Top Answer
samcarter
You could use path decorations like this:

```
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
    \begin{tikzpicture}[decoration={
    markings,% switch on markings
    mark=between positions 0 and 1 step 1cm with {\arrow{Bar}}
    }]
      \draw[postaction={decorate}] (0,0) node[anchor=east] {A} -- (2,0) node[anchor=west] {B};
      \draw[postaction={decorate}] (0,-1) node[anchor=east] {A} -- (3,-1) node[anchor=west] {B};      
  \end{tikzpicture}
\end{document}
```


![document-1.png](/image?hash=8d4468b6e3eed4e47aaa5dd1508e014be8048877aa582bf14af51b620c02747f)
Answer #2
Skillmon
With only plain and LaTeX macros the following ports an example from the TeXbook and adapt it to make the rules for the vertical ticks sit centred around the horizontal rule.

```
\documentclass[border=3.14]{standalone}

\newsavebox\rulerboxA
\newsavebox\rulerboxB
\newsavebox\rulerboxC
\newcommand\rulertick{\usebox\rulertickbox}
\newsavebox\rulertickbox
% default thickness of a \hrule is .4pt, we want half of 2pt above the rule (so move 1pt down) and accommodate for half the rule width (.2pt less)
\sbox\rulertickbox{\rule[-0.8pt]{.4pt}{2pt}}
% then we tell TeX the height would be 0pt (else the `\hrule` would be drawn at the top of the rule instead of in the centre)
\ht\rulertickbox=0pt
\newlength\rulerunit
\setlength\rulerunit{1cm}
\ExplSyntaxOn
\cs_new_eq:NN \rulerReplicate \prg_replicate:nn
\ExplSyntaxOff
\newcommand\ruler[3]
  {%
    \begingroup
      \sbox\rulerboxA{#1}%
      \sbox\rulerboxB
        {$\vcenter{\hrule\hbox{\rulertick\rulerReplicate{#2}\rulerunits}}$}%
      \sbox\rulerboxC{#3}%
      \ifdim\dp\rulerboxA>\dp\rulerboxC
        \dp\rulerboxC=\dp\rulerboxA
      \else
        \dp\rulerboxA=\dp\rulerboxC
      \fi
      \setlength\rulerunit{\dimexpr\ht\rulerboxB+\dp\rulerboxA+2pt\relax}%
      \mbox
        {%
          \raisebox{\rulerunit}{\usebox\rulerboxA}\kern-.5\wd\rulerboxA
          \usebox\rulerboxB
          \kern-.5\wd\rulerboxC\raisebox{\rulerunit}{\usebox\rulerboxC}%
        }%
    \endgroup
  }
\newcommand\rulerunits{\makebox[\rulerunit][r]{\rulertick}}

\begin{document}
\begin{tabular}{@{} l @{}}
  Text before \ruler{A}{2}{B} Text after \\
  \ruler{C}{3}{D} \\
  \ruler{E}{4}{F} \\
  \ruler{M}{5}{N} \\
\end{tabular}
\end{document}
```

![ruleranswer-1.png](/image?hash=c897fbe19e70610c4f30baf1781b5bec7336796ccafa26b0ae13656f1c6d06a1)
Answer #3
Laurenso
You can try this code
```
\documentclass[border=3.14mm]{standalone}
\usepackage{tikz}
\begin{document}
	\begin{tikzpicture}[line join=round, 
		line cap=round,c/.style={circle,fill,inner sep=1pt},
		declare function={a=3;b=5;}]
		\pgfmathsetmacro{\a}{8}
		\pgfmathsetmacro{\b}{4}
		\pgfmathsetmacro{\c}{3}
		\pgfmathsetmacro{\d}{6}
		\pgfmathsetmacro{\h}{-1} 
		\pgfmathsetmacro{\m}{-2} 
		\pgfmathsetmacro{\n}{-3} 
		\pgfmathsetmacro{\k}{0.1} 
		\path
		(0,0) coordinate (A)
		(\a,0) coordinate (B)
		(0,\h) coordinate (C)
		(\b,\h) coordinate (D)
		(0,\m) coordinate (E)
		(\c,\m) coordinate (F)
		(0,\n) coordinate (M)
		(\d,\n) coordinate (N)
		;
		\foreach \x in {0,1,...,\a}
		\draw (\x,\k) -- (\x,-\k);
		\foreach \y in {0,1,...,\b} \draw (\y,\h + \k) -- (\y,\h - \k);
		\foreach \z in {0,1,...,\c} \draw (\z,\m + \k) -- (\z,\m - \k);
		\foreach \t in {0,1,...,\d} \draw (\t,\n + \k) -- (\t,\n - \k);
		\draw (A) -- (B) (C) -- (D) (E) -- (F) (M) -- (N);
		\path foreach \p/\g in {A/-90,B/-90,C/-90,D/-90,E/-90,F/-90,M/-90,N/-90}{(\p){}+(\g:4mm) node{$\p$}};   
		
	\end{tikzpicture}
\end{document}
```
![image.png](/image?hash=20edd42c778f45d925f028618bf08aa80f04a18295e8584d3bb88f2d422d4a3e)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.