
다음은 일반 텍스트의 한 행, tikz 노드의 다른 행, 포리스트 셀의 또 다른 행으로 테이블을 생성하는 MWE입니다. 테이블 환경에 [t] 옵션을 사용하여 셀을 위쪽으로 정렬하고 열 지정자 c를 사용하여 셀을 수직으로 가운데 정렬하려고 합니다.
\documentclass{standalone}
\usepackage{forest}
\begin{document}
\forestset{c/.style={circle,draw},t/.style={},}
\def\bb{ \draw[fill=blue,opacity=0.2] (current bounding box.south west) rectangle (current bounding box.north east);}
\def\xx#1#2{
#1
\begin{tikzpicture}
\node [fill=green,opacity=0.2,draw,minimum width=#1cm, minimum height=#2cm] {#1#2};
\end{tikzpicture}
#2
}
\begin{tabular}[t]{|c|c|c|c|c|c|}
$(ab.cd)$ &
$(abcd.\bot)$ &
$(ab.(c.d))$ &
$((a.b).(c.d))$ &
$(a.(b.(c.d)))$ &
$(((a.b).c).d)$ \\
\hline
\xx23 &
\xx34 &
\xx24 &
\xx14 &
\xx41 &
\xx43 \\
\hline
\scriptsize
\Forest{for tree [{},c[$ab$,t][$cd$,t]]\bb} &
\scriptsize
\Forest{for tree [{},c[$abcd$,t][$\bot$,t]]\bb} &
\scriptsize
\Forest{for tree [{},c[$ab$,t][{},c[$c$,t][$d$,t]]]\bb} &
\scriptsize
\Forest{for tree [{},c[{},c[$a$,t][$b$,t]][{},c[$c$,t][$d$,t]]]\bb} &
\scriptsize
\Forest{for tree [{},c [{},c [{},c[a,t][b,t]] [c,t]] [d,t] ] \bb} &
\scriptsize
\Forest{for tree [{},c [{}, c [{}, c
[a,t][b,t]] [c,t] ] [d,t]] \bb}
\end{tabular}
\end{document}
그러나 출력은 이것이 작동하지 않음을 보여줍니다
답변1
두 가지 문제가 있습니다.
- 무엇보다도 pgf에는 가짜 공백을 삽입하는 버그가 있습니다. 버그의 임시 수정이 제공되었습니다.여기. pgf의 향후 버전에서는 이 버그가 수정될 예정입니다.
- 둘째,
[t]
in은\begin{tabular}[t]{...}
테이블의 셀을 위쪽으로 정렬하지 않습니다. 및를T
사용하여 이를 수행하는 열 유형을 추가했습니다 .collcell
adjustbox
암호:
\documentclass{standalone}
\usepackage{forest}
\usepackage{adjustbox}
\usepackage{collcell}
\makeatletter
% remove the stray space https://tex.stackexchange.com/a/513549
\patchcmd{\pgfutilsolvetwotwoleqfloat}
{ \noexpand\pgfmathfloatdivide@}
{\noexpand\pgfmathfloatdivide@}
{}{}
\makeatother
\newcommand{\TopAlign}[1]{\adjustbox{valign=t}{#1}}
\newcolumntype{T}{>{\collectcell{\TopAlign}}c<{\endcollectcell}}
\begin{document}
\forestset{c/.style={circle,draw},t/.style={},}
\def\bb{ \draw[fill=blue,opacity=0.2] (current bounding box.south west) rectangle (current bounding box.north east);}
\def\xx#1#2{
#1
\begin{tikzpicture}
\node [fill=green,opacity=0.2,draw,minimum width=#1cm, minimum height=#2cm] {#1#2};
\end{tikzpicture}
#2
}
\begin{tabular}{*{6}{|T}|}
$(ab.cd)$ &
$(abcd.\bot)$ &
$(ab.(c.d))$ &
$((a.b).(c.d))$ &
$(a.(b.(c.d)))$ &
$(((a.b).c).d)$ \\
\hline
\xx23 &
\xx34 &
\xx24 &
\xx14 &
\xx41 &
\xx43 \\
\hline
\scriptsize
\Forest{for tree [{},c[$ab$,t][$cd$,t]]\bb} &
\scriptsize
\Forest{for tree [{},c[$abcd$,t][$\bot$,t]]\bb} &
\scriptsize
\Forest{for tree [{},c[$ab$,t][{},c[$c$,t][$d$,t]]]\bb} &
\scriptsize
\Forest{for tree [{},c[{},c[$a$,t][$b$,t]][{},c[$c$,t][$d$,t]]]\bb} &
\scriptsize
\Forest{for tree [{},c [{},c [{},c[a,t][b,t]] [c,t]] [d,t] ] \bb} &
\scriptsize
\Forest{for tree [{},c [{}, c [{}, c
[a,t][b,t]] [c,t] ] [d,t]] \bb}
\end{tabular}
\end{document}