8

enter image description here

How to draw this figure in LaTeX?

I am new to LaTeX figure drawing. Here I see two round headed rectangles and two circles. Also I am eager to know that can I draw this in Overleaf?

12

Just another solution.

\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\begin{tikzpicture}

\fill circle(2pt) coordinate(a) ++(20:2cm) circle(2pt) coordinate(b); 
\draw (a)++(110:2mm) arc (110:290:2mm)--++(20:2cm) arc (-70:110:2mm)--cycle;
\draw (b)++(170:2mm) arc (170:350:2mm)--++(80:2cm) arc (-10:170:2mm)--cycle;

\end{tikzpicture}
\end{document}

enter image description here

11

One out of many possibilities.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{shapes.misc} 
\begin{document}
\begin{tikzpicture}[bullet/.style={fill,circle,inner sep=2pt}]
\node[rounded rectangle,draw,minimum width=3cm,minimum height=4mm,rotate=20](A) at (0,0){};
\node[rounded rectangle,draw,minimum width=3cm,minimum
height=4mm,rotate=80,anchor=west](B) 
at ([xshift=-1mm]A.south east){};
\node[bullet,shift={(200:2mm)}] at (A.east){};
\node[bullet,shift={(20:2mm)}] at (A.west){};
\end{tikzpicture}
\end{document}

enter image description here

  • 1
    The figure reminds me of a toy called "Metallbaukasten" (de.wikipedia.org/wiki/Metallbaukasten). It would be interesting if there is a package for this. – Stefan Jan 22 at 11:55
  • @Stefan I am not aware of such a package. (And I guess kids will prefer the real thing anyway. ;-) – marmot Jan 22 at 15:38
  • I had thought of the usage for simulation purposes. – Stefan Jan 23 at 6:07
11

Run with xelatex

\documentclass{article}
\usepackage{pst-node}
\begin{document}

\begin{pspicture}(-1,-1)(4,5)
\pnodes(0,0){A}(3,1){B}(3.5,4){C}\psdots[dotscale=3](A)(B)
\ncbox[linearc=0.4,nodesep=4mm]{A}{B}
\ncbox[linearc=0.4,nodesep=4mm]{C}{B}
\end{pspicture}

\end{document}

enter image description here

4

Another option: this one is in Metapost using the mplib package, so you need to use lualatex to compile it. In Overleaf, click on "Menu" at the top left and choose "LuaLaTeX" as the compiler.

A drawing of some semaphore arms.

\documentclass[border=5mm]{standalone}
\usepackage{luatex85}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);
    vardef arm(expr extent, radius, mark_start, mark_end) =
        save P, A; 
        picture P; path A;
        A = halfcircle scaled 2 radius rotated 90 
         -- halfcircle scaled 2 radius rotated -90 shifted (extent, 0)
         -- cycle;
        P = image(draw A;
            if mark_start > 0:
                fill fullcircle scaled 2 mark_start;
            fi
            if mark_end > 0:
                fill fullcircle scaled 2 mark_end shifted (extent, 0);
            fi
        ); P
    enddef;
    draw arm(200, 16, 0, 6) rotated 200;
    draw arm(200, 16, 6, 0) rotated 60;
endfig;
\end{mplibcode}
\end{document}

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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