TransWikia.com

How to put forest in 2 columns page?

TeX - LaTeX Asked on March 2, 2021

I have a 2-column article in which I would like to put a forest in 2 column instead of one, and at the top of page.

Here is the code:

newcommand{CLASSINPUTbottomtextmargin}{25.4mm}
newcommand{CLASSINPUTtoptextmargin}{19.1mm}
newcommand{CLASSINPUToutersidemargin}{15.8mm}
newcommand{CLASSINPUTinnersidemargin}{17mm}
setlength{textfloatsep}{-5pt}
documentclass[letterpaper,conference]{IEEEtran}


usepackage{graphicx}
usepackage{array,multirow,makecell}
usepackage{forest}

makeatletter
newcolumntype{P}[1]{>{centeringarraybackslash}p{#1}}

setcellgapes{1pt}
makegapedcells
newenvironment{multicases}[1]
{let@ifnextcharnew@ifnextchar
leftlbracedefarraystretch{1.2}%
array{@{}l*{#1}{@{quad}l}@{}}}
{endarrayright.kern-nulldelimiterspace}

title{The principal title: hello !}


begin{document}
maketitle
this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.


begin{figure*}[!b]
centering
scalebox{.9}{

    begin{forest}
for tree={rectangle,draw, l sep=20pt}
    [This is the root node, black 
        [This is the first level  
          [This is the second level
            [This is the third level, edge label={node[midway,right] {hi !!}}
            ]
            [This is the third level]
            [This is the third level]
          ]
        ]
        [This is the first level
            [This is the second level]
            [This is the second level
                [This is the second level, edge label={node[midway,left] {hi}}
                    [This is the second level, edge label={node[midway,left] {hello !!}}
                    ]
                ]
                [This is the third level]
                [This is the third level]
             ] 
        ] 
    ]
    end{forest}
            }

caption{My figure}
end{figure*}


end{document}

Thanks for your answers, however the tree is not well placed at the bottom of the page, and there is a part that goes out of the border.

One Answer

  • Unfortunately, you provide only code fragment, so we not know anything about layout of the your document.
  • I would not use scalebox, It will reduce font size to to an illegible size
  • As reasonable solution is redesign tree's node, i.e. enble break nodes' texts to two or more lines. For example:

enter image description here

(red lines indicate text borders)

documentclass[twocolumn]{article}
usepackage{forest}
%---------- Shows page layout. Doesn't use it in a real document!
usepackage{showframe}
renewcommandShowFrameLinethickness{0.15pt}
renewcommand*ShowFrameColor{color{red}}
%---------------------------------------------------------------%

begin{document}
begin{figure*}
centering
    begin{forest}
for tree={
    draw, 
    text width=22mm, text centered, % <--- new
    l sep=9mm,
    s sep=1mm}
    [This is the root node, black
        [This is the first level
          [This is the second level
            [This is the third level, edge label={node[midway,left] {hi !!}}
            ]
            [This is the third level]
            [This is the third level]
          ]
        ]
        [This is the first level
            [This is the second level]
            [This is the second level
                [This is the third level, edge label={node[midway,left] {hi}}
                    [This is the fourth level, edge label={node[midway,left] {hello !!}}
                    ]
                ]
                [This is the third level]
                [This is the third level]
             ]
        ]
    ]
end{forest}
end{figure*}
end{document}

Answered by Zarko on March 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP