# how to fit this tree within the default margins?

i have the following code and wish it to fit the default margins without making he page vertical, is it possible to do this?

\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{forest}
\usepackage{pdflscape}
\begin{document}
\begin{landscape}
\textit{Generator $(12)$}
$\hspace*{-10em}\vcenter{\hbox{ \begin{forest} for tree={grow'=east,l sep=5em,s sep=2em,circle,inner sep=2pt,fill} [,label=left:{(132)} [,label=above:{(12)},edge label={node[midway,sloped,above]{(23)}} [,label=right:(132),edge label={node[midway,sloped,above]{(23)}}] [,label=right:(23),edge label={node[midway,sloped,below]{(132)}}] ] [,label=below:{(123)},edge label={node[midway,sloped,below]{(132)}} [,label=right:(13),edge label={node[midway,sloped,above]{(23)}}] [,label=right:(),edge label={node[midway,sloped,below]{(132)}}] ] ] \end{forest}}} \rightarrow\hspace*{-10em} \vcenter{\hbox{\begin{forest} for tree={grow'=east,l sep=7em,s sep=4em,circle,inner sep=2pt,fill} [,label=left:{\begin{bmatrix} 0 & 0 & 1 \\ 1 & 0 & 0 \\ 0 & 1 & 0 \end{bmatrix}} [,label=above:{\begin{bmatrix} 0 & 1 & 0 \\ 1 & 0 & 0 \\ 0 & 0 & 1 \end{bmatrix}},edge label={node[midway,sloped,above]{(23)}} [,label=right:\begin{bmatrix} 0 & 0 & 1 \\ 1 & 0 & 0 \\ 0 & 1 & 0 \end{bmatrix},edge label={node[midway,sloped,above]{(23)}}] [,label=right:\begin{bmatrix} 1 & 0 & 0 \\ 0 & 0 & 1 \\ 0 & 1 & 0 \end{bmatrix},edge label={node[midway,sloped,below]{(132)}}] ] [,label=below:{\begin{bmatrix} 0 & 1 & 0 \\ 0 & 0 & 1 \\ 1 & 0 & 0 \end{bmatrix}},edge label={node[midway,sloped,below]{(132)}} [,label=right:\begin{bmatrix} 0 & 0 & 1 \\ 0 & 1 & 0 \\ 1 & 0 & 0 \end{bmatrix},edge label={node[midway,sloped,above]{(23)}}] [,label=right:\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix},edge label={node[midway,sloped,below]{(132)}}] ] ] \end{forest}}}$
\end{landscape}
\end{document}


Instead of using pdflscape, you can use rotating package, MWE is:

\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{forest}
\usepackage[figuresright]{rotating}
\usepackage{showframe}
\begin{document}
\begin{sidewaysfigure}
\textit{Generator $(12)$}
$\hspace*{-10em}\vcenter{\hbox{ \begin{forest} for tree={grow'=east,l sep=5em,s sep=2em,circle,inner sep=2pt,fill} [,label=left:{(132)} [,label=above:{(12)},edge label={node[midway,sloped,above]{(23)}} [,label=right:(132),edge label={node[midway,sloped,above]{(23)}}] [,label=right:(23),edge label={node[midway,sloped,below]{(132)}}] ] [,label=below:{(123)},edge label={node[midway,sloped,below]{(132)}} [,label=right:(13),edge label={node[midway,sloped,above]{(23)}}] [,label=right:(),edge label={node[midway,sloped,below]{(132)}}] ] ] \end{forest}}} \rightarrow\hspace*{-10em} \vcenter{\hbox{\begin{forest} for tree={grow'=east,l sep=7em,s sep=4em,circle,inner sep=2pt,fill} [,label=left:{\begin{bmatrix} 0 & 0 & 1 \\ 1 & 0 & 0 \\ 0 & 1 & 0 \end{bmatrix}} [,label=above:{\begin{bmatrix} 0 & 1 & 0 \\ 1 & 0 & 0 \\ 0 & 0 & 1 \end{bmatrix}},edge label={node[midway,sloped,above]{(23)}} [,label=right:\begin{bmatrix} 0 & 0 & 1 \\ 1 & 0 & 0 \\ 0 & 1 & 0 \end{bmatrix},edge label={node[midway,sloped,above]{(23)}}] [,label=right:\begin{bmatrix} 1 & 0 & 0 \\ 0 & 0 & 1 \\ 0 & 1 & 0 \end{bmatrix},edge label={node[midway,sloped,below]{(132)}}] ] [,label=below:{\begin{bmatrix} 0 & 1 & 0 \\ 0 & 0 & 1 \\ 1 & 0 & 0 \end{bmatrix}},edge label={node[midway,sloped,below]{(132)}} [,label=right:\begin{bmatrix} 0 & 0 & 1 \\ 0 & 1 & 0 \\ 1 & 0 & 0 \end{bmatrix},edge label={node[midway,sloped,above]{(23)}}] [,label=right:\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix},edge label={node[midway,sloped,below]{(132)}}] ] ] \end{forest}}}$
\end{sidewaysfigure}
\end{document}

• i made a mistake aaah, let me amend the code, and hopegully you can amend the answer :)
– Math
Oct 16 '19 at 11:56
• Amended the question. this is how I want it, but this page is landscape. I wish to make this vertical keeping the default margins, while, if needed, to 'shrink' the tree to give a clean output
– Math
Oct 16 '19 at 12:01

Disclaimer: I do not know why the trees have that large bounding box, i.e. why the negative \hspaces are needed. Other than that I would just slightly rearrange them.

\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{forest}
\begin{document}
\textit{Generator $(12)$}
$\bgroup\tikzset{label distance=-3.14pt}\hspace*{-10em}\vcenter{\hbox{ \begin{forest} for tree={grow'=east,l sep=2em,s sep=4em,circle,inner sep=2pt,fill} [,label=left:{(132)} [,label=above left:{(12)},edge label={node[midway,sloped,above]{(23)}} [,label=right:(132),edge label={node[midway,sloped,above]{(23)}}] [,label=right:(23),edge label={node[midway,sloped,below]{(132)}}] ] [,label=below left:{(123)},edge label={node[midway,sloped,below]{(132)}} [,label=right:(13),edge label={node[midway,sloped,above]{(23)}}] [,label=right:(),edge label={node[midway,sloped,below]{(132)}}] ] ] \end{forest}}} \rightarrow\hspace*{-10em} \vcenter{\hbox{\begin{forest} for tree={grow'=east,l sep=3em,s sep=8em,circle,inner sep=2pt,fill} [,label=left:{\begin{bmatrix} 0 & 0 & 1 \\ 1 & 0 & 0 \\ 0 & 1 & 0 \end{bmatrix}} [,label=above left:{\begin{bmatrix} 0 & 1 & 0 \\ 1 & 0 & 0 \\ 0 & 0 & 1 \end{bmatrix}},edge label={node[midway,sloped,above]{(23)}} [,label=right:\begin{bmatrix} 0 & 0 & 1 \\ 1 & 0 & 0 \\ 0 & 1 & 0 \end{bmatrix},edge label={node[midway,sloped,above]{(23)}}] [,label=right:\begin{bmatrix} 1 & 0 & 0 \\ 0 & 0 & 1 \\ 0 & 1 & 0 \end{bmatrix},edge label={node[midway,sloped,below]{(132)}}] ] [,label=below left:{\begin{bmatrix} 0 & 1 & 0 \\ 0 & 0 & 1 \\ 1 & 0 & 0 \end{bmatrix}},edge label={node[midway,sloped,below]{(132)}} [,label=right:\begin{bmatrix} 0 & 0 & 1 \\ 0 & 1 & 0 \\ 1 & 0 & 0 \end{bmatrix},edge label={node[midway,sloped,above]{(23)}}] [,label=right:\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix},edge label={node[midway,sloped,below]{(132)}}] ] ] \end{forest}}}\egroup$
\end{document}


BTW, I am way more sympathetic with these permutation matrices. Whether or not it is necessary to spell all of them out in such great detail rather than just keeping the cycle notation is something that is to be decided by others.

• I am modelling something using particular groups hence need these matrix descriptions
– Math
Oct 16 '19 at 12:11
• isn't there a way to shrink the entire tree whilst maintaining the shape?
– Math
Oct 16 '19 at 12:14
• something like this: tex.stackexchange.com/questions/482599/…
– Math
Oct 16 '19 at 12:18
• @Math Yes, there is. You should then go with MadyYuvi's solution once they go back to adjustbox. I personally am very much opposed to shrinking the text just in order to squeeze something on a page. (I am not saying my solution is "better" but just that I am not going to spell this out, the more so since MadyYuvi had adjustbox first.)
– user194703
Oct 16 '19 at 12:28
• i tried her solution and its not what i want. for example, in this post tex.stackexchange.com/questions/482599/…, the OP wanted to shrink the figure to fit into the default margins whilst maintaining vertical format, that's what i want
– Math
Oct 16 '19 at 12:42