TransWikia.com

Aligning graphs with psmatrix

TeX - LaTeX Asked by Dan Cat on May 27, 2021

In the dummy slide below there are two graphs side by side. I would like to align them in such a way that the nodes 7 8 and 9 lie on the same line. Do you have any suggestion about how to achieve this result? Thanks.

documentclass[xcolor=dvipsnames,compress,aspectratio=169]{beamer}
usepackage[T1]{fontenc}
usepackage{bold-extra}
usepackage{subfigure}
usepackage{tcolorbox}
usepackage{pstricks}
usepackage{tikz}
usetikzlibrary{calc, chains, fit, positioning, shapes}
usepackage{pst-node}% http://ctan.org/pkg/pst-node
usepackage{multido}% http://ctan.org/pkg/multido
usepackage{pst-poly}
usetheme[progressbar=frametitle]{metropolis}

makeatletter
newcommand{srcsizefour}{@setfontsize{srcsize}{4pt}{4pt}}


newcommand{mytextsizesmaller}{srcsizefour}
definecolor{platinum}{rgb}{0.9, 0.89, 0.89}
definecolor{myred}{RGB}{255, 73, 93}

begin{document}
begin{frame}{Dummy example}
hfill
    begin{center}
    begin{columns}
    begin{column}{0.45textwidth}
    
    centering
    psmatrix[mnode=Circle,radius=5pt,colsep=0.5cm,rowsep=0.25cm,fillcolor=myred!95,fillstyle=solid,linewidth=0.5pt]
    mytextsizesmaller2 &                                          & mytextsizesmaller3                     & mytextsizesmaller4                      & &mytextsizesmaller5    
                        & [fillcolor=platinum]mytextsizesmaller7  & [fillcolor=platinum]mytextsizesmaller8 & [fillcolor=platinum]mytextsizesmaller9  & [fillcolor=platinum]mytextsizesmaller10       
    mytextsizesmaller1 &                                          &                                         &                                          & &mytextsizesmaller6   
    endpsmatrix     
    ncline[linewidth=0.25pt]{-}{1,1}{2,2} 
    ncline[linewidth=0.25pt]{-}{1,3}{2,3}
    ncline[linewidth=0.25pt]{-}{1,4}{2,4}
    ncline[linewidth=0.25pt]{-}{1,6}{2,5}
    
    ncline[linewidth=0.25pt]{-}{2,2}{2,3} 
    ncline[linewidth=0.25pt]{-}{2,3}{2,4}
    ncline[linewidth=0.25pt]{-}{2,4}{2,5} 
    
    ncline[linewidth=0.25pt]{-}{3,1}{2,2}
    ncline[linewidth=0.25pt]{-}{3,6}{2,5}
    end{column}
    begin{column}{0.45textwidth}
    centering%
    psmatrix[mnode=Circle,radius=5pt,colsep=0.5cm,rowsep=0.25cm,fillcolor=myred!95,fillstyle=solid,linewidth=0.5pt]
                          &     mytextsizesmaller3                  &                                         &  mytextsizesmaller4                                              
    mytextsizesmaller 2  &                                          & [fillcolor=platinum]mytextsizesmaller10&                                          & mytextsizesmaller5    
                          & [fillcolor=platinum]mytextsizesmaller7  & [fillcolor=platinum]mytextsizesmaller8 & [fillcolor=platinum]mytextsizesmaller9            
    mytextsizesmaller 1  &                                          &                                         &                                          & mytextsizesmaller6   
    endpsmatrix     
    ncline[linewidth=0.25pt]{-}{1,2}{2,3} 
    ncline[linewidth=0.25pt]{-}{1,4}{2,3} 
    
    ncline[linewidth=0.25pt]{-}{2,1}{3,2} 
    ncline[linewidth=0.25pt]{-}{4,1}{3,2} 
    
    ncline[linewidth=0.25pt]{-}{2,5}{3,4} 
    ncline[linewidth=0.25pt]{-}{4,5}{3,4} 
    
    ncline[linewidth=0.25pt]{-}{3,2}{3,3} 
    ncline[linewidth=0.25pt]{-}{3,3}{3,4} 
    ncline[linewidth=0.25pt]{-}{3,3}{2,3} 
    end{column}
    vspace{0pt}
    end{columns}
    end{center}
    hfill

end{frame}
end{document}

One Answer

The images can be aligned by putting a simple vspace in one of the two. For example as follows.

hfill
begin{center}
begin{columns}
begin{column}{0.45textwidth}
centering
vspace{0.25cm}
psmatrix[mnode=Circle,radius=5pt,colsep=0.5cm,rowsep=0.25cm,fillcolor=myred!95,fillstyle=solid,linewidth=0.5pt]
mytextsizesmaller2 &                                          & mytextsizesmaller3                     & mytextsizesmaller4                      & &mytextsizesmaller5    
                    & [fillcolor=platinum]mytextsizesmaller  & [fillcolor=platinum]mytextsizesmaller & [fillcolor=platinum]mytextsizesmaller  & [fillcolor=platinum]mytextsizesmaller       
mytextsizesmaller1 &                                          &                                         &                                          & &mytextsizesmaller6   
endpsmatrix     
ncline[linewidth=0.25pt]{-}{1,1}{2,2} 
ncline[linewidth=0.25pt]{-}{1,3}{2,3}
ncline[linewidth=0.25pt]{-}{1,4}{2,4}
ncline[linewidth=0.25pt]{-}{1,6}{2,5}

ncline[linewidth=0.25pt]{-}{2,2}{2,3} 
ncline[linewidth=0.25pt]{-}{2,3}{2,4}
ncline[linewidth=0.25pt]{-}{2,4}{2,5} 

ncline[linewidth=0.25pt]{-}{3,1}{2,2}
ncline[linewidth=0.25pt]{-}{3,6}{2,5}
end{column}
begin{column}{0.45textwidth}
centering%
psmatrix[mnode=Circle,radius=5pt,colsep=0.5cm,rowsep=0.25cm,fillcolor=myred!95,fillstyle=solid,linewidth=0.5pt]
                      &     mytextsizesmaller3                  &                                         &  mytextsizesmaller4                                              
mytextsizesmaller 2  &                                          & [fillcolor=platinum]mytextsizesmaller&                                          & mytextsizesmaller5    
                      & [fillcolor=platinum]mytextsizesmaller  & [fillcolor=platinum]mytextsizesmaller & [fillcolor=platinum]mytextsizesmaller            
mytextsizesmaller 1  &                                          &                                         &                                          & mytextsizesmaller6   
endpsmatrix     
ncline[linewidth=0.25pt]{-}{1,2}{2,3} 
ncline[linewidth=0.25pt]{-}{1,4}{2,3} 

ncline[linewidth=0.25pt]{-}{2,1}{3,2} 
ncline[linewidth=0.25pt]{-}{4,1}{3,2} 

ncline[linewidth=0.25pt]{-}{2,5}{3,4} 
ncline[linewidth=0.25pt]{-}{4,5}{3,4} 

ncline[linewidth=0.25pt]{-}{3,2}{3,3} 
ncline[linewidth=0.25pt]{-}{3,3}{3,4} 
ncline[linewidth=0.25pt]{-}{3,3}{2,3} 
end{column}
vspace{0pt}
end{columns}
end{center}

Perhaps there are more elegant solutions, but this worked anyway.

Correct answer by Dan Cat on May 27, 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