- 我怎样才能让(上方和下方)箭头彼此靠近一点?以及
- 如何将标签放在 \faIcon 符号下?
\documentclass[a4paper]{scrartcl}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{tikz}
\usepackage{tikz-uml}
\usetikzlibrary{shapes.multipart,positioning,fit}
\usepackage{pgf-umlsd}
\usetikzlibrary{arrows}
\usepackage{fontawesome}
\begin{document}
\begin{tikzpicture}
\node[scale=2.2] (A) at (0,0) {\faUser};
\node[scale=2,right=0.75cm of A] (B) at (A.east) {\faInstitution};
\node[scale=2,right=0.75cm of B] (C) at (B.east) {\faInstitution};
\draw[gray,->] (A.north east) -- (B.north west) node[midway, above]{\tiny{AA}};
\draw[gray,->] (B.north east) -- (C.north west) node[midway, above]{\tiny {BB}}; ;
\draw[gray,<-] (A.south east) -- (B.south west) node[midway, below]{\tiny {CC}}; ;
\draw[gray,<-] (B.south east) -- (C.south west) node[midway, below]{\tiny {DD}}; ;
\end{tikzpicture}
\end{document}
答案1
通过使用更多的库和样式定义,图像代码变得更加简单:
\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, % <--- changed
chains, % <--- new
positioning,
quotes} % <--- new
\usepackage{newtxtext,
fontawesome}
\begin{document}
\begin{tikzpicture}[
node distance = 9mm,
start chain = going right,
N/.style = {inner ysep=0pt, font=\Huge, on chain},
tc/.style = {transform canvas={yshift=#1}},
every label/.style= {font=\tiny, text=red},
every edge/.style = {draw, gray, -Straight Barb},
every edge quotes/.style = {auto, inner sep=1pt, font=\tiny}
]
\node[N,label=below:USER ] (A) {\faUser};
\node[N,label=below:ORG 1] (B) {\faInstitution};
\node[N,label=below:ORG 2] (C) {\faInstitution};
%
\draw[tc=+1ex]
(A) edge ["AA"] (B)
(B) edge ["BB"] (C);
\draw[tc=-1.2ex]
(C) edge ["AA"] (B)
(B) edge ["BB"] (A);
\end{tikzpicture}
\end{document}
答案2
请确保你的例子是最小的以及工作;你当前的示例对我来说编译不通过。我尝试制作一个在职的举个例子来说明你提出的问题。如果你还想了解更多信息,请随时告诉我。
\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}
\usepackage{fontawesome}
\begin{document}
\begin{tikzpicture}[label distance=-1em,every node/.style={font=\tiny}]
\node[scale=3.2,label=below:{USER}]
(A) at (0,0)
{\faUser};
\node[scale=3,right=2em of A,label=below:{ORG1}]
(B) at (A.east)
{\faInstitution};
\node[scale=3,right=2em of B,label=below:{ORG2}]
(C) at (B.east)
{\faInstitution};
\draw[gray,->] (A.25)--(B.157)
node[midway, above]{AA};
\draw[gray,->] (B.25)--(C.155)
node[midway, above]{BB};
\draw[gray,<-] (A.335)--(B.203)
node[midway, below]{CC};
\draw[gray,<-] (B.335)--(C.205)
node[midway, below]{DD};
\end{tikzpicture}
\end{document}