我有以下问题。
如您所见,最后一个节点的高度会使箭头缩小。我想通过将节点向下移动来固定箭头的大小。我该怎么做?
这是我的代码的一个示例。
%% LyX 2.1.0 created this file. For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[14pt,spanish]{extarticle}
\usepackage{fontspec}
\setmainfont[Mapping=tex-text]{Ubuntu}
\usepackage{geometry}
\geometry{verbose,tmargin=2cm,bmargin=2cm,lmargin=2cm,rmargin=2cm}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{tikz}
\usepackage{textgreek}
\usepackage{mhchem}
\usepackage{gensymb}
\usetikzlibrary{shapes.geometric, arrows}
\tikzstyle{inicio} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=yellow]
\tikzstyle{nodo} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black]
\tikzstyle{arrow} = [thick,->,>=stealth]
\tikzstyle{centerzero} = [trim left=0pt,trim right=0pt]
\makeatother
\usepackage{babel}
\addto\shorthandsspanish{\spanishdeactivate{~<>}}
\usepackage{xunicode}
\begin{document}
\begin{center}
\begin{tikzpicture}[node distance=2cm, centerzero]
\node (crecimiento) [inicio] {Crecimiento de la biomasa};
\node (luz) [nodo, below of=crecimiento, xshift=-3cm] {Luz}; \draw [arrow] (crecimiento) -- (luz);
\node (oscuridad) [nodo, below of=crecimiento, xshift=3cm] {Oscuridad}; \draw [arrow] (crecimiento) -- (oscuridad);
\node (alto) [nodo, below of=luz] {Alto crecimiento}; \draw [arrow] (luz) -- (alto);
\node (bajo) [nodo, below of=oscuridad] {Bajo crecimiento}; \draw [arrow] (oscuridad) -- (bajo);
\node (bc1-alto) [nodo, below of=alto, xshift=-2cm, text width=2cm] {BC1: 150 a 470 mg SSl\textsuperscript{-1}}; \draw [arrow] (alto) -- (bc1-alto);
\node (bc2-alto) [nodo, below of=alto, xshift=2cm, text width=2cm] {BC2: 1500 a 1620 mg SSl\textsuperscript{-1}}; \draw [arrow] (alto) -- (bc2-alto);
\end{tikzpicture}
\par\end{center}
\end{document}
答案1
使用positioning
库并使用below = of...
语法below=of
%% LyX 2.1.0 created this file. For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[14pt,spanish]{extarticle}
%\usepackage{fontspec}
%\setmainfont[Mapping=tex-text]{Ubuntu}
\usepackage{geometry}
\geometry{verbose,tmargin=2cm,bmargin=2cm,lmargin=2cm,rmargin=2cm}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{tikz}
\usepackage{textgreek}
\usepackage{mhchem}
\usepackage{gensymb}
\usetikzlibrary{shapes.geometric, arrows,positioning}
\tikzstyle{inicio} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=yellow]
\tikzstyle{nodo} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black]
\tikzstyle{arrow} = [thick,->,>=stealth]
\tikzstyle{centerzero} = [trim left=0pt,trim right=0pt]
\makeatother
\usepackage{babel}
\addto\shorthandsspanish{\spanishdeactivate{~<>}}
%\usepackage{xunicode}
\begin{document}
\begin{center}
\begin{tikzpicture}[node distance=2cm, centerzero,anchor=north]
\node (crecimiento) [inicio] {Crecimiento de la biomasa};
\node (luz) [nodo, below = of crecimiento, xshift=-3cm] {Luz}; \draw [arrow] (crecimiento) -- (luz);
\node (oscuridad) [nodo, below = of crecimiento, xshift=3cm] {Oscuridad}; \draw [arrow] (crecimiento) -- (oscuridad);
\node (alto) [nodo, below = of luz] {Alto crecimiento}; \draw [arrow] (luz) -- (alto);
\node (bajo) [nodo, below =of oscuridad] {Bajo crecimiento}; \draw [arrow] (oscuridad) -- (bajo);
\node (bc1-alto) [nodo, below = of alto, xshift=-2cm, text width=2cm] {BC1: 150 a 470 mg SSl\textsuperscript{-1}}; \draw [arrow] (alto) -- (bc1-alto);
\node (bc2-alto) [nodo, below = of alto, xshift=2cm, text width=2cm] {BC2: 1500 a 1620 mg SSl\textsuperscript{-1}}; \draw [arrow] (alto) -- (bc2-alto);
\end{tikzpicture}
\par\end{center}
\end{document}
此外,最好使用tilzset
已弃用的“tikzstyle”。
\tikzset{inicio/.style = {rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=yellow},
nodo/.style = {rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black},
}
答案2
在选项中使用yshift
负值node
。
\node (bc1-alto) [nodo, below of=alto, xshift=-2cm,yshift=-1cm, text width=2cm] {BC1: 150 a 470 mg SSl\textsuperscript{-1}}; \draw [arrow] (alto) -- (bc1-alto);
\node (bc2-alto) [nodo, below of=alto, xshift=2cm,yshift=-1cm, text width=2cm] {BC2: 1500 a 1620 mg SSl\textsuperscript{-1}}; \draw [arrow] (alto) -- (bc2-alto);