我想在下图的 Q_s 和 Q_d 之间添加一个括号
\begin{tikzpicture}[domain=0:5,scale=1,thick]
\usetikzlibrary{calc} %allows coordinate calculations.
%Define linear parameters for supply and demand
\def\dint{4.5} %Y-intercept for DEMAND.
\def\dslp{-0.5} %Slope for DEMAND.
\def\sint{1.2} %Y-intercept for SUPPLY.
\def\sslp{0.8} %Slope for SUPPLY.
\def\pfc{2.5} %Price floor or ceiling
\def\demand{\x,{\dslp*\x+\dint}}
\def\supply{\x,{\sslp*\x+\sint}}
% Define coordinates.
\coordinate (ints) at ({(\sint-\dint)/(\dslp-\sslp)},{(\sint-\dint)/(\dslp-\sslp)*\sslp+\sint});
\coordinate (ep) at (0,{(\sint-\dint)/(\dslp-\sslp)*\sslp+\sint});
\coordinate (eq) at ({(\sint-\dint)/(\dslp-\sslp)},0);
\coordinate (dint) at (0,{\dint});
\coordinate (sint) at (0,{\sint});
\coordinate (pfq) at ({(\pfc-\dint)/(\dslp)},0);
\coordinate (pfp) at ({(\pfc-\dint)/(\dslp)},{\pfc});
\coordinate (sfq) at ({(\pfc-\sint)/(\sslp)},0);
\coordinate (sfp) at ({(\pfc-\sint)/(\sslp)},{\pfc});
% DEMAND
\draw[thick,color=blue] plot (\demand) node[right] {$P(q) = -\frac{1}{2}q+\frac{9}{2}$};
% SUPPLY
\draw[thick,color=purple] plot (\supply) node[right] {Supply};
% Draw axes, and dotted equilibrium lines.
\draw[->] (0,0) -- (6.2,0) node[right] {$Q$};
\draw[->] (0,0) -- (0,6.2) node[above] {$P$};
%Price floor and ceiling lines
\draw[dashed,color=black] plot (\x,{\pfc}) node[right] {$P_c$};
\draw[dashed] (pfp) -- (pfq) node[below] {$Q_d$};
\draw[dashed] (sfp) -- (sfq) node[below] {$Q_s$};
\draw[->,baseline=5] ($(0,{\pfc})+(-1.5,0.7)$) node[label= left:Price Ceiling] {} -- ($(0,{\pfc})+(-.1,0.1)$);
\end{tikzpicture}
上述代码(不带括号)的结果是:
另外我想知道当我使用
\documentclass[class=minimal,border=0pt]{standalone}
答案1
对于括号,您可以使用brace
装饰(来自decorations.pathreplacing
库);对于标题,您可以使用\node
放置在(current bounding box.north)
(或任何其他所需位置)的,例如:
\documentclass[class=minimal,border=0pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}[domain=0:5,scale=1,thick]
%Define linear parameters for supply and demand
\def\dint{4.5} %Y-intercept for DEMAND.
\def\dslp{-0.5} %Slope for DEMAND.
\def\sint{1.2} %Y-intercept for SUPPLY.
\def\sslp{0.8} %Slope for SUPPLY.
\def\pfc{2.5} %Price floor or ceiling
\def\demand{\x,{\dslp*\x+\dint}}
\def\supply{\x,{\sslp*\x+\sint}}
% Define coordinates.
\coordinate (ints) at ({(\sint-\dint)/(\dslp-\sslp)},{(\sint-\dint)/(\dslp-\sslp)*\sslp+\sint});
\coordinate (ep) at (0,{(\sint-\dint)/(\dslp-\sslp)*\sslp+\sint});
\coordinate (eq) at ({(\sint-\dint)/(\dslp-\sslp)},0);
\coordinate (dint) at (0,{\dint});
\coordinate (sint) at (0,{\sint});
\coordinate (pfq) at ({(\pfc-\dint)/(\dslp)},0);
\coordinate (pfp) at ({(\pfc-\dint)/(\dslp)},{\pfc});
\coordinate (sfq) at ({(\pfc-\sint)/(\sslp)},0);
\coordinate (sfp) at ({(\pfc-\sint)/(\sslp)},{\pfc});
% DEMAND
\draw[thick,color=blue] plot (\demand) node[right] {$P(q) = -\frac{1}{2}q+\frac{9}{2}$};
% SUPPLY
\draw[thick,color=purple] plot (\supply) node[right] {Supply};
% Draw axes, and dotted equilibrium lines.
\draw[->] (0,0) -- (6.2,0) node[right] {$Q$};
\draw[->] (0,0) -- (0,6.2) node[above] {$P$};
%Price floor and ceiling lines
\draw[dashed,color=black] plot (\x,{\pfc}) node[right] {$P_c$};
\draw[dashed] (pfp) -- (pfq) node[below] (qd) {$Q_d$};
\draw[dashed] (sfp) -- (sfq) node[below] (qs) {$Q_s$};
\draw[->,baseline=5] ($(0,{\pfc})+(-1.5,0.7)$) node[label= left:Price Ceiling] {} -- ($(0,{\pfc})+(-.1,0.1)$);
\draw[decorate,decoration={brace,mirror}] (qs.south) -- node[below] {some text} (qd.south);
\draw[decorate,decoration={brace,mirror}]
([yshift=-1.2cm]0,0) -- node[below] {some text} ([yshift=-1.2cm]6.2,0);
\node at ([yshift=10pt]current bounding box.north) {A diagram illustrating supply versus demand};
\end{tikzpicture}
\end{document}