我想画一条线连接每个三角形的两条边。这条线应该连接 AB 和 BC。但是,我觉得很难。所以,你能帮我吗?谢谢
\documentclass[12pt,article]{elsarticle}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{figure}[!h]
\begin{minipage}{0.5\textwidth}
\centering
\begin{tikzpicture}[font=\sffamily]
\path (0,0) coordinate (A) (60:3) coordinate (B) (3,0) coordinate (C);
\draw[thick,path picture={
\foreach \X in {A,B,C}
{\draw[line width=0.4pt] (\X);}}]
(A) node[left]{$A$} to[bend right=12]
(B) node[above right]{$B$} to[bend right=15]
(C) node[right]{$C$} to[bend right=20] cycle;
% \node at (barycentric cs:A=1,B=1,C=1) {$<180^\circ$};
\end{tikzpicture}
\caption{Triangle in a CAT(0) space}
\label{fig:tri1}
\end{minipage}\hspace{0.05cm}%\hfill
\hspace{-0.12cm}
\begin{minipage}{0.5\textwidth}
\centering
\begin{tikzpicture}[font=\sffamily]
\path (0,0) coordinate (A) (60:3) coordinate (B) (3,0) coordinate (C);
\draw [thick,path picture={
\foreach \X in {A,B,C}
{\draw[line width=0.4pt] (\X);}}] (A) node[left]{$A$} (B) node[above right]{$B$} (C) node[right]{$C$} (0,0) -- (60:3) -- (3,0) -- cycle;
\end{tikzpicture}
\caption{Triangle in an Euclidean space}
\label{fig:tri2}
\end{minipage}%\hspace{0.05cm}%\hfill
\end{figure}
\end{document}
答案1
您可以coordinate
在路径段中间添加名为 的坐标,例如,\draw (A) -- coordinate(b) (C);
或在坐标和之间\draw (A) to[bend left] coordinate(b) (C);
会有一个名为 的坐标。b
A
C
要在坐标旁边添加标签节点,您可以使用该label
选项,例如“\draw(A)--coordinate [label = left:foo](b)(C);”
顺便说一下,在下面的代码中我减少了minipage
sa 的宽度,并将水平空间改为\hfill
。
\documentclass[12pt,article]{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\begin{minipage}{0.45\textwidth}
\centering
\begin{tikzpicture}[font=\sffamily]
\path (0,0) coordinate (A) (60:3) coordinate (B) (3,0) coordinate (C);
\draw[thick]
(A) node[left]{$A$} to[bend right=12] coordinate[label=left:$a$] (a)
(B) node[above right]{$B$} to[bend right=15] coordinate[label=right:$b$] (b)
(C) node[right]{$C$} to[bend right=20] coordinate (c) cycle;
% \node at (barycentric cs:A=1,B=1,C=1) {$<180^\circ$};
\draw (a) -- (b);
\end{tikzpicture}
\caption{Triangle in a CAT(0) space}
\label{fig:tri1}
\end{minipage}\hfill
\begin{minipage}{0.45\textwidth}
\centering
\begin{tikzpicture}[font=\sffamily]
\path (0,0) coordinate (A) (60:3) coordinate (B) (3,0) coordinate (C);
\draw [thick]
(A) node[left]{$A$} -- coordinate[label=left:$a$] (a)
(B) node[above right]{$B$} -- coordinate[label=right:$b$] (b)
(C) node[right]{$C$} -- coordinate (c)
cycle;
\draw (a) -- (b);
\end{tikzpicture}
\caption{Triangle in an Euclidean space}
\label{fig:tri2}
\end{minipage}
\end{figure}
\end{document}