1

How can you draw exactly this?

Line Segment

I tried this

\begin{tikzpicture}
\pgfmathsetmacro\gratio{(1+sqrt(5))/2}
\def\lenB{2}
\path (0,0) node[coordinate](start){} ++(\gratio*\lenB,0)node[coordinate](a){} -- ++(\lenB,0)node[coordinate](b){};
\draw (start) --node[above] {$a$} (a) --node[above]{$b$} (b);
\foreach \n in {start,a,b}\draw (\n) ++(0,-2pt) -- ++(0,4pt);
\end{tikzpicture}
1

3 Answers 3

3

There are many ways. Here is one with a user-defined style called tick that includes the label below the tick mark.

enter image description here

\documentclass{article}

\usepackage{tikz}
\tikzset{tick/.style={draw, minimum width=0pt, minimum height=2pt, inner sep=0pt, label=below:$#1$},
    tick/.default={}}

\pgfmathsetmacro\gratio{(1+sqrt(5))/2}
\newcommand{\lenB}{2}

\begin{document}

\begin{tikzpicture}
\draw(0,0) node[tick=C_2]{} -- ++(\lenB*\gratio,0) node[tick=C_1]{} 
     (\lenB,0) node[tick=A]{} -- ++(\lenB*\gratio,0) node[tick=B]{};
\end{tikzpicture}

\end{document}
1
  • 1
    oh, nice [minimum width=0pt]!
    – Black Mild
    Apr 6, 2022 at 7:51
2

This looks pretty much like your example:

\documentclass{article}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}
    \def\x{5}
    \def\tick{0.05}

    \draw (0,0) -- (\x,0);
    \draw (0,\tick) -- ++(0,-2*\tick) node[below] {$C_2$};
    \draw (0.37*\x,\tick) -- ++(0,-2*\tick) node[below] {$A$};
    \draw (0.63*\x,\tick) -- ++(0,-2*\tick) node[below] {$C_1$};
    \draw (\x,\tick) -- ++(0,-2*\tick) node[below] {$B$};
\end{tikzpicture}
    
\end{document}

enter image description here

3
  • 2
    It seems that you missed the involved golden ratio in it.
    – SebGlav
    Apr 5, 2022 at 19:34
  • True, it wasn't really specified in the question. Is the drawing in the question some standard text book drawing one should know, or how do you know how exactly it relates to the golden ratio?
    – user263192
    Apr 7, 2022 at 18:30
  • I don't know but it seemed to me that it should be taken in account. Maybe OP would answer that question.
    – SebGlav
    Apr 7, 2022 at 19:05
2

@Sandy G gave a node way. Here is an alternative using pic.

enter image description here

\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro\gratio{(1+sqrt(5))/2}
\newcommand{\lenB}{2}
\tikzset{mytick/.pic={\draw[thick] (0,.08)--(0,-.08);}}
\draw 
(0,0)               pic[red]{mytick}     node[below=1pt]{$C_2$} -- 
++(\lenB*\gratio,0) pic[magenta]{mytick} node[below=1pt]{$C_1$}--
(\lenB,0)           pic[blue]{mytick}    node[below=1pt]{$A$} -- ++(\lenB*\gratio,0) pic[orange]{mytick}  node[below=1pt]{$B$};
\end{tikzpicture}
\end{document}

You must log in to answer this question.

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