![如何在 Tikz 中使用花括号创建注释](https://linux22.com/image/459220/%E5%A6%82%E4%BD%95%E5%9C%A8%20Tikz%20%E4%B8%AD%E4%BD%BF%E7%94%A8%E8%8A%B1%E6%8B%AC%E5%8F%B7%E5%88%9B%E5%BB%BA%E6%B3%A8%E9%87%8A.png)
大家好,我想创建这个图像的图形:
我可以创建它,但我不知道如何添加箭头、注释和花括号。
这是我的 MWE:
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
%coordinate system
\draw[->] (0,0,0)--++(14,0,0) node[right]{$x$};
\draw[->] (0,0,0)--++(0,5,0) node[above]{$y$};
\draw[->] (0,0,0)--++(0,0,10) node[below left]{$z$};
% rectangle 1
\draw[thick, preaction={fill=blue}]
(8.5,0,6) node[anchor=north]{$$}
-- (8.5,3.6,6) node[anchor=north]{$$}
-- (3.5,3.8,0.1) node[anchor=south]{$$}
-- (3,0,-0.81) node[anchor=south]{$$}
-- cycle;
% rectangle 2
\draw[thick, preaction={fill=blue}]
(8.5,0,6) node[anchor=north]{$$}
-- (8.5,3.6,6) node[anchor=north]{$$}
-- (8.9,3.5,6) node[anchor=south]{$$}
-- (8.9,0,6) node[anchor=south]{$$}
-- cycle;
% rectangle 3
\draw[thick, preaction={fill=blue}]
(8.9,3.5,6) node[anchor=north]{$$}
-- (8.5,3.5,6) node[anchor=north]{$$}
-- (3.8,3.83,0.45) node[anchor=south]{$$}
-- (3.9,3.5,-0.1) node[anchor=south]{$$}
-- cycle;
% the connections
\draw[ultra thick](1,0,-1)--(1,4,-1);
\draw[ultra thick](1,0,-1)--(6,0,6);
\draw[ultra thick](6,0,6)--(12,0,6);
\draw[ultra thick](6,0,6)--(6,4,6);
\draw[ultra thick](1,4,-1)--(6,4,6);
\draw[ultra thick](12,0,6) arc (0:90:5.9 and 4);% one quarter circle 1
\draw[ultra thick](12,0,6) arc (0:70:12.5 and 7);% one quarter circle 2
% colored one quarter circle 3
\draw[ultra thick, preaction={fill=blue,very nearly transparent}]
(12,0,6) arc (10:90:8.3 and 3.2);% one quarter circle 4
% triangle
\draw[transparent, preaction={fill=blue,very nearly transparent}] (12,0,6) node[anchor=north]{$$}
-- (6,0,6) node[anchor=north]{$$}
-- (1,0,-1) node[anchor=south]{$$}
-- cycle;
\end{tikzpicture}
\end{document}
答案1
所以,已经过去将近一天了,却没有答复。
我编写的代码非常静态,不易修改。我使用了 3 个库:
calc
计算一些坐标位置。intersections
计算蓝色矩形与其他形状相交的位置。decorations.pathreplacing
绘制括号。
我相信还有很大的进步空间。
结果
代码
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{intersections}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
%coordinate system
% \draw[->] (0,0,0)--++(14,0,0) node[right]{$x$};
% \draw[->] (0,0,0)--++(0,5,0) node[above]{$y$};
% \draw[->] (0,0,0)--++(0,0,10) node[below left]{$z$};
%
% Define the base points
\coordinate (a) at (0,0) ;
\coordinate (b) at (0:5) ;
\coordinate (c) at (130:2.5);
\coordinate (d) at (0,3) ;
\coordinate (e) at ($(b) + (0,3)$);
\coordinate (f) at ($(c) + (0,3)$);
%
\draw [name path = p2](b) .. controls (1,2) ..(c);
\draw (f) -- (c) -- (a) -- (b);
\draw (a) --(d)--(f);
\draw [name path= p3](b) .. controls (2,3) .. (d);
\draw [name path= p4](b) .. controls (2,3.5) .. (f);
% defining the blue retangle
\coordinate (m1) at ($(a)!0.5!(b)$);
\path [name path= pm1] (m1) --($(m1)+(130:2.5)$);
\path [name path= pm2] (m1) --($(m1)+(0,5)$);
*
\path [name intersections = {of = p2 and pm1, by = m2}];
\path [name intersections = {of = p3 and pm2, by = m3}];
%
\path [name path= pm3] (m2) --($(m2)+(0,5)$);
\path [name intersections = {of = p4 and pm3, by = m4}];
%
\draw (m4)--(m3)--(m1) -- (m2)--cycle;
% make the blue rectangle 3D by creating a quasi-copy just next ot it.
\coordinate (c1) at ($(m1)-(0.5,0)$);
\path [name path= cm1] (c1) --($(c1)+(130:2.5)$);
\path [name path= cm2] (c1) --($(c1)+(0,5)$);
\path [name intersections = {of = p2 and cm1, by = c2}];
\path [name intersections = {of = p3 and cm2, by = c3}];
%
\path [name path= cm3] (c2) --($(c2)+(0,5)$);
\path [name intersections = {of = p4 and cm3, by = c4}];
%
\draw (c4)--(c3)--(c1) -- (c2)--cycle;
\fill [blue, opacity=0.5](c1) -- (m1)-- (m3)--(m4) --(c4) -- (c2) -- cycle;
% put the braces
\draw [decorate,decoration={brace,amplitude=10pt,aspect=0.65}] (c1)--(c2) ;
\draw [decorate,decoration={brace,amplitude=10pt}] (m1)--(a);
% now annotate :
\node[below left of=a] (eq) {$1 -\frac{x^2}{4}$};
\draw (eq) -- ($(c1)!0.5!(c2)- (0.6,0)$);
% showing the thickness of blue
\coordinate (c4bis) at ($(c4) + (0,2)$);
\coordinate (m4bis) at ($(c4) + (0,2) +(0.6,0)$);
\draw (c4) --(c4bis);
\draw (m4) --(m4bis);
\node at ($(c4bis)!0.5! (m4bis)$) {$\Delta x$};
\end{tikzpicture}
\end{document}