I'm trying to accomplish drawing a tree for a tic-tac-toe game. The output of the tree will be rather large, and I would like the page to auto scale the size of the tree as it grows with appropriate spacing. Is that possible?
\documentclass{article}
\usepackage{qtree}
\usepackage{tikz}
\newcounter{num}
\newcommand{\tictactoe}[1]
{
\begin{tikzpicture}[line width=2pt]
\def\r{3mm}
\tikzset{
circ/.pic={\draw circle (\r);},
cross/.pic={\draw (-\r,-\r) -- (\r,\r) (-\r,\r) -- (\r,-\r);},
opt/.pic={\draw[opacity=0.2] (-\r,-\r) -- (\r,\r) (-\r,\r) -- (\r,-\r);}
}
% The grid
\foreach \i in {1,2} \draw (\i,0) -- (\i,3) (0,\i) -- (3,\i);
% Numbering the cells
\setcounter{num}{0}
\foreach \y in {0,...,2}
\foreach \x in {0,...,2}
{
\coordinate (\thenum) at (\x+0.5,2-\y+0.5);
%\node[opacity=0.5] at (\thenum) {\sffamily\thenum}; % Uncomment to see numbers in the cells
\addtocounter{num}{1}
}
\def\X{X} \def\x{x} \def\O{O} \def\n{n}
\foreach \l [count = \i from 0] in {#1}
{
\if\l\X \path (\i) pic{cross};
\else
\if\l\O \path (\i) pic{circ};
\else
\if\l\x \path (\i) pic{opt};
\else
\if\l\n \node[opacity=0.5] at (\i) {\sffamily\i};
\fi
\fi
\fi
\fi
}
\end{tikzpicture}
}
\begin{document}
\Tree [.\tictactoe{X,0,0,
0,0,0,
0,0,0} [.\tictactoe{X,0,0,
O,0,0,
0,0,0} {\tictactoe{X,0,0,O,0,0,X,0,0}} \tictactoe{X,0,0,O,0,0,0,X,0} \tictactoe{X,0,0,O,0,0,0,0,X} \tictactoe{X,0,0,O,X,0,0,0,0} ]
[.\tictactoe{X,0,0,
0,0,0,
0,O,0}
]
[.\tictactoe{X,0,0,
0,O,0,
0,0,0}
]
[.\tictactoe{X,0,0,
0,0,0,
O,0,0}
]
[.\tictactoe{X,0,0,
0,0,0,
0,0,O}
]
]
\end{document}
the tikz for the tic-tac-toe board is from here: https://tex.stackexchange.com/a/634705/251522




geometryis intended for defining of pages layout. It has nothing with scaling (any kind). In my solution us by it enlarge text area on page. This indicates red lines in showed image of tree- – Zarko Jul 02 '22 at 21:56