我怎样才能在 LaTeX 中绘制附图?

我怎样才能在 LaTeX 中绘制附图?

在此处输入图片描述

我怎样才能在 LaTeX 中绘制附图?

答案1

我同意用户的评论,当然比我更熟练,但我的回答是一样的,因为它可能对其他人有用,特别是交集和宏定义的使用。

您必须将宏、、、、、\a设置为您想要的 x 值,然后将宏分别设置为上线斜率和截距。\b\c\d\e\f\m \q

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}

\begin{document}
\begin{tikzpicture}[extended line/.style={shorten >=-#1,shorten <=-#1}, extended line/.default=1cm]
\pgfmathsetmacro\d{0}
\pgfmathsetmacro\e{2}
\pgfmathsetmacro\f{4}
\pgfmathsetmacro\m{0.4}
\pgfmathsetmacro\q{3}
\pgfmathsetmacro\a{-1}
\pgfmathsetmacro\b{2}
\pgfmathsetmacro\c{5}

\coordinate[label=above:$A$](A)at(\a,\m*\a+\q);
\coordinate[label=above:$B$](B)at(\b,\m*\b+\q);
\coordinate[label=above:$C$](C)at(\c,\m*\c+\q);
\coordinate[label=below:$D$](D)at(\d,0);
\coordinate[label=below:$E$](E)at(\e,0);
\coordinate[label=below:$F$](F)at(\f,0);

\draw[blue, name path=A--E](A)--(E);
\draw[blue, name path=B--D](B)--(D);
\draw[blue, name path=A--F](A)--(F);
\draw[blue, name path=C--D](C)--(D);
\draw[blue, name path=B--F](B)--(F);
\draw[blue, name path=C--E](C)--(E);

\path [name intersections={of=A--E and B--D,by=P}];
\path [name intersections={of=A--F and C--D,by=Q}];
\path [name intersections={of=B--F and C--E,by=R}];
\node[blue, above]at(P){$P$};
\node[blue, above]at(Q){$Q$};
\node[blue, above]at(R){$R$};

\draw [extended line=0.5cm] (A)--(B)--(C);
\draw [extended line=0.5cm] (D)--(E)--(F);
\draw [extended line=0.5cm, red , dashed] (P)--(Q)--(R);

\draw[red, ->] (\d-1,0)--(\f+1,0);
\draw[red, ->] (0,-1)--(0,\c);

\fill (A)circle(2pt) (B)circle(2pt) (C)circle(2pt) (D)circle(2pt) (E)circle(2pt) (F)circle(2pt);
\fill[blue] (P)circle(2pt) (Q)circle(2pt) (R)circle(2pt);
\end{tikzpicture}
\end{document}

答案2

差不多就是这样了...

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}[dot/.style={insert path={ circle [radius=.05] }},
  line cap=round, line join=round, >=stealth]
\draw (0,2) -- (4,4)
  coordinate [pos=0.125] (A) coordinate [pos=0.5] (B) coordinate [pos=0.875] (C);

\draw (0,0) coordinate (O) -- (4,0) coordinate (O')
  coordinate [pos=0.2] (D) coordinate [pos=0.5] (E) coordinate [pos=0.8] (F);

\foreach \x/\y/\z in {A/E/F, B/D/F, C/D/E}{
  \draw [name path global=\x\y, blue!75!black] (\x) -- (\y);
  \draw [name path global=\x\z, blue!75!black] (\x) -- (\z); 
}

\foreach \x/\y/\z in {AE/BD/P, AF/CD/Q, BF/CE/R}
  \path [name intersections={of/.expanded=\x\space and \y, name=i}] 
    (i-1) coordinate (\z);

\draw [thick, orange, dashed, shorten >=-1cm, shorten <=-1cm] (P) -- (R);

\foreach \n in {A, B, C} \fill (\n) [dot] node [above] {\n};
\foreach \n in {D, E, F} \fill (\n) [dot] node [below] {\n};
\foreach \n/\a in {P/340, Q/280, R/330}
  \fill (\n) [dot] node [blue!75!black, anchor=\a] {\n};

\draw [ultra thick, ->, shorten >=-.125cm, red] (O) -- (O');
\draw [ultra thick, ->, red] (D) -- ++(0,3);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容