2

Is there a simple way to add the equality marks on equal lines (hash marks)? Sure, I could manually draw a small line but it becomes quite tedious when 3+ lines are equal in a figure.

\begin{tikzpicture}[scale = 1.8]
    \draw (0,1) -- (1,1);
\end{tikzpicture}

How can I draw a hash mark on this line? Like this:

enter image description here

2
  • 1
    Why don't you show us how you draw the figure without the hash marks? I'm sure you'll then find somebody able to help with the marks. Commented Jan 24, 2023 at 22:05
  • How should they look? The simplest would be to place a sloped node with text / or similar on the line, i.e. \draw (0,1)--node[sloped]{/} (1,1);. For more complex marking, the pic function was made for this. Finally, there's the decoration.markings library that provides the same functionality (and a bit more) but I don't think you need that if you would allow a slightly different syntax. Commented Jan 24, 2023 at 23:04

2 Answers 2

6

A simple solution would be to use the sloped option together with a label $|||$ (or however many lines you want. For smaller marks you could use $\scriptstyle|||$.

enter image description here

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
  \draw(0,0)--node[sloped]{$|||$}(2,1);
\end{tikzpicture}
\end{document}
1
  • This is exactly what I am looking for, very straightforward. Thanks! Commented Jan 25, 2023 at 2:31
7

With this code:

    \documentclass{article}
    
    \usepackage{tikz}
    
    \begin{document} 
    \begin{tikzpicture}[scale=2]
        \draw[] (-1,0) -- (3,1) node[pos=.5,sloped] () {\bfseries $\arrowvert$}; 
        \draw[] (3,1) -- (5,-1) node[pos=.5,sloped] () {\bfseries $\Arrowvert$}; 
        \draw[] (5,-1) -- (-1,0) node[pos=.5,sloped] () {\bfseries $\times$};
    \end{tikzpicture}   
\end{document}

You have this output:

enter image description here

ADD: With this code:

\documentclass{article}

\usepackage{tikz}

\begin{document} 
    \begin{tikzpicture}
        \draw[line width=2pt] (-1,-2)--(2,3) node[pos=.5,sloped] () {\bfseries $\arrowvert$};
        \draw[line width=2pt] (2,3)--(5,2) node[pos=.5,sloped] () {\bfseries $\Arrowvert$}; 
        \draw[line width=2pt] (5,2)--(2,-3) node[pos=.5,sloped] () {\bfseries $\arrowvert$};
        \draw[line width=2pt] (2,-3)--(-1,-2) node[pos=.5,sloped] () {\bfseries $\Arrowvert$};
    \end{tikzpicture}   
\end{document}

You can mark equals sides with the same symbol:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .