我正在forest
为一份报告绘制酶/底物的水平图。在我的实际standalone
文件中,它目前的样子如下:
我想使用standalone
以便可以添加引用和工作超链接。但是,包含文本的框太高,相对不重要的图形占用了主报告文档中的太多空间。我已经尝试过s sep
等,但因为我认为这是个tikz
问题(即文本框的高度),所以我不确定该怎么做,因为我最近才开始学习tikz
。我绝对不知道如何forest
与 交互tikz
以设置node
至少。
请问我怎样才能控制包含“马肝醇 DH”的框的高度node
(例如)并减少单词上方和下方的空间?
我的 MWE 如下所示:
梅威瑟:
\documentclass[border=0mm]{standalone}
\usepackage{forest}
\useforestlibrary{edges}
\usetikzlibrary{arrows,arrows.meta,automata,backgrounds,calc,
fit,shadings,shapes}
\usepackage{chemmacros}
\usepackage[hidelinks]{hyperref}
\begin{document}
\newcommand\hyperlinkStuff[2]{\scalebox{0.75}{\tiny(\color{blue}{\href{#1}{#2}}\color{black}{)}}}
\begin{forest}
for tree={%
grow'=east,
edge={thick, -Stealth},
tier/.option=level,
if level=0{%
thick,
draw=none,
font=\tiny,
align=left,
anchor=parent,
l=-5mm,
l sep=8mm,
s sep=0mm,
}{},
if level=1{%
thick,
draw,
font=\tiny,
align=left,
anchor=parent,
s sep=0mm,
}{},%
}
%
[\hspace{-2.08mm}Dehydrogen-\\\hspace{-2.08mm}ases (DH), for children={forked edge}, name=dh
[\textit{A. fulgidus} \iupac{\L-Alanine} DH \hyperlinkStuff{https://www.brenda-enzymes.org/enzyme.php?ecno=1.4.1.1}{1.4.1.1}, name=afaladh]
[Horse liver alcohol DH \hyperlinkStuff{https://www.brenda-enzymes.org/enzyme.php?ecno=1.1.1.1}{1.1.1.1}, name=hladh]
[\iupac{\L-Amino} acid DH \hyperlinkStuff{https://www.brenda-enzymes.org/enzyme.php?ecno=1.4.1.5}{1.4.1.5}, name=aadh]
[Glutamate DH \hyperlinkStuff{https://www.brenda-enzymes.org/enzyme.php?ecno=1.4.1.2}{1.4.1.2}, name=gdh ]
[\iupac{\L-Leucine} DH \hyperlinkStuff{https://www.brenda-enzymes.org/enzyme.php?ecno=1.4.1.9}{1.4.1.9}, name=leucine]
[Amine DH \hyperlinkStuff{https://www.brenda-enzymes.org/enzyme.php?ecno=1.4.9.1}{1.4.9.1}, name=amdh]
]
%
\node[%above=2pt,
font=\bfseries\tiny,
above=4pt,
anchor=west,
] at (afaladh.north west) {Enzyme name \scalebox{0.75}{\tiny(\normalfont EC number)}};
%
\end{forest}
\end{document}
答案1
您可以添加inner ysep=1pt
(或任意长度)到for tree
。
\documentclass[border=0mm]{standalone}
\usepackage{forest}
\useforestlibrary{edges}
\usetikzlibrary{arrows,arrows.meta,automata,backgrounds,calc,
fit,shadings,shapes}
\usepackage{chemmacros}
\usepackage[hidelinks]{hyperref}
\begin{document}
\newcommand\hyperlinkStuff[2]{\scalebox{0.75}{\tiny(\color{blue}{\href{#1}{#2}}\color{black}{)}}}
\begin{forest}
for tree={%
grow'=east,
inner ysep=1pt, % <----- Added
edge={thick, -Stealth},
tier/.option=level,
if level=0{%
thick,
draw=none,
font=\tiny,
align=left,
anchor=parent,
l=-5mm,
l sep=8mm,
s sep=0mm,
}{},
if level=1{%
thick,
draw,
font=\tiny,
align=left,
anchor=parent,
s sep=0mm,
}{},%
}
%
[\hspace{-2.08mm}Dehydrogen-\\\hspace{-2.08mm}ases (DH), for children={forked edge}, name=dh
[\textit{A. fulgidus} \iupac{\L-Alanine} DH \hyperlinkStuff{https://www.brenda-enzymes.org/enzyme.php?ecno=1.4.1.1}{1.4.1.1}, name=afaladh]
[Horse liver alcohol DH \hyperlinkStuff{https://www.brenda-enzymes.org/enzyme.php?ecno=1.1.1.1}{1.1.1.1}, name=hladh]
[\iupac{\L-Amino} acid DH \hyperlinkStuff{https://www.brenda-enzymes.org/enzyme.php?ecno=1.4.1.5}{1.4.1.5}, name=aadh]
[Glutamate DH \hyperlinkStuff{https://www.brenda-enzymes.org/enzyme.php?ecno=1.4.1.2}{1.4.1.2}, name=gdh ]
[\iupac{\L-Leucine} DH \hyperlinkStuff{https://www.brenda-enzymes.org/enzyme.php?ecno=1.4.1.9}{1.4.1.9}, name=leucine]
[Amine DH \hyperlinkStuff{https://www.brenda-enzymes.org/enzyme.php?ecno=1.4.9.1}{1.4.9.1}, name=amdh]
]
%
\node[%above=2pt,
font=\bfseries\tiny,
above=4pt,
anchor=west,
] at (afaladh.north west) {Enzyme name \scalebox{0.75}{\tiny(\normalfont EC number)}};
%
\end{forest}
\end{document}
答案2
我将编写提供的树代码如下:
\documentclass{standalone}
\usepackage{forest}
\useforestlibrary{edges}
\usetikzlibrary{arrows,arrows.meta,automata,backgrounds,calc,
fit,shadings,shapes}
\usepackage{chemmacros}
\usepackage[
colorlinks=true,
urlcolor=blue,
]{hyperref}
\newcommand\hyperlinkStuff[2]{\scalebox{0.75}{\href{#1}{#2}}}
\begin{document}
\begin{forest}
for tree={%
font=\tiny,
inner ysep =
align=left,
anchor=west,
%
grow'=east,
edge={thick, -Stealth},
forked edge, % for forked edge
l sep = 6mm,
fork sep = 2mm,
s sep = 1pt, % <----
if level=1{draw, thick}{},
tier/.option=level,
}
%
[Dehydrogen-\\ases (DH), name=dh
[\textit{A. fulgidus} \iupac{\L-Alanine} DH \hyperlinkStuff{https://www.brenda-enzymes.org/enzyme.php?ecno=1.4.1.1}{1.4.1.1}, name=afaladh]
[Horse liver alcohol DH \hyperlinkStuff{https://www.brenda-enzymes.org/enzyme.php?ecno=1.1.1.1}{1.1.1.1}, name=hladh]
[\iupac{\L-Amino} acid DH \hyperlinkStuff{https://www.brenda-enzymes.org/enzyme.php?ecno=1.4.1.5}{1.4.1.5}, name=aadh]
[Glutamate DH \hyperlinkStuff{https://www.brenda-enzymes.org/enzyme.php?ecno=1.4.1.2}{1.4.1.2}, name=gdh ]
[\iupac{\L-Leucine} DH \hyperlinkStuff{https://www.brenda-enzymes.org/enzyme.php?ecno=1.4.1.9}{1.4.1.9}, name=leucine]
[Amine DH \hyperlinkStuff{https://www.brenda-enzymes.org/enzyme.php?ecno=1.4.9.1}{1.4.9.1}, name=amdh]
]
%
\node[font=\bfseries\tiny,
above=4pt,
anchor=west,
] at (afaladh.north west) {Enzyme name \scalebox{0.75}{(\normalfont EC number)}};
\end{forest}
\end{document}
如您所见,节点之间的垂直距离由 设定s sep=1pt
(在代码中用 标记<--
)。您可以根据需要更改距离的大小。
编辑:
显然,由于某些未知的原因,您更喜欢节点的边界紧贴文本,并且节点具有垂直距离,例如如下所示:
对于这个(丑陋的)结果你需要for tree
添加选项:
inner ysep = 0.5pt, outer ysep=0pt,
并改为s sep = 1pt
`s sep = 0pt。
附录:
对于第一幅有问题的图像,可能的解决方案是:
\documentclass{standalone}
\usepackage[edges]{forest}
\usetikzlibrary{arrows.meta}
\usepackage{chemmacros}
\usepackage[
colorlinks=true,
urlcolor=blue,
]{hyperref}
\newcommand\HLscale[2]{\scalebox{0.75}{\href{#1}{#2}}}
\begin{document}
\begin{forest}
for tree={%
% nodes
font=\tiny,
inner sep=2pt, outer sep=0pt,
align=left,
% tree
grow'=east,
anchor=west,
forked edge, % for forked edge
l sep = 6mm,
fork sep = 3mm,
s sep = 2pt, % <----
/tikz/arr/.style = {thick, -{Stealth[scale=0.8]}},
if level = 1{draw, thick}{},
if level> = 3{edge={draw=none}}{edge={arr}},
tier/.option=level,
}
%
[Dehydrogen-\\ases (DH)
[\textit{A. fulgidus} \iupac{\L-Alanine} DH
\HLscale{https://www.brenda-enzymes.org/enzyme.php?ecno=1.4.1.1}{1.4.1.1},
name=m1
[L-Alanine, name=n1
[ [test name, name=t1]]]
]
[Horse liver alcohol DH
\HLscale{https://www.brenda-enzymes.org/enzyme.php?ecno=1.1.1.1}{1.1.1.1}
[Ethanol, name=n2
[ [test name, name=t2]]]
]
[\iupac{\L-Amino} acid DH
\HLscale{https://www.brenda-enzymes.org/enzyme.php?ecno=1.4.1.5}{1.4.1.5}
[L-Glicine, name=n3
[NADPH, name=nadph
[test name, name=t3]
]
]
]
[Glutamate DH
\HLscale{https://www.brenda-enzymes.org/enzyme.php?ecno=1.4.1.2}{1.4.1.2}
[L-Glicine, name=n4
[ [test name, name=t4]]
]
]
[\iupac{\L-Leucine} DH
\HLscale{https://www.brenda-enzymes.org/enzyme.php?ecno=1.4.1.9}{1.4.1.9}
[L-Leucine, name=n5
[ [test name, name=t5]]
]
]
[Amine DH
\HLscale{https://www.brenda-enzymes.org/enzyme.php?ecno=1.4.9.1}{1.4.9.1},
[Methylamine, name=n6
[TTQ, name=ttq
[Test, name=T]
]
]
]
]
%
\node[inner sep=2pt,
font=\bfseries\tiny,
above right,
] at (m1.north west) {Enzyme name \scalebox{0.75}{(\normalfont EC number)}};
\draw[thick]
(nadph.west) -- ++ (-3mm,0) coordinate (aux-1) |- (n1)
(aux-1) |- (n2)
(aux-1) -- (n3)
(aux-1) |- (n4)
(aux-1) |- (n5)
%
(nadph.east) -- ++ (3mm,0) coordinate (aux-2) |- (t1)
(aux-2) |- (t2)
(aux-2) -- (t3)
(aux-2) |- (t4)
(aux-2) |- (t5);
\draw[arr] (n6) -- (ttq);
\draw[arr] (ttq) -- (T);
\end{forest}
\end{document}