Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'd like to nest several psmatrix environments within a psmatrix, so that every cell of the outer psmatrix itself is an psmatrix again. Ultimately I want to draw within these inner matrices using pspicture. All that in a beamer document in case this is relevant. Unfortunately when nesting the psmatrices, so unwanted space is added in a way, that the outer psmatrix is not longer properly centered with respect to the page.

\documentclass{beamer}
\usepackage[utf8x]{inputenc}
\usepackage{pstricks}
\usepackage{pst-node}
\newcommand\mycirc{\pspicture(.5,.5)\pscircle(.25,.25){.25}\endpspicture}
\newcommand\myframe{\pspicture(.5,.5)\psframe(.5,.5)\endpspicture}
\begin{document}
\begin{frame}{Properly centered}
\begin{center}
 \begin{psmatrix}
  A & B \\
  C & D
 \end{psmatrix}
 \end{center}
\end{frame}
\begin{frame}{Not centered}
\begin{center}
 \begin{psmatrix}[rowsep=2,colsep=2]
  \begin{psmatrix}[rowsep=0.5,colsep=0.5]A1&A2\\A3&A4\end{psmatrix}&
  \begin{psmatrix}[rowsep=0.5,colsep=0.5]B1&B2\\B3&B4\end{psmatrix}\\
  \begin{psmatrix}[rowsep=0.5,colsep=0.5]C1&C2\\C3&C4\end{psmatrix}&
  \begin{psmatrix}[rowsep=0.5,colsep=0.5]D1&D2\\D3&D4\end{psmatrix}
  \end{psmatrix}
 \end{center}
\end{frame}
\begin{frame}{Not centered - pspicture example}
\begin{center}
 \begin{psmatrix}[rowsep=2,colsep=2]
  \begin{psmatrix}[rowsep=0.5,colsep=0.5]\mycirc&\mycirc\\ \mycirc&\mycirc\end{psmatrix}&
  \begin{psmatrix}[rowsep=0.5,colsep=0.5]\myframe&\myframe\\ \myframe&\myframe\end{psmatrix}\\
  \begin{psmatrix}[rowsep=0.5,colsep=0.5]\mycirc&\mycirc\\ \mycirc&\mycirc\end{psmatrix}&
  \begin{psmatrix}[rowsep=0.5,colsep=0.5]\myframe&\myframe\\ \myframe&\myframe\end{psmatrix}
  \end{psmatrix}
 \end{center}
\end{frame}
\end{document}

My question is how to make the psmatrix being correctly aligned. I'm mentioning the pspicture environment here just in case someone has a much more elegant solution for this. Note: As a workaround I'm using a not nested psmatrix where the distance between the four "blocks" is introduced by additional empty columns. Please don't propose that. I'd prefer the embedded solution this it allows more fine-grained positioning.

Thanks in advance to all of you who spend their time on giving me some hints!

Edit by The Last Error

The following edit tries to simplify the given MWE above. Feel free to rollback if you don't like my edit.

\documentclass[preview,border=12pt]{standalone}

\usepackage{pst-node}
\newcommand\mycirc{\pspicture(.5,.5)\pscircle(.25,.25){.25}\endpspicture}
\newcommand\myframe{\pspicture(.5,.5)\psframe(.5,.5)\endpspicture}

\begin{document}
\section{Properly centered}
\begin{center}
 \begin{psmatrix}
  A & B \\
  C & D
 \end{psmatrix}
 \end{center}

\section{Not centered}
\begin{center}
\fbox{%
 \begin{psmatrix}[rowsep=2,colsep=2,mcol=l]
  \begin{psmatrix}[rowsep=0.5,colsep=0.5]A1&A2\\A3&A4\end{psmatrix}&
  \begin{psmatrix}[rowsep=0.5,colsep=0.5]B1&B2\\B3&B4\end{psmatrix}\\
  \begin{psmatrix}[rowsep=0.5,colsep=0.5]C1&C2\\C3&C4\end{psmatrix}&
  \begin{psmatrix}[rowsep=0.5,colsep=0.5]D1&D2\\D3&D4\end{psmatrix}
  \end{psmatrix}}
 \end{center}

\section{Not centered - pspicture example}
\begin{center}
\fbox{%
 \begin{psmatrix}[rowsep=2,colsep=2]
  \begin{psmatrix}[rowsep=0.5,colsep=0.5]\mycirc&\mycirc\\ \mycirc&\mycirc\end{psmatrix}&
  \begin{psmatrix}[rowsep=0.5,colsep=0.5]\myframe&\myframe\\ \myframe&\myframe\end{psmatrix}\\
  \begin{psmatrix}[rowsep=0.5,colsep=0.5]\mycirc&\mycirc\\ \mycirc&\mycirc\end{psmatrix}&
  \begin{psmatrix}[rowsep=0.5,colsep=0.5]\myframe&\myframe\\ \myframe&\myframe\end{psmatrix}
  \end{psmatrix}}
 \end{center}

\end{document}

enter image description here

share|improve this question
    
Welcome to TeX.SX! –  Jubobs Feb 23 at 15:52
2  
Thanks for reviewing the MWE! –  Denis Feb 23 at 16:09
    
Is there an ulterior reason it has to be a psmatrix? There are many other ways to set up row/column formats. –  Steven B. Segletes Feb 23 at 17:16
    
Of course there are other ways to do this. The way I know is pstricks/psmatrix and I like this way due to the features of drawing node connections and bonds (specifically required, but skipped for MWE). If you have an easier way then let's have it! –  Denis Feb 23 at 17:19
add comment

2 Answers 2

It makes no sense to use a nested psmatrix. It can simply be done without it:

\documentclass{beamer}
\usepackage{pst-node}

\begin{document}
\begin{frame}{centered}
\begin{center}
\fbox{%
 \begin{psmatrix}[rowsep=0.5,colsep=0.5]
  A1&A2  &&& B1&B2 \\
  A3&A4  &&& B3&B4 \\[1cm]
  C1&C2  &&& D1&D2 \\
  C3&C4  &&& D3&D4
\end{psmatrix}}
\end{center}
\end{frame}

\end{document}

enter image description here

share|improve this answer
add comment

The OP insisted in the comments that alternative approaches (not employing psmatrix) were not what he was looking for. And I have not debugged the nesting of "psmatrices". Furthermore, my attempts are stymied by the fact that \pspicture always produces blank images, no matter what MWE I run.

BE THAT AS IT MAY, one can simply add a negative \kern when entering the outer psmatrix and everything else flows from there. Experimentation with the MWE indicates that the magnitude of the kern should equal the value of colsep of the outer psmatrix.

\documentclass[preview,border=12pt]{standalone}

\usepackage{pst-node}
\newcommand\mycirc{\pspicture(.5,.5)\pscircle(.25,.25){.25}\endpspicture}
\newcommand\myframe{\pspicture(.5,.5)\psframe(.5,.5)\endpspicture}

\begin{document}
\section{Properly centered}
\begin{center}
 \begin{psmatrix}
  A & B \\
  C & D
 \end{psmatrix}
 \end{center}

\section{Not centered}
\begin{center}
\fbox{\kern-2cm%
 \begin{psmatrix}[rowsep=2,colsep=2,mcol=l]
  \begin{psmatrix}[rowsep=0.5,colsep=0.5]A1&A2\\A3&A4\end{psmatrix}&
  \begin{psmatrix}[rowsep=0.5,colsep=0.5]B1&B2\\B3&B4\end{psmatrix}\\
  \begin{psmatrix}[rowsep=0.5,colsep=0.5]C1&C2\\C3&C4\end{psmatrix}&
  \begin{psmatrix}[rowsep=0.5,colsep=0.5]D1&D2\\D3&D4\end{psmatrix}
  \end{psmatrix}}
 \end{center}

\section{Not centered - pspicture example}
\begin{center}
\fbox{\kern-2cm% WITHOUT A VISUAL, DON'T KNOW IF AMOUNT IS CORRECT
 \begin{psmatrix}[rowsep=2,colsep=2]
  \begin{psmatrix}[rowsep=0.5,colsep=0.5]\mycirc&\mycirc\\ \mycirc&\mycirc\end{psmatrix}&
  \begin{psmatrix}[rowsep=0.5,colsep=0.5]\myframe&\myframe\\ \myframe&\myframe\end{psmatrix}\\
  \begin{psmatrix}[rowsep=0.5,colsep=0.5]\mycirc&\mycirc\\ \mycirc&\mycirc\end{psmatrix}&
  \begin{psmatrix}[rowsep=0.5,colsep=0.5]\myframe&\myframe\\ \myframe&\myframe\end{psmatrix}
  \end{psmatrix}}
 \end{center}

\end{document}

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.