我正在使用 Ti钾我第一次使用 Z,在获取我到底想要它显示什么方面遇到了一些困难。我正在尝试绘制以下图片:
这是代码(我知道它不是那么好,但请注意这是我第一次使用 Ti钾韓國語:
\documentclass[paper=a4, fontsize=11pt]{scrartcl} % A4 paper and 11pt font size
\usepackage[T1]{fontenc}
\usepackage[english]{babel} % English language/hyphenation
\usepackage{amsmath,amsfonts,amsthm} % Math packages
\usepackage{graphicx}
\usepackage{mdframed}
\usepackage[ampersand]{easylist}
\usepackage{enumitem}
\usepackage{tikz}
\begin{document}
\begin{center}\begin{tikzpicture}[auto]
\draw[thick, ->] (-6,0) -- (10,0) node[anchor = north west] {x};
\draw[thick, ->] (0,-3) -- (0,11) node[anchor = south east] {y};
\node (P) at (-4,-2) {$P(-4;-2)$};
\node (Q) at (8,3) {$Q(8;3)$};
\node (R) at (4,10) {$R(4;10)$};
\node (N) at (2,7) {N};
\draw (P) to (Q);
\draw (R) to (Q);
\draw (P) to (R);
\draw (N) to (Q);
\end{tikzpicture}\end{center}
\end{document}
它目前给我以下信息:
我怎么能够
- 获取点名称不是打破界限,
- 画出连接 QN 的线以表示为垂直线?
答案1
我仅展示众多可能性中的一种(以及 90 度角标记的另一种选择 - 对于其他角度,请查看angles
v3.00 手册中的库-)
\documentclass[tikz]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[scale=5]% Scale it rather using too big dimensions in centimeters
\coordinate[label=below:{$P(-4,-2)$}](p) at (-4mm,-2mm);
\coordinate[label=right:{$Q(8,3)$}](q) at (8mm,3mm);
\coordinate[label=above:{$R(4,10)$}] (r) at (4mm,10mm);
\draw (p) -- (q) -- (r) -- cycle; %Look at the tip of the triangle with cycle or (p)
% Here is some black magic; start from q and draw to a point
% which is at the place along the line from p to r but at the
% place where q is projected on that line.
\draw (q) -- ($(p)!(q)!(r)$) coordinate (s);
\draw ($(s)!0.5mm!(q)$) coordinate (t) -- ($(t)!0.5mm!90:(q)$) --($(s)!0.5mm!(r)$);
\end{tikzpicture}
\end{document}
当你正在开发你的 Ti 时钾Z-fu,请留意我们自己的 Alain Matthes 的包裹,名为tkz-euclide
。它使这类绘图变得非常简单和结构化。唯一的缺点是手册对我来说是法语(字面意思)。但无论如何它还是相当不言自明的。
答案2
\documentclass[11pt,a4paper]{article}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}
\tkzInit[xmin=-5,xmax=9,ymin=-3,ymax=11]
\tkzAxeXY
%\tkzGrid
\tkzDefPoint[label=below:{$P(-4,-2)$}](-4,-2){P}
\tkzDefPoint[label=right:{$Q(8,3)$}](8,3){Q}
\tkzDefPoint[label=above:{$R(4,10)$}](4,10){R}
\tkzDrawSegments(P,Q Q,R R,P)
\tkzDefPointBy[projection=onto P--R](Q)
\tkzGetPoint{N}
\tkzLabelPoints[above left](N)
\tkzDrawPoints[color=red](P,Q,R,N)
\tkzDrawSegment(Q,N)
\tkzMarkRightAngle[fill=lightgray](Q,N,R)
\tkzLabelAngle[pos=1.3](Q,P,R){$\beta$}
\tkzMarkAngle[arc=l,size=1cm](Q,P,R)
\end{tikzpicture}
\end{document}
答案3
为了比较,元帖子。
请注意,与 OP 图顶部的警告不同,这个是按比例绘制……
prologues := 3;
outputtemplate := "%j%c.eps";
beginfig(1);
u := 5mm;
% axes
path xx, yy;
xx = (5 left -- 9 right) scaled u;
yy = (3 down -- 11 up) scaled u;
drawarrow xx withcolor .5 white;
drawarrow yy withcolor .5 white;
label.rt (btex $x$ etex, point 1 of xx);
label.top(btex $y$ etex, point 1 of yy);
% define the points
pair M, N, P, Q, R;
P = (-4, -2) scaled u;
Q = ( 8, 3) scaled u;
R = ( 4, 10) scaled u;
M = yy intersectionpoint (P--R);
N = whatever[P,R]; (N-Q) dotprod (R-P) = 0;
%
% mark the right angle
draw unitsquare scaled 5 rotated angle (Q-N) shifted N withcolor .5 white;
% draw the lines
draw P--Q--R--cycle; draw Q--N;
% add the labels
label.ulft(btex $M$ etex, M);
label.ulft(btex $N$ etex, N);
label.top (btex $R\,(4;10)$ etex, R);
label.rt (btex $Q\,(8;3)$ etex, Q);
label.lft (btex $P\,(-4;-2)$ etex, P);
% label the angle along the bisector
label(btex $\beta$ etex, P + 20 unitvector(Q+R-2P));
endfig;
end.
稍微思考一下这里的几何图形,就会发现由于M
位于 y 轴上,因此它位于x 方向上P
和 的中间,所以它一定是 的中点。因此它的坐标为;因此从到 的距离为 ,但这与从到 的距离相同,即;因此和是全等三角形,因此是 的中点,坐标为。您可以使用 Metapost 方程系统来确认这一点;如果您添加R
P--R
(0,4)
M
Q
sqrt(8^2+1^2)=sqrt(65)
R
Q
sqrt(4^2+7^2)=sqrt(65)
QNR
QNM
N
R--M
(2,7)
M = (0,4) scaled u; N = (2,7) scaled u;
后已经给出了隐式定义,那么 MP 不会出错。
答案4
面对不公平的未知mfpic
包。它是一组广泛的 (La)TeX 宏,为 METAFONT 或 MetaPost 提供了非常方便的接口,在本例中为后者。
由于大多数人不熟悉这个包,我在下面的代码中添加了相当多的注释,因此它相对较长。
对于那些对 MetaPost 有所了解的人来说,mfpic
还可以嵌入原始的 MetaPost 指令,这有时更方便。正如我在这里所做的那样,定位点 M 和 N(这是 MetaPost 以其标志性的隐式方式完成的),并在 N 上绘制直角标记(感谢 MetaPost 变换器)。
\documentclass{scrartcl}
% MetaPost instead of Metafont as drawing program and labels manager.
% Bounding box based on actual picture dimensions, not on the axes dimensions.
\usepackage[metapost, mplabels, truebbox]{mfpic}
% LaTeX preamble given to MetaPost for its labels management
% (corresponds to the verbatimtex ... etex flags of MetaPost)
\mfpverbtex{%&latex
\documentclass{scrartcl}
\begin{document}}
\setlength{\mfpicunit}{.5cm}
\opengraphsfile{\jobname}
\begin{document}
\begin{mfpic}[1]{-5}{9.5}{-3}{11}
% Points definitions. For MetaPost they are local pairs.
\setmfpair{P}{(-4, -2)}
\setmfpair{Q}{(8, 3)}
\setmfpair{R}{(4, 10)}
% Point M computed by MetaPost as intersection of y-axis and straight line (PQ)
\setmfpair{M}{(P -- R) intersectionpoint (origin -- (0, \ymax))}
% Point N computed by MetaPost as intersection of line (PQ)
% and the straight line perpendicular to (PQ) going through Q
\mfsrc{save N; pair N; N = whatever[P, R] = whatever[Q, Q + (R-P) rotated 90];}
% Mark angle beta with the convenient \arc macro of mfpic
\store{mark_angle}\arc[a]{P, 0.8, angle(Q-P), angle(R-P)}
% Mark right angle on N with help of MetaPost transformers
\setmfvariable{path}{mark_right_angle}
{((1, 0) -- (1, 1) -- (0, 1)) zscaled 0.3unitvector(Q-N) shifted N}
% Actual drawings
\polygon{P, Q, R}
\lines{Q, N}
\doaxes{xy}
\mfobj{mark_angle}
\mfobj{mark_right_angle}
% Labels
\tlpointsep{2bp} % Offset
\tlabels{[tc]{(\xmax, 0)}{$x$} [cr]{(0, \ymax)}{$y$}
[cr]{P}{$P(-4, -2)$} [cl]{Q}{$Q(8, 3)$} [bc]{R}{$R(4, 10)$}
[br]{M}{$M$} [cr]{N}{$N$} [bl]{point 0.4 of mark_angle}{$\beta$}}
\end{mfpic}
\closegraphsfile
\end{document}
该.tex
文件首先要用 (pdf)LaTeX 排版,然后.mp
用 MetaPost 对生成的文件进行排版,最后再用 (pdf)LaTeX 对 LaTeX 文件进行排版,以生成下图。