如何在特定位置添加括号?

如何在特定位置添加括号?

如何重新创建以下内容 在此处输入图片描述 我正在编辑回答,当我尝试使用此代码添加括号时出现错误

\draw[decorate,decoration={brace,raise=1pt,amplitude=5pt,mirror}] (1,2.2) -- (1,1.7);

这是我的 MWE:

\documentclass[preview,margin=10pt]{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings,backgrounds,patterns}
\usepackage{pgfplots}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings,backgrounds,patterns}
\tikzset{point/.style={circle,draw=black,inner sep=0pt,minimum size=3pt}}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\newcommand{\thescale}{0.5}
\centering
\subcaptionbox{one choice for $c$}{
\begin{tikzpicture}[scale=\thescale*1.2]
    \draw[blue,thick] (1,1) node[point,fill=black] (a) {} parabola bend (3,3) (4,2.5) node[point,fill=black] (b) {};
    \draw[thick] (1,1) -- (4,2.5);
    \draw (1,1+9/8) -- (4,2.5+9/8) coordinate (topright);
    \node[point,fill=black] (x0) at (2.5,2.875) {};

    \coordinate (origin) at (0,0);
    \draw[<->] (topright -| origin) -- (origin) -- (origin -| topright) -- +(1,0);
    \draw[dotted,very thick] (a) -- (a|-origin) node[below,black] {$a$};
    \draw[dotted,very thick] (b) -- (b|-origin) node[below] {$b$};
    \draw[dashed] (x0) -- (x0|-origin) node[below] {$c$};
   \draw[decorate,decoration={brace,raise=1pt,amplitude=5pt,mirror}] (1,2.2) -- (1,1.7);%%%Added
\end{tikzpicture}
}
\subcaptionbox{two choices for $c$}{
\begin{tikzpicture}[scale=\thescale]
    \begin{scope}
    \clip (-3,-2) rectangle (3,2);
    \draw[thick,smooth,domain=-3:3] plot (\x,{\x^3/3 - \x});
    \end{scope}
    \node[point,fill=black] (a) at (-2,-2/3) {};
    \node[point,fill=black] (b) at (2,2/3) {};
    \draw[thick] (a) -- (b);
    \coordinate (origin) at (-4,-3);
    \coordinate (topright) at (4,2);
    \draw[<->] (topright -| origin) -- (origin) -- (origin -| topright);
    \draw[dotted,very thick] (a) -- (a|-origin) node[below] {$a$};
    \draw[dotted,very thick] (b) -- (b|-origin) node[below] {$b$};

    \node[point,fill=black] (x0) at ({-2/sqrt(3)},{(1/3)*(-2/sqrt(3))^3+2/sqrt(3)}) {};
    \draw (x0) +(-1,-1/3) -- +(1,1/3);
    \node[point,fill=black] (x1) at ({2/sqrt(3)},{(1/3)*(2/sqrt(3))^3-2/sqrt(3)}) {};
    \draw (x1) +(-1,-1/3) -- +(1,1/3);
    \draw[dashed] (x0) -- (x0 |- origin) node[below]{$c_0$};
    \draw[dashed] (x1) -- (x1 |- origin) node[below]{$c_1$};
\end{tikzpicture}
}
\subcaptionbox{\centering infinitely many choices for $c$}{
\begin{tikzpicture}[scale=\thescale/1.2]
    \draw[thick,smooth] plot coordinates{(-2,-1) (-1.75,0) (-1,1) (0,2) (1,3) (2,4) (3,4.74) (4,5)} ++(1,0) coordinate (topright);
    \coordinate (origin) at (-3,-2);
    \draw[<->] (origin|-topright) -- (origin) -- (origin-|topright);
    \node[point,fill=black] (a) at (-2,-1) {};
    \node[point,fill=black] (b) at (4,5) {};

    \draw[very thick, dotted] (a) -- (a|-origin) node[below] {$a$};
    \draw[dotted,very thick] (b) -- (b|-origin) node[below] {$b$};

    \draw[thin] (-2,0) -- (4,6);
    \draw[ultra thick] (0,2) -- (1,3);

    \draw[dashed] (0,2) -- (0,-2);
    \draw[dashed] (0.5,2.5) -- (0.5,-2);
    \draw[dashed] (1,3) -- (1,-2);
\end{tikzpicture}
}
\end{figure}
\end{document} 

编辑:我的 MWE 输出没有给出正确的括号。我还想用 g 指向括号(如图所示),但我无法做到这一点。

答案1

装饰brace是在decorations.pathreplacing库中定义的,但你只加载decorations.markings库。添加decorations.pathreplacing到你的库列表中(其中有两个相同的库,你可以删除其中一个)。

要定义支架的下端点,您可以使用

\path (a) -- (b) coordinate[midway] (m);

(这只在这里有效,因为位于和 的c中间),并且为了标记括号,您可以添加和,如下所示:abcoordinatepin

\draw[decorate,decoration={brace,raise=1pt,amplitude=5pt,mirror}] (x0) -- (m) 
 coordinate[pin={[red,inner sep=1pt,pin edge={red,thick}]135:$g$},left=7pt,midway] {};

代码输出

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{
  calc,angles,positioning,intersections,quotes,decorations.markings,backgrounds,patterns,
  decorations.pathreplacing % <- added
}
\tikzset{point/.style={circle,draw=black,inner sep=0pt,minimum size=3pt}}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\newcommand{\thescale}{0.5}
\centering
\subcaptionbox{one choice for $c$}{
\begin{tikzpicture}[scale=\thescale*1.2]
    \draw[blue,thick] (1,1) node[point,fill=black] (a) {} parabola bend (3,3) (4,2.5) node[point,fill=black] (b) {};
    \draw[thick] (1,1) -- (4,2.5);
    \draw (1,1+9/8) -- (4,2.5+9/8) coordinate (topright);
    \node[point,fill=black] (x0) at (2.5,2.875) {};

    \coordinate (origin) at (0,0);
    \draw[<->] (topright -| origin) -- (origin) -- (origin -| topright) -- +(1,0);
    \draw[dotted,very thick] (a) -- (a|-origin) node[below,black] {$a$};
    \draw[dotted,very thick] (b) -- (b|-origin) node[below] {$b$};
    \draw[dashed] (x0) -- (x0|-origin) node[below] {$c$};

    % added
    \path (a) -- (b) coordinate[midway] (m);

   \draw[decorate,decoration={brace,raise=1pt,amplitude=5pt,mirror}] (x0) -- (m) 
     coordinate[pin={[red,inner sep=1pt,pin edge={red,thick}]135:$g$},left=7pt,midway] {};
\end{tikzpicture}
}
\subcaptionbox{two choices for $c$}{
\begin{tikzpicture}[scale=\thescale]
    \begin{scope}
    \clip (-3,-2) rectangle (3,2);
    \draw[thick,smooth,domain=-3:3] plot (\x,{\x^3/3 - \x});
    \end{scope}
    \node[point,fill=black] (a) at (-2,-2/3) {};
    \node[point,fill=black] (b) at (2,2/3) {};
    \draw[thick] (a) -- (b);
    \coordinate (origin) at (-4,-3);
    \coordinate (topright) at (4,2);
    \draw[<->] (topright -| origin) -- (origin) -- (origin -| topright);
    \draw[dotted,very thick] (a) -- (a|-origin) node[below] {$a$};
    \draw[dotted,very thick] (b) -- (b|-origin) node[below] {$b$};

    \node[point,fill=black] (x0) at ({-2/sqrt(3)},{(1/3)*(-2/sqrt(3))^3+2/sqrt(3)}) {};
    \draw (x0) +(-1,-1/3) -- +(1,1/3);
    \node[point,fill=black] (x1) at ({2/sqrt(3)},{(1/3)*(2/sqrt(3))^3-2/sqrt(3)}) {};
    \draw (x1) +(-1,-1/3) -- +(1,1/3);
    \draw[dashed] (x0) -- (x0 |- origin) node[below]{$c_0$};
    \draw[dashed] (x1) -- (x1 |- origin) node[below]{$c_1$};
\end{tikzpicture}
}
\subcaptionbox{\centering infinitely many choices for $c$}{
\begin{tikzpicture}[scale=\thescale/1.2]
    \draw[thick,smooth] plot coordinates{(-2,-1) (-1.75,0) (-1,1) (0,2) (1,3) (2,4) (3,4.74) (4,5)} ++(1,0) coordinate (topright);
    \coordinate (origin) at (-3,-2);
    \draw[<->] (origin|-topright) -- (origin) -- (origin-|topright);
    \node[point,fill=black] (a) at (-2,-1) {};
    \node[point,fill=black] (b) at (4,5) {};

    \draw[very thick, dotted] (a) -- (a|-origin) node[below] {$a$};
    \draw[dotted,very thick] (b) -- (b|-origin) node[below] {$b$};

    \draw[thin] (-2,0) -- (4,6);
    \draw[ultra thick] (0,2) -- (1,3);

    \draw[dashed] (0,2) -- (0,-2);
    \draw[dashed] (0.5,2.5) -- (0.5,-2);
    \draw[dashed] (1,3) -- (1,-2);
\end{tikzpicture}
}
\end{figure}
\end{document} 

相关内容