我是 LaTeX 新手,我开始学习它主要是为设计思维导图。我的目标是将包含许多概念(如 40 条定理)的数学课程综合到思维导图上,使其能够达到 4、5 或 6 级,同时优化其大小。我做了很多研究,发现了这个主题:思维导图,获得规则/和谐圆形的通用方法,适用于 3 级及以上级别
此外,我找不到允许作者创建这个漂亮的思维导图的代码。我拿来并修改了文章中另一个人编写的最后一段代码,该代码适用于第 3 级,但我对第 4 级有些问题,这是我的代码:
\documentclass[tikz,border=2]{standalone}
\usetikzlibrary{mindmap, decorations.pathmorphing}
\makeatletter
\newcount\tikz@count@leaf % count only leaf
\def\tikz@grow@concentric{
\pgftransformreset%
\pgftransformshift{\pgfpoint
{\pgfkeysvalueof{/tikz/smuggle xshift}}
{\pgfkeysvalueof{/tikz/smuggle yshift}}}
\pgftransformrotate{
\pgfkeysvalueof{/tikz/smuggle rotation}+
(\pgfkeysvalueof{/tikz/sibling angle})*(\tikz@count@leaf)}
\ifnum\pgfkeysvalueof{/tikz/nold}=0
% this is a leaf
\global\advance\tikz@count@leaf by1
\else
% this is not a leaf
% we need to rotate it further
\pgftransformrotate{
(\pgfkeysvalueof{/tikz/sibling angle})*
(\pgfkeysvalueof{/tikz/nold}-1)/2}
\tikzset{nold/.initial=0} % reset for safty
\fi
\pgftransformxshift{\the\tikzleveldistance}
}
\begin{document}
\tikzset{
smuggle rotation/.initial=0,
smuggle xshift/.initial=0pt,
smuggle yshift/.initial=0pt,
Xshift/.style={xshift=#1,smuggle xshift=#1},
Yshift/.style={yshift=#1,smuggle yshift=#1},
Rotate/.style={smuggle rotate=#1},
nold/.initial=0, % hint tikz the number of leaf in its descendants
% explain: don't count a child if they have your grand-child
branch color/.style={
concept color=#1!white,
every child/.append style={concept color=#1!white!30!white},
}
}
\tikzstyle{circle connection bar}=[to path={[every circle connection bar] decorate [decoration={bent}] { -- (\tikztotarget) \tikztonodes}},
append after command={[fill=white,draw=black]}]
\begin{tikzpicture}
% \draw foreach\i in{1,...,36}{
% (0:0)--(\i*10:15)
% };
\begin{scope}[text width=1.5cm,
mindmap,
growth function=\tikz@grow@concentric,
sibling angle=15,
nodes={concept, draw=blue!30, minimum size=0cm, inner sep=1mm},
concept color=orange!60,
level 1/.style={
level distance=8cm,
minimum size=3.0cm,text width=2.5cm
},
level 2/.style={
level distance=12cm,
minimum size=2.0cm,text width=2.0cm
},
level 3/.style={
level distance=15cm,
minimum size=2.0cm,text width=2.0cm
}
level 4/.style={
level distance=15cm,
minimum size=2.0cm,text width=2.0cm
}
]
\node [root concept]{Dimension finie}
child[nold=9]{node {EV de DF}
child[nold=2] {node {L. Steinitz}
child[nold=1] {node {T. Base intermédiaire}
child {node {T. Base incomplète}}
}
child {node {P. Dim infinie}}
}
child[nold=1] {node {T. Dim de f. libres, génératrices, bonux 1}
child{node{T. Bonux 2}}
}
child {node {P. Dim d'un produit}}
child[nold=5] {node {P. Grassman}
child{node {P. Non généralisation de Grassman}}
child[nold=2]{node {P. Dim de sommes directes}
child{node {P. Supplémentaires}}
child{node {T. Bonux 3 des supplé.}}
}
child[nold=2]{node {D. Le rang}
child{node {P. sur le rang}}
child{node {P. Rang, lib, gén, base}}
}
}
}
child[nold=8]{node {ALM}
child[nold=3]{ node (equity) {Equity}
child { node {Indices}}
child { node {Stocks}}
child { node {ETFs}}
}
child[nold=3]{ node (commo) {Commodities}
child { node {Soft commo}}
child { node {Precious}}
child { node {Oil/Gas}}
}
child {node {Assurances}}
child {node {Caisse de retraite}}
}
child[nold=1]{node {Directions financieres}
child {node {Corporate}}
}
child[nold=3]{node {Instrument specialists}
child {node {Asset Managers traditionnels}}
child {node {Hedge funds}}
child {node {Trading desks form other banks}}
}
;
\end{scope}
\end{tikzpicture}
\end{document}
除此之外,我想知道是否可以修改 3 级和 4 级的级别距离,以产生更大的气泡,因为它们似乎被锁定以允许增长函数形成一个良好的圆圈。
最后,我会把我的定理和命题放入矩形而不是气泡中,如果您有任何优化这种风格的建议,请告诉我(矩形之间的级别距离很难使用,因为它以矩形的中心为基础)
感谢你所做的一切 !
答案1
可以为此设计一些增长函数。这是一个将配置存储在辅助文件中并在第二次运行中使用它的版本。它基本上记录了给定级别出现多少个节点,并将此信息用于布局。它确实重建了您要求的代码的图形。
\documentclass[tikz,border=9]{standalone}
\usetikzlibrary{mindmap,decorations}
\makeatletter
\newcount\tikzcountchildi
\newcount\tikzcountchildii
\newcount\tikzcountchildiii
\newcount\tikzcountchildiv
\newcount\tikzcountchildv
\newcount\tikzcountchildvi
\tikzset{garlic growth/.style={growth function=\tikz@grow@garlic,
/tikz/mmap/name=#1,mmap/#1/.is family,
mmap/initialize counts,
execute at end scope={%
\tikz@mmap@store@aux{n-i}{\the\tikzcountchildi}%
\tikz@mmap@store@aux{n-ii}{\the\tikzcountchildii}%
\tikz@mmap@store@aux{n-iii}{\the\tikzcountchildiii}%
\tikz@mmap@store@aux{n-iv}{\the\tikzcountchildiv}%
\tikz@mmap@store@aux{n-v}{\the\tikzcountchildv}%
\tikz@mmap@store@aux{n-vi}{\the\tikzcountchildvi}}},
mmap/.cd,initialize counts/.code={\tikzcountchildi=0%
\tikzcountchildii=0%
\tikzcountchildiii=0%
\tikzcountchildiv=0%
\tikzcountchildv=0%
\tikzcountchildvi=0%
}
}
\def\tikz@mmap@store@aux#1#2{%
\immediate\write\@mainaux{\string\expandafter\xdef\noexpand\csname pgfk@/tikz/mmap/\pgfkeysvalueof{/tikz/mmap/name}/#1\string\endcsname{#2}}}%
\def\tikz@mmap@get@from@aux#1#2{%
\ifcsname pgfk@/tikz/mmap/\pgfkeysvalueof{/tikz/mmap/name}/#1\endcsname
\edef#2{\csname pgfk@/tikz/mmap/\pgfkeysvalueof{/tikz/mmap/name}/#1\endcsname}%
\else
\edef#2{0}%
\fi
}
\newcount\tikzcountgrandchild
\def\tikz@grow@garlic{%
\pgfmathsetmacro{\pgfutil@tempa}{\pgfkeysvalueof{/tikz/mmap/overall rotation}}%
\ifcase\tikztreelevel
\or
\global\advance\tikzcountchildi by1\relax%
\tikz@mmap@get@from@aux{n-i}{\myni}%
\tikz@mmap@get@from@aux{n-ii}{\mynii}%
\tikz@mmap@get@from@aux{n-1-\the\tikzcountchildi}{\mynall}%
\tikz@mmap@get@from@aux{p-1-\the\tikzcountchildi}{\mypi}%
\ifnum\mynii>0
\pgfmathsetmacro{\pgfutil@tempa}{\pgfutil@tempa+\pgfkeysvalueof{/tikz/mmap/sign}%
*(\pgfkeysvalueof{/tikz/mmap/child weight}*(\mypi)*360/\mynii+%
(1-\pgfkeysvalueof{/tikz/mmap/child weight})*(\tikzcountchildi-1)*360/\myni)}%
\fi
\or
\global\advance\tikzcountchildii by1\relax%
\tikz@mmap@get@from@aux{n-ii}{\mynii}%
\tikz@mmap@get@from@aux{n-1-1}{\mynall}%
\ifnum\mynii>0
\pgfmathsetmacro{\pgfutil@tempa}{\pgfutil@tempa+\pgfkeysvalueof{/tikz/mmap/sign}%
*(\tikzcountchildii-1-\mynall/2)*360/\mynii}%
\fi
\ifnum\tikznumberofcurrentchild=1\relax
\tikz@mmap@store@aux{n-1-\the\tikzcountchildi}{\the\tikznumberofchildren}%
\tikz@mmap@store@aux{p-1-\the\tikzcountchildi}{\the\numexpr\tikzcountchildii-1}%
\tikz@mmap@store@aux{a-1-\the\tikzcountchildi-\the\tikzcountchildii}{\pgfutil@tempa}%
\fi
\or
\global\advance\tikzcountchildiii by1\relax%
\ifnum\tikznumberofcurrentchild=1\relax
\tikz@mmap@store@aux{n-1-\the\tikzcountchildi-\the\tikzcountchildii}{\the\tikznumberofchildren}%
\tikz@mmap@store@aux{p-1-\the\tikzcountchildi-\the\tikzcountchildii}{\the\numexpr\tikzcountchildiii-1}%
\fi
\tikz@mmap@get@from@aux{n-iii}{\myniii}%
\tikz@mmap@get@from@aux{a-1-1-1}{\bettera}%
\tikz@mmap@get@from@aux{n-1-1-1}{\mynall}%
\ifdim\bettera pt=0pt\relax
\else
\pgfmathsetmacro{\pgfutil@tempa}{\bettera}%
\fi
\ifnum\myniii>0
\pgfmathsetmacro{\pgfutil@tempa}{\pgfutil@tempa+\pgfkeysvalueof{/tikz/mmap/sign}%
*(\tikzcountchildiii-1-\mynall/2)*360/\myniii}%
\fi
\or
\global\advance\tikzcountchildiv by1\relax%
\tikz@mmap@get@from@aux{n-iv}{\myniv}%
\ifnum\myniv>0
\pgfmathsetmacro{\pgfutil@tempa}{\pgfutil@tempa+\pgfkeysvalueof{/tikz/mmap/sign}*(\tikzcountchildiv-1)*360/\myniv}%
\fi
\or
\tikz@mmap@get@from@aux{n-v}{\mynv}%
\pgfmathsetmacro{\pgfutil@tempa}{\pgfutil@tempa+\pgfkeysvalueof{/tikz/mmap/sign}*(\tikzcountchildv-1)*360/\mynv}%
\ifnum\mynv>0
\global\advance\tikzcountchildv by1\relax%
\fi
\or
\global\advance\tikzcountchildvi by1\relax%
\tikz@mmap@get@from@aux{n-vi}{\mynvi}%
\ifnum\myvi>0
\pgfmathsetmacro{\pgfutil@tempa}{\pgfutil@tempa+(\tikzcountchildvi-1)*360/\mynvi}%
\fi
\fi
\pgftransformreset%
\pgftransformshift{\pgfpoint{\pgfkeysvalueof{/tikz/mmap/overall xshift}}%
{\pgfkeysvalueof{/tikz/mmap/overall yshift}}}%
\pgftransformrotate{\pgfutil@tempa}%
\pgftransformxshift{\the\tikzleveldistance}%
}
\makeatother
\begin{document}
\tikzset{mmap/.cd,
name/.initial=undef,
overall rotation/.initial=0,
overall xshift/.initial=0pt,
overall yshift/.initial=0pt,
sign/.initial=1,
child weight/.initial=0.5,
/tikz/.cd,
Xshift/.style={xshift=#1,mmap/overall xshift=#1},
Yshift/.style={yshift=#1,mmap/overall yshift=#1},
branch color/.style={
concept color=#1!80,ball color=#1!50,
every child/.append style={concept color=#1!50},
}
}
\begin{tikzpicture}
\begin{scope}[
mindmap,garlic growth=A,mmap/child weight=0,
mmap/overall rotation=-70,mmap/sign=-1,
nodes={concept,align=center, text width=2.5cm,inner sep=1mm},
concept color=orange!60,
level 1/.style={nodes=concept,
%every child/.append style={concept color=orange},
level distance=5cm,
},
level 2/.style={%opacity=0,
%every child/.append style={concept color=blue},
level distance=10cm,
minimum size=2.0cm
},
level 3/.style={%opacity=0,
%every child/.append style={concept color=green!70!black},
level distance=15cm,sibling angle=40,
minimum size=2.0cm,
},
level 4/.style={%opacity=0,
%level distance=20cm,
minimum size=2.0cm,text width=2.0cm
}
]
\node [root concept,ball color=orange!50]{Core}
child[branch color=yellow]{node[shading=ball] {Core-1}
child {node {Core-1-1}
child {node {Core-1-1-1}}
child {node {Core-1-1-2}}
child {node {Core-1-1-3}}
}
child {node {Core-1-2}
child {node {Core-1-2-1}}
child {node {Core-1-2-2}}
child {node {Core-1-2-3}}
}
child {node {Core-1-3}
child {node {Core-1-3-1}}
}
child {node {Core-1-4}
child {node {Core-1-4-1}}
}
child {node {Core-1-5}
child {node {Core-1-5-1}}
child {node {Core-1-5-2}}
}
}
child[branch color=blue]{node[shading=ball] {Core-2}
child {node {Core-2-1}
child {node {Core-1-1-1}}
child {node {Core-1-1-2}}
}
child {node {Core-2-2}
child {node {Core-2-2-1}}
child {node {Core-2-2-2}}
child {node {Core-2-2-3}}
child {node {Core-2-2-4}}
}
}
child[branch color=red]{node[shading=ball] {Core-3}
child {node {Core-3-1}
child {node {Core-3-1-1}}
child {node {Core-3-1-2}}
}
child {node {Core-3-2}
child {node {Core-3-2-1}}
child {node {Core-3-2-2}}
}
child {node {Core-3-3}
child {node {Core-3-3-1}}
child {node {Core-3-3-2}}
}
child {node {Core-3-4}
}
}
child[branch color=gray]{node[shading=ball] {Core-4}
child {node {Core-4-1}
child {node {Core-4-1-1}}
child {node {Core-4-1-2}}
}
child {node {Core-4-2}
child {node {Core-4-2-1}}
child {node {Core-4-2-2}}
}
child {node {Core-4-3}
child {node {Core-4-3-1}}
child {node {Core-4-3-2}}
}
child {node {Core-4-4}
}
}
child[branch color=orange]{node[shading=ball] {Core-5}
child {node {Core-5-1}
child {node {Core-5-1-1}}
}
child {node {Core-5-2}
child {node {Core-5-2-1}}
child {node {Core-5-2-2}}
}
child {node {Core-5-3}
child {node {Core-5-3-1}}
child {node {Core-5-3-2}}
}
child {node {Core-5-4}
}
child {node {Core-5-5}
}
}
;
\end{scope}
\end{tikzpicture}
\end{document}
在其他情况下,必须有人手动帮助
\documentclass[tikz,border=9]{standalone}
\usetikzlibrary{mindmap,decorations}
\makeatletter
\newcount\tikzcountchildi
\newcount\tikzcountchildii
\newcount\tikzcountchildiii
\newcount\tikzcountchildiv
\newcount\tikzcountchildv
\newcount\tikzcountchildvi
\tikzset{garlic growth/.style={growth function=\tikz@grow@garlic,
/tikz/mmap/name=#1,mmap/#1/.is family,
mmap/initialize counts,
execute at end scope={%
\tikz@mmap@store@aux{n-i}{\the\tikzcountchildi}%
\tikz@mmap@store@aux{n-ii}{\the\tikzcountchildii}%
\tikz@mmap@store@aux{n-iii}{\the\tikzcountchildiii}%
\tikz@mmap@store@aux{n-iv}{\the\tikzcountchildiv}%
\tikz@mmap@store@aux{n-v}{\the\tikzcountchildv}%
\tikz@mmap@store@aux{n-vi}{\the\tikzcountchildvi}}},
mmap/.cd,initialize counts/.code={\tikzcountchildi=0%
\tikzcountchildii=0%
\tikzcountchildiii=0%
\tikzcountchildiv=0%
\tikzcountchildv=0%
\tikzcountchildvi=0%
}
}
\def\tikz@mmap@store@aux#1#2{%
\immediate\write\@mainaux{\string\expandafter\xdef\noexpand\csname pgfk@/tikz/mmap/\pgfkeysvalueof{/tikz/mmap/name}/#1\string\endcsname{#2}}}%
\def\tikz@mmap@get@from@aux#1#2{%
\ifcsname pgfk@/tikz/mmap/\pgfkeysvalueof{/tikz/mmap/name}/#1\endcsname
\edef#2{\csname pgfk@/tikz/mmap/\pgfkeysvalueof{/tikz/mmap/name}/#1\endcsname}%
\else
\edef#2{0}%
\fi
}
\newcount\tikzcountgrandchild
\def\tikz@grow@garlic{%
\pgfmathsetmacro{\pgfutil@tempa}{\pgfkeysvalueof{/tikz/mmap/overall rotation}}%
\ifcase\tikztreelevel
\or
\global\advance\tikzcountchildi by1\relax%
\tikz@mmap@get@from@aux{n-i}{\myni}%
\tikz@mmap@get@from@aux{n-ii}{\mynii}%
\tikz@mmap@get@from@aux{n-1-\the\tikzcountchildi}{\mynall}%
\tikz@mmap@get@from@aux{p-1-\the\tikzcountchildi}{\mypi}%
\ifnum\mynii>0
\pgfmathsetmacro{\pgfutil@tempa}{\pgfutil@tempa+\pgfkeysvalueof{/tikz/mmap/sign}%
*(\pgfkeysvalueof{/tikz/mmap/child weight}*(\mypi)*360/\mynii+%
(1-\pgfkeysvalueof{/tikz/mmap/child weight})*(\tikzcountchildi-1)*360/\myni)}%
\fi
\or
\global\advance\tikzcountchildii by1\relax%
\ifnum\tikznumberofcurrentchild=1\relax
\tikz@mmap@store@aux{n-1-\the\tikzcountchildi}{\the\tikznumberofchildren}%
\tikz@mmap@store@aux{p-1-\the\tikzcountchildi}{\the\numexpr\tikzcountchildii-1}%
\fi
\tikz@mmap@get@from@aux{n-ii}{\mynii}%
\tikz@mmap@get@from@aux{n-1-1}{\mynall}%
\ifnum\mynii>0
\pgfmathsetmacro{\pgfutil@tempa}{\pgfutil@tempa+\pgfkeysvalueof{/tikz/mmap/sign}%
*(\tikzcountchildii-1-\mynall/2)*360/\mynii}%
\fi
\or
\global\advance\tikzcountchildiii by1\relax%
\ifnum\tikznumberofcurrentchild=1\relax
\tikz@mmap@store@aux{n-1-\the\tikzcountchildi-\the\tikzcountchildii}{\the\tikznumberofchildren}%
\tikz@mmap@store@aux{p-1-\the\tikzcountchildi-\the\tikzcountchildii}{\the\numexpr\tikzcountchildiii-1}%
\fi
\tikz@mmap@get@from@aux{n-iii}{\myniii}%
\ifnum\myniii>0
\pgfmathsetmacro{\pgfutil@tempa}{\pgfutil@tempa+\pgfkeysvalueof{/tikz/mmap/sign}%
*(\tikzcountchildiii-1)*360/\myniii}%
\fi
\or
\global\advance\tikzcountchildiv by1\relax%
\tikz@mmap@get@from@aux{n-iv}{\myniv}%
\ifnum\myniv>0
\pgfmathsetmacro{\pgfutil@tempa}{\pgfutil@tempa+\pgfkeysvalueof{/tikz/mmap/sign}*(\tikzcountchildiv-1)*360/\myniv}%
\fi
\or
\tikz@mmap@get@from@aux{n-v}{\mynv}%
\pgfmathsetmacro{\pgfutil@tempa}{\pgfutil@tempa+\pgfkeysvalueof{/tikz/mmap/sign}*(\tikzcountchildv-1)*360/\mynv}%
\ifnum\mynv>0
\global\advance\tikzcountchildv by1\relax%
\fi
\or
\global\advance\tikzcountchildvi by1\relax%
\tikz@mmap@get@from@aux{n-vi}{\mynvi}%
\ifnum\myvi>0
\pgfmathsetmacro{\pgfutil@tempa}{\pgfutil@tempa+(\tikzcountchildvi-1)*360/\mynvi}%
\fi
\fi
\pgftransformreset%
\pgftransformshift{\pgfpoint{\pgfkeysvalueof{/tikz/mmap/overall xshift}}%
{\pgfkeysvalueof{/tikz/mmap/overall yshift}}}%
\pgftransformrotate{\pgfutil@tempa}%
\pgftransformxshift{\the\tikzleveldistance}%
}
\makeatother
\begin{document}
\tikzset{mmap/.cd,
name/.initial=undef,
overall rotation/.initial=0,
overall xshift/.initial=0pt,
overall yshift/.initial=0pt,
sign/.initial=1,
child weight/.initial=0.5,
/tikz/.cd,
Xshift/.style={xshift=#1,mmap/overall xshift=#1},
Yshift/.style={yshift=#1,mmap/overall yshift=#1},
branch color/.style={
concept color=#1!60,
every child/.append style={concept color=#1!30},
}
}
\begin{tikzpicture}
\begin{scope}[
mindmap,garlic growth=A,mmap/child weight=0,
mmap/overall rotation=-45,mmap/sign=1,
nodes={concept,align=center, text width=2.5cm,inner sep=1mm},
concept color=orange!60,
level 1/.style={nodes={concept},
every child/.append style={concept color=orange},
level distance=5cm,
},
level 2/.style={%opacity=0,
every child/.append style={concept color=blue},
nodes={concept},
level distance=10cm,
minimum size=2.0cm
},
level 3/.style={%opacity=0,
every child/.append style={concept color=green!70!black},
level distance=5cm,sibling angle=40,
minimum size=2.0cm,
},
level 4/.style={opacity=0,
level distance=14cm,
minimum size=2.0cm,text width=2.0cm
}
]
\node [root concept]{Dimension finie}
child{node {EV de DF}% [clockwise from=0]
child {node {L.\ Steinitz}
[clockwise from=0]
child {node {T.\ Base interm\'ediaire}
child {node {T.\ Base incompl\`ete}}
}
child {node {P.\ Dim infinie}}
}
child {node {T.\ Dim de f.\ libres, g\'en\'eratrices, bonux 1}
[clockwise from=-20]child{node{T.\ Bonux 2}}
}
child {node {P.\ Dim d'un produit}}
child {node {P.\ Grassmann}
[clockwise from=10]
child{node {P.\ Non g\'en\'eralisation de Grassmann}}
child{node {P.\ Dim de sommes directes}
child{node {P.\ Suppl\'ementaires}}
child{node {T.\ Bonux 3 des suppl\'e.}}
}
child{node {D.\ Le rang}
child{node {P.\ sur le rang}}
child{node {P.\ Rang, lib, g\'en, base}}
}
}
}
child{node {ALM}
child{ node (equity) {Equity}
[clockwise from=40]
child { node {Indices}}
child { node {Stocks}}
child { node {ETFs}}
}
child{ node (commo) {Commodities}
[clockwise from=70]
child { node {Soft commo}}
child { node {Precious}}
child { node {Oil/Gas}}
}
child {node {Assurances}}
child {node {Caisse de retraite}}
}
child{node {Directions financieres}
child {node {Corporate}}
}
child{node {Instrument specialists}
child {node {Asset Managers traditionnels}}
child {node {Hedge funds}}
child {node {Trading desks form other banks}}
}
;
\end{scope}
\end{tikzpicture}
\end{document}
这里引入了一个新参数,child weight
。在上面的例子中,它实际上设置为 0.5。它决定了子节点的数量对分配给 1 级节点的角度空间的影响程度。如果它是 1,则影响最大,在这个例子中它是 0。
所以总体来说,有些事情有效,有些则无效,至少不是完全自动的。但是,我认为不能指望答案能完全解决问题。这个网站上的答案可以做的是贡献一些渐进式的进展。如果有人提供了一个具体的想法(比如说一个特定的算法),我们可以在此基础上进行构建,那么进步就更大。可以探索上述许多可能的修改。一个特别有希望的方法可能是将思维导图故事与图形绘制算法结合起来(快速搜索没有得到结果,但我当然可能错过了它们),但这将留到以后的问题和答案中。