如题,对于如下的MWE:
\documentclass{standalone}
\usepackage{ctex}
\usepackage[edges]{forest}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{forest}
for tree={
grow'=east,
anchor=west,
inner sep=0pt,
outer sep=0pt,
fit=band,
align=left,
if n=1{edge path'={(!ul.south west)-- (!u1.north west)}}{no edge},
edge={decorate, decoration={brace,amplitude=1.5mm,raise=2mm}}
}
[1 一级标题
[1.1 二级标题
[1.1.1 三级标题
[1.1.1.1 四级标题]
[1.1.1.2 四级标题]
]
[1.1.2 三级标题
[1.1.2.1 四级标题]
[1.1.2.2 四级标题]
]
]
[1.2 二级标题
[1.2.1 三级标题
[1.2.1.1 四级标题]
[1.2.1.2 四级标题]
]
[1.2.2 三级标题
[1.2.2.1 四级标题]
[\parbox{8em}{文字文字文字文字文字文字文字文字文字文字文字文字}]
]
]
]
\end{forest}
\end{document}
希望「{」的父节点总是位于其所有子节点的几何中心。
可以试试这个...手动计算一下...不过是不是「最佳实践」呢🤔
\documentclass[border=5pt]{standalone}
\usepackage[fontset=fandol]{ctex}
\usepackage[edges]{forest}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{forest}
for tree={
grow'=east,
anchor=west,
inner sep=0pt,
outer sep=0pt,
fit=band,
align=left,
if n=1{edge path'={(!ul.south west)-- (!u1.north west)}}{no edge},
edge={decorate, decoration={brace,amplitude=1.5mm,raise=2mm}},
},
before drawing tree={
for tree={
if n children=0{}{
y/.pgfmath={(y("!1")+max_y("!1")+y("!l")+min_y("!l"))/2}
}
}
}
[1 一级标题
[1.1 二级标题
[1.1.1 三级标题
[1.1.1.1 四级标题]
[1.1.1.2 四级标题]
[1.1.1.3 四级标题]
]
[1.1.2 三级标题
[1.1.2.1 四级标题]
[1.1.2.2 四级标题]
[1.1.2.3 四级标题[\parbox{5em}{文字文字文字文字文字文字文字文字文字文字文字文字}]]
[1.1.2.4 四级标题]
]
]
[1.2 二级标题
[1.2.1 三级标题
[1.2.1.1 四级标题]
[1.2.1.2 四级标题]
]
[1.2.2 三级标题
[1.2.2.1 四级标题]
[\parbox{8em}{文字文字文字文字文字文字文字文字文字文字文字文字}]
]
]
]
\end{forest}
\end{document}
基于schemata宏包不做任何微调的话:
\documentclass[border=5pt]{standalone}
\usepackage[fontset=fandol]{ctex}
\usepackage{schemata}
\begin{document}
\schema
{
\schemabox{1 一级标题}
}
{
\schema
{
\schemabox{1.1 二级标题}
}
{
\schema
{
\schemabox{1.1.1 三级标题}
}
{
\schemabox{1.1.1.1 四级标题}
\schemabox{1.1.1.2 四级标题}
}
\schema
{
\schemabox{1.1.2 三级标题}
}
{
\schemabox{1.1.2.1 四级标题}
\schemabox{1.1.2.2 四级标题}
}
}
\schema
{
\schemabox{1.2 二级标题}
}
{
\schema
{
\schemabox{1.1.1 三级标题}
}
{
\schemabox{1.1.1.1 四级标题}
\schemabox{1.1.1.2 四级标题}
}
\schema
{
\schemabox{1.1.2 三级标题}
}
{
\schemabox{1.1.2.1 四级标题}\smallskip
\schemabox{\parbox{8em}{\linespread{1.0}\selectfont 文字文字文字文字文字文字文字文字文字文字文字文字}}
}
}
}
\end{document}
修改\Schema[⟨type⟩]{⟨adjust⟩}{⟨size⟩}调整brace的位置:
\documentclass[border=5pt]{standalone}
\usepackage[fontset=fandol]{ctex}
\usepackage{schemata}
\begin{document}
\Schema{-2ex}{8ex}
{
\schemabox{1 一级标题}
}
{
\Schema{0ex}{4.5ex}
{
\schemabox{1.1 二级标题}
}
{
\schema
{
\schemabox{1.1.1 三级标题}
}
{
\schemabox{1.1.1.1 四级标题}
\schemabox{1.1.1.2 四级标题}
}
\schema
{
\schemabox{1.1.2 三级标题}
}
{
\schemabox{1.1.2.1 四级标题}
\schemabox{1.1.2.2 四级标题}
}
}
\Schema{-1.5ex}{5.5ex}
{
\schemabox{1.2 二级标题}
}
{
\schema
{
\schemabox{1.1.1 三级标题}
}
{
\schemabox{1.1.1.1 四级标题}
\schemabox{1.1.1.2 四级标题}
}
\schema
{
\schemabox{1.1.2 三级标题}
}
{
\schemabox{1.1.2.1 四级标题}\smallskip
\schemabox{\parbox{8em}{\linespread{1.1}\selectfont 文字文字文字文字文字文字文字文字文字文字文字文字}}
}
}
}
\end{document}
(OS.其实我感觉这个语法也并不优雅...不如forest...难用,不够自动化...)
大佬,为什么这个大括号尖端没有对齐哇
@u167359 神秘:( 晚点再看看