在 tikz 中添加下支撑

在 tikz 中添加下支撑

我有此代码用于在弹簧上绘制质量,现在我想在弹簧下方使用花括号来表示距离:x_0。我该怎么做?

\begin{tikzpicture}
\tikzstyle{ground}=[fill,pattern=north east lines,draw=none,minimum width=0.3,minimum height=0.6]

\node (wall1) [ground, minimum height=2cm] {};
\draw (wall1.north east) -- (wall1.south east);
\node [draw,minimum width=0.5cm,minimum height=0.5cm] (mass) at (2,0) {m};
\node (fix) at (0,0) {};
\draw [snake=coil,segment amplitude=5pt,segment length=5pt] (fix) -- (mass); 
\end{tikzpicture}

答案1

正如 Seamus 链接的 Andrew 的回答中所建议的那样,你可以brace为此使用装饰。如果它在路径的错误一侧,请使用选项mirror(或反转路径顺序)。要增加间距,你可以使用raise=<length>

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{patterns,snakes}

\begin{document}
\begin{tikzpicture}
\tikzstyle{ground}=[fill,pattern=north east lines,draw=none,minimum width=0.3,minimum height=0.6]

\node (wall1) [ground, minimum height=2cm] {};
\draw (wall1.north east) -- (wall1.south east);
\node [draw,minimum width=0.5cm,minimum height=0.5cm] (mass) at (2,0) {m};
\node (fix) at (0,0) {};
\draw [
    snake=coil,
    segment amplitude=5pt,
    segment length=5pt
] (wall1.east) -- (mass); 
\draw [
    thick,
    decoration={
        brace,
        mirror,
        raise=0.5cm
    },
    decorate
] (wall1.east) -- (mass) 
node [pos=0.5,anchor=north,yshift=-0.55cm] {coil}; 
\end{tikzpicture}
\end{document}

相关内容