2

I want to have a \bordermatrix environment in a subfigure to show the correspondence between an incidence graph (which is a tikzpicture - I'm sure it's irrelevant to the problem) and the incidence matrix. The two figures are next to each other (as expected), but the math environment creates a (huge) white space (margin) above. Please see the code and the screenshot below.

\begin{figure}
  \centering 

  \subfigure[bipartiter Inzidenzgraph\newline (\emph{bipartite Anordnung})]{
    \fbox{
      \plotungerichteterHGInzidenzBipartit % a tikzpicture
    }
  }

  \subfigure[Inzidenzmatrix] {
    \fbox{
      \resizebox{4cm}{!}{
        $\bordermatrix{
          &v_1&v_2&v_3 &v_4&v_5  \cr
          e_1& 1 & 1 & 0 & 1 & 1 \cr
          e_2& 1 & 1 & 1 & 0 & 0 \cr
          e_3& 0 & 0 & 1 & 0 & 1  \cr
          e_4& 0 & 0 & 0 & 1 & 0}$
      }
    }
  }

  \caption[Darstellungsformen eines Hypergraphen]{Darstellungsformen eines Hypergraphen}
  \label{fig:ungerichteterHG}
\end{figure}

As you can see, I added fboxes to show that the scope of the figures are as expected. These as well as the resizebox are not the problem (I removed them, same issue).

subfigs next to each other .

Actually in the above code there is no newline between the subfigures so that they are next to each other. But, interestingly, if I would place the matrix beneath the subfigure (by adding that new line) I will get the following and as you can see, this mysterious white space is gone:

subfig 1 upon subfig 2 - no whitespace .

So why would there be whitespace above the matrix only if I place them next to each other, but everything as expect in case I place them above each other?

Werner
  • 603,163
  • 1
    Welcome to TeX.sx! Your post was migrated here from [so]. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – Werner Jun 20 '13 at 18:11

1 Answers1

3

This results from the \bordermatrix command centering its contents vertically along the math axis. Alternatively put, you'll note that the vertical centre of the \bordermatrix - between rows 2 and 3 is where the "anchor" point is, which coincides with the base line anchor point of the tikzpicture.

Here's an updated view on what you might be after instead:

enter image description here

\documentclass{article}
\usepackage{subfigure,graphicx}% http://ctan.org/pkg/{subfigure,graphicx}
\begin{document}

\begin{figure}
  \centering 
  \subfigure[bipartiter Inzidenzgraph\newline (\emph{bipartite Anordnung})]{
    \fbox{%
      \rule{0.3\linewidth}{100pt}% a tikzpicture
    }
  }
  \subfigure[Inzidenzmatrix] {
    \raisebox{.5\height}{\fbox{%
      \resizebox{4cm}{!}{%
        $\bordermatrix{
          &v_1&v_2&v_3 &v_4&v_5  \cr
          e_1& 1 & 1 & 0 & 1 & 1 \cr
          e_2& 1 & 1 & 1 & 0 & 0 \cr
          e_3& 0 & 0 & 1 & 0 & 1  \cr
          e_4& 0 & 0 & 0 & 1 & 0}$
      }%
    }}
  }

  \caption{Darstellungsformen eines Hypergraphen}
  \label{fig:ungerichteterHG}
\end{figure}

\end{document}

The correction I've made is to raise the \bordermatrix by 50% of its own height, thereby placing the "anchor" at the baseline.

Some considerations:

Ps. I've used a black box to represent the tikzpicture, since you didn't include that in your code.

Werner
  • 603,163
  • Thank you very much, Werner! The anchor point consideration was the point I didn't unterstand but now I guess I'm aware of. Thank you also for the tips concerning my TeX scripting :) –  Jun 20 '13 at 17:35
  • Shameless self-advertisement: When using \subcaptionbox offered by the subcaption package (instead of \subfigure), the extra \raisebox isn't needed at all since the two sub-figures are aligned at their first caption line automatically. –  Jun 20 '13 at 18:14
  • @AxelSommerfeldt: Thanks. I mention your caption package, but it translates to the subsidiaries as well. – Werner Jun 20 '13 at 18:17