我正在使用 tikz 绘制下图,但我的交点 Q 和 Z 没有显示在图中,请帮忙。
\documentclass{article}
\usepackage[x11names]{xcolor}
\usepackage{tikz}
\usetikzlibrary{intersections}
\pgfdeclarelayer{bg} % declare background
\pgfsetlayers{bg,main} % order of layers (main = standard layer)
\usepackage{amsmath}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\draw (0,-1)--(0,5);
\draw (-1,0)--(8,0);
\draw[name path=P3] (7,0)node(a){A}--(0,2)node (b){B};
\draw[name path=P1] (3,0)node(c){C}--(0,3.5)node(m){M};
\draw[name path=P2] (2,0)node(e){E}--(2,4)node(d){D};
\draw (0,0)node(o){O};
\path [name intersections={of=P1 and P3,by=Q}];
\path [name intersections={of=P1 and P2,by=Z}];
\begin{pgfonlayer}{bg} % select background
\path [fill=blue!50] (o.center) --(e.center) --(Z.center) -- (Q.center)--(b.center)-- (o.center) --cycle;
\end{pgfonlayer}
\end{tikzpicture}
\end{document}
答案1
由于您没有标记坐标,因此坐标未显示,但坐标计算正确。以下是标记坐标的一种可能方法。
\documentclass{article}
\usepackage[x11names]{xcolor}
\usepackage{tikz}
\usetikzlibrary{intersections}
\pgfdeclarelayer{bg} % declare background
\pgfsetlayers{bg,main} % order of layers (main = standard layer)
\usepackage{amsmath}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[dot/.style={circle,fill,inner sep=1pt}]
\draw (0,-1)--(0,5);
\draw (-1,0)--(8,0);
\draw[name path=P3]
(7,0)coordinate[label=below:$A$](a)--(0,2)coordinate[label=left:$B$](b);
\draw[name path=P1] (3,0)coordinate[label=below:$C$](c)--(0,3.5)coordinate[label=left:$M$](m);
\draw[name path=P2] (2,0)coordinate[label=below:$E$](e)--(2,4)coordinate[label=left:$D$](d);
\path(0,0)coordinate[label=below left:$O$](o);
\path [name intersections={of=P1 and P3,by=Q}] (Q) node[dot,label=above:$Q$]{};
\path [name intersections={of=P1 and P2,by=Z}] (Z) node[dot,label=right:$Z$]{}; ;
\begin{pgfonlayer}{bg} % select background
\path [fill=blue!50] (o.center) --(e.center) --(Z.center) -- (Q.center)--(b.center)-- (o.center) --cycle;
\end{pgfonlayer}
\end{tikzpicture}
\end{document}