我需要将两个块之间的箭头向上或向下移动。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,fit,arrows}
\usepackage{graphicx}
\begin{document}
\noindent\resizebox{\textwidth}{!}{
\begin{tikzpicture}[auto,node distance=5cm,>=stealth']
\tikzset{
block/.style= {draw, rectangle, minimum height=2em,minimum width=4em},
sum/.style = {draw, circle, node distance=2cm},
input/.style = {coordinate},
output/.style = {coordinate}}
\node [block] (A) {};
\node [block, right of=A] (B) {};
\draw [->] (A) -- node {} (B);
\end{tikzpicture}
}
\end{document}
答案1
箭头可以通过画布变换来移动:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,fit,arrows}
\usepackage{graphicx}
\begin{document}
\noindent\resizebox{\textwidth}{!}{%
\begin{tikzpicture}[auto,node distance=5cm,>=stealth']
\tikzset{
block/.style= {draw, rectangle, minimum height=2em,minimum width=4em},
sum/.style = {draw, circle, node distance=2cm},
input/.style = {coordinate},
output/.style = {coordinate}}
\node [block] (A) {};
\node [block, right of=A] (B) {};
\begin{scope}[transform canvas={yshift=.7em}]
\draw [->] (A) -- node {} (B);
\end{scope}
\end{tikzpicture}%
}
\end{document}
箭头(或线)的长度可以通过shorten <
和进行修改shorten >
:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,fit,arrows}
\usepackage{graphicx}
\begin{document}
\noindent\resizebox{\textwidth}{!}{%
\begin{tikzpicture}[auto,node distance=5cm,>=stealth']
\tikzset{
block/.style= {draw, rectangle, minimum height=2em,minimum width=4em},
sum/.style = {draw, circle, node distance=2cm},
input/.style = {coordinate},
output/.style = {coordinate}}
\node [block] (A) {};
\node [block, right of=A] (B) {};
\begin{scope}[transform canvas={yshift=.7em}]
\draw [->, shorten <=5mm, shorten >=5mm] (A) -- node {} (B);
\end{scope}
\end{tikzpicture}%
}
\end{document}
评论:
- TeX内部
\resizebox
处于水平模式。因此空格很重要,需要删除不需要的行尾空格,例如,在行尾添加注释字符。