我是 tikzp 新手,需要一些帮助来完成这项任务(代表版主)。有人能帮我解决我的代码吗?我怎样才能延长箭头的长度?以及如何告诉 tikzp 它应该绘制这种箭头?
我的代码:
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\usetikzlibrary{positioning}
\begin{document}
\begin{figure}[h]
\label{illustration}
\centering
\caption{The model}
\begin{tikzpicture}[
node distance=1cm and 1cm,
ar/.style={->,>=latex},
mynode/.style={
draw,
text width=4cm,
minimum height=1cm,
align=center
}
]
\node[mynode] (LE) {Level of expertise};
\node[mynode,right=of LE] (PS) {Problem solving time};
\node[mynode,below=of LE] (FI) {Fluid intelligence};
\draw[ar]
(LE) -> node[above] {-} (PS);
\draw[ar]
(FI) -> node[left] {-} (PS);
\end{tikzpicture}
\end{figure}
\end{document}
答案1
还有另一个答案,在从到coordinate
绘制箭头时动态定义。LE
PS
\documentclass[border=1mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}%
[node distance=1cm and 1cm,
ar/.style={->,>=latex},
mynode/.style=
{draw,
text width=4cm,
minimum height=1cm,
align=center
}
]
\node[mynode] (LE) {Level of expertise};
\node[mynode,right=of LE] (PS) {Problem solving time};
\draw[ar] (LE) -> node[above] {-} coordinate(LE-PS) (PS);
\node[mynode,below=of LE-PS] (FI) {Fluid intelligence};
\draw[ar] (FI) -> node[left] {-} (LE-PS);
\end{tikzpicture}
\end{document}
答案2
使用calc
库并 ($(LE)!0.5!(PS)$)
到达所需位置
我使用这个命令来定位节点(FI)并跟踪线段
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\usetikzlibrary{positioning,calc}
\begin{document}
\begin{figure}[h]
\label{illustration}
\centering
\caption{The model}
\begin{tikzpicture}[
node distance=1cm and 1cm,
ar/.style={->,>=latex},
mynode/.style={
draw,
text width=4cm,
minimum height=1cm,
align=center
}
]
\node[mynode] (LE) {Level of expertise};
\node[mynode,right=of LE] (PS) {Problem solving time};
\node[mynode,below=of $(LE)!0.5!(PS)$] (FI) {Fluid intelligence}; % <-- changed
\draw[ar]
(LE) -> node[above] {-} (PS);
\draw[ar]
(FI) -> node[left] {-} ($(LE)!0.5!(PS)$); % <-- changed
\end{tikzpicture}
\end{figure}
\end{document}
答案3
\documentclass{article}
\usepackage{caption} % <-- added
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{figure}[h]
\centering
\caption{The model}
\label{illustration} % <-- changed position to after caption
\begin{tikzpicture}[
node distance = 1cm and 2cm,% <-- changed
ar/.style = {-latex},
mynode/.style = {draw,
text width=4cm,
minimum height=1cm,
align=center}
]
\node[mynode] (LE) {Level of expertise};
\node[mynode,right=of LE] (PS) {Problem solving time};
\node[mynode,below=of LE.south east] (FI) {Fluid intelligence};
%
\draw[ar] (LE) -- coordinate[label=$-$] (a) (PS); % <-- changed
\draw[ar] (FI) -- node[left] {$-$} (a); % <-- changed
\end{tikzpicture}
\end{figure}
\end{document}