Я хочу расставить деревья 2 x 2. Но вместо этого получаю это:
Что я делаю не так? Я не нахожу свою ошибку.
\documentclass[a4paper,11pt]{article}
\usepackage{tikz}
\usepackage{subfigure}
\usepackage{array}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\usepackage{forest}
\begin{document}
\begin{figure}[htbp]
\begin{tabular}{C{.48\textwidth}C{.48\textwidth}}
\subfigure [Subfigure 1] {
\resizebox{0.4\textwidth}{!}{%
\begin{forest}
for tree={delay={where content={}{content={\phantom{00}}}{}},s sep+=5mm,l+=5mm}
[,circle,fill=black,inner sep=1mm
[,circle,fill=red,inner sep=0.5mm
[,circle,draw,red,inner sep=0.25mm,edge={red}
[,circle,draw,red,inner sep=0.25mm,edge={red}]
]
[,circle,draw,red,inner sep=0.5mm
[,circle,draw,red,inner sep=0.25mm,edge={red}]
]
]
[,circle,fill=blue,inner sep=0.5mm
[,circle,draw,blue,inner sep=0.25mm,edge={blue}
]
]
[,circle,fill=green,inner sep=0.5mm]
[,circle,fill=orange,inner sep=0.5mm
]
]
\end{forest}
}}&
\subfigure [Subfigure 2] {
\resizebox{0.4\textwidth}{!}{%
\begin{forest}
for tree={delay={where content={}{content={\phantom{00}}}{}},s sep+=5mm,l+=5mm}
[,circle,fill=black,inner sep=1mm
[,circle,fill=red,inner sep=0.5mm
[,circle,draw,red,inner sep=0.25mm,edge={red}]
[,circle,draw,red,inner sep=0.5mm
]
]
[,circle,fill=blue,inner sep=0.5mm
[,circle,draw,blue,inner sep=0.25mm,edge={blue}
[,circle,draw,blue,inner sep=0.25mm,edge={blue}]
]
[,circle,draw,blue,inner sep=0.25mm,edge={blue}
]
]
[,circle,fill=green,inner sep=0.5mm
]
[,circle,fill=orange,inner sep=0.5mm
]
]
\end{forest}
}}\
\subfigure [Subfigure 3]{
\resizebox{0.4\textwidth}{!}{%
\begin{forest}
for tree={delay={where content={}{content={\phantom{00}}}{}},s sep+=5mm,l+=5mm}
[,circle,fill=black,inner sep=1mm
[,circle,fill=red,inner sep=0.5mm]
[,circle,fill=blue,inner sep=0.5mm]
[,circle,fill=green,inner sep=0.5mm
[,circle,draw,green,inner sep=0.25mm,edge={green}]
]
[,circle,fill=orange,inner sep=0.5mm
[,circle,draw,orange,inner sep=0.25mm,edge={orange}]
[,circle,draw,orange,inner sep=0.25mm,edge={orange}
[,circle,draw,orange,inner sep=0.25mm,edge={orange}]
]
]
]
\end{forest}
}}
\subfigure [Subfigure 4] {
\resizebox{0.4\textwidth}{!}{%
\begin{forest}
for tree={delay={where content={}{content={\phantom{00}}}{}},s sep+=5mm,l+=5mm}
[,circle,fill=black,inner sep=1mm
[,circle,fill=red,inner sep=0.5mm]
[,circle,fill=blue,inner sep=0.5mm]
[,circle,fill=green,inner sep=0.5mm
[,circle,draw,green,inner sep=0.25mm,edge={green}]
[,circle,draw,green,inner sep=0.25mm,edge={green}]
]
[,circle,fill=orange,inner sep=0.5mm
[,circle,draw,orange,inner sep=0.25mm,edge={orange}]
[,circle,draw,orange,inner sep=0.25mm,edge={orange}]
[,circle,draw,orange,inner sep=0.25mm,edge={orange}
[,circle,draw,orange,inner sep=0.25mm,edge={orange}
[,circle,draw,orange,inner sep=0.25mm,edge={orange}]
]
]
]
]
\end{forest}
}}
\end{tabular}
\end{figure}
\end{document}
решение1
В вашем коде отсутствует двойная обратная косая черта \\
и вторая &
. (См. отмеченные позиции в коде ниже.)
\documentclass[a4paper,11pt]{article}
\usepackage{tikz}
\usepackage{subfigure}
\usepackage{array}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\usepackage{forest}
\begin{document}
\begin{figure}[htbp]
\begin{tabular}{C{.48\textwidth}C{.48\textwidth}}
\subfigure [Subfigure 1] {
\resizebox{0.4\textwidth}{!}{%
\begin{forest}
for tree={delay={where content={}{content={\phantom{00}}}{}},s sep+=5mm,l+=5mm}
[,circle,fill=black,inner sep=1mm
[,circle,fill=red,inner sep=0.5mm
[,circle,draw,red,inner sep=0.25mm,edge={red}
[,circle,draw,red,inner sep=0.25mm,edge={red}]
]
[,circle,draw,red,inner sep=0.5mm
[,circle,draw,red,inner sep=0.25mm,edge={red}]
]
]
[,circle,fill=blue,inner sep=0.5mm
[,circle,draw,blue,inner sep=0.25mm,edge={blue}
]
]
[,circle,fill=green,inner sep=0.5mm]
[,circle,fill=orange,inner sep=0.5mm
]
]
\end{forest}
}}&
\subfigure [Subfigure 2] {
\resizebox{0.4\textwidth}{!}{%
\begin{forest}
for tree={delay={where content={}{content={\phantom{00}}}{}},s sep+=5mm,l+=5mm}
[,circle,fill=black,inner sep=1mm
[,circle,fill=red,inner sep=0.5mm
[,circle,draw,red,inner sep=0.25mm,edge={red}]
[,circle,draw,red,inner sep=0.5mm
]
]
[,circle,fill=blue,inner sep=0.5mm
[,circle,draw,blue,inner sep=0.25mm,edge={blue}
[,circle,draw,blue,inner sep=0.25mm,edge={blue}]
]
[,circle,draw,blue,inner sep=0.25mm,edge={blue}
]
]
[,circle,fill=green,inner sep=0.5mm
]
[,circle,fill=orange,inner sep=0.5mm
]
]
\end{forest}
}}\\ % <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HERE HERE HERE
\subfigure [Subfigure 3]{
\resizebox{0.4\textwidth}{!}{%
\begin{forest}
for tree={delay={where content={}{content={\phantom{00}}}{}},s sep+=5mm,l+=5mm}
[,circle,fill=black,inner sep=1mm
[,circle,fill=red,inner sep=0.5mm]
[,circle,fill=blue,inner sep=0.5mm]
[,circle,fill=green,inner sep=0.5mm
[,circle,draw,green,inner sep=0.25mm,edge={green}]
]
[,circle,fill=orange,inner sep=0.5mm
[,circle,draw,orange,inner sep=0.25mm,edge={orange}]
[,circle,draw,orange,inner sep=0.25mm,edge={orange}
[,circle,draw,orange,inner sep=0.25mm,edge={orange}]
]
]
]
\end{forest}
}}& % <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HERE HERE HERE
\subfigure [Subfigure 4] {
\resizebox{0.4\textwidth}{!}{%
\begin{forest}
for tree={delay={where content={}{content={\phantom{00}}}{}},s sep+=5mm,l+=5mm}
[,circle,fill=black,inner sep=1mm
[,circle,fill=red,inner sep=0.5mm]
[,circle,fill=blue,inner sep=0.5mm]
[,circle,fill=green,inner sep=0.5mm
[,circle,draw,green,inner sep=0.25mm,edge={green}]
[,circle,draw,green,inner sep=0.25mm,edge={green}]
]
[,circle,fill=orange,inner sep=0.5mm
[,circle,draw,orange,inner sep=0.25mm,edge={orange}]
[,circle,draw,orange,inner sep=0.25mm,edge={orange}]
[,circle,draw,orange,inner sep=0.25mm,edge={orange}
[,circle,draw,orange,inner sep=0.25mm,edge={orange}
[,circle,draw,orange,inner sep=0.25mm,edge={orange}]
]
]
]
]
\end{forest}
}}
\end{tabular}
\end{figure}
\end{document}