2

(This question is related to "How to align subfigures of different heights in the same row").

I plot have plotted an array of 2x2 matrices with this code:

\documentclass[journal,twocolumn,10pt]{IEEEtran}
    \usepackage[compress]{cite}
    \usepackage{times} % Font Times New Roman throughout the document
    \usepackage{subfigure}
    \usepackage{epsfig}
    \usepackage{amsmath}
    \usepackage{amssymb}
    \usepackage{array}
    \usepackage{algorithm}
    \usepackage{algorithmic}
    \usepackage{tikz,pgfplots}
    \usepackage{adjustbox}
    \pgfplotsset{compat=1.14}
    \usepgfplotslibrary{patchplots}
    \usepgfplotslibrary{fillbetween}
    \usepackage{caption}
    \usetikzlibrary{arrows.meta}
    \usepackage{graphicx}
    \usepackage{float}
    \usepackage{mathtools}

\begin{document}

\begin{figure}[t]
\centering
\captionsetup{justification=centering}
\resizebox {0.8 \columnwidth}{!}{
\subfigure[Line]{\centering
\begin{tikzpicture}
\draw (0,0) node {$S= \begin{bmatrix}
     0  &   0  &   0  &   0\\
     1  &   0  &   0  &   0\\
     0  &   1  &   0  &   0\\
     0  &   0  &   1  &   0\\
     1  &   0  &   1  &   0\\
     0  &   0  &   0  &   1\\
     1  &   0  &   0  &   1\\
     0  &   1  &   0  &   1\\
    \end{bmatrix}$};
\end{tikzpicture} }
\subfigure[Square]{\centering
\begin{tikzpicture}
\draw (0,0) node {$S= \begin{bmatrix}
     0  &   0  &   0  &   0\\
     1  &   0  &   0  &   0\\
     0  &   1  &   0  &   0\\
     0  &   0  &   1  &   0\\
     1  &   0  &   1  &   0\\
     0  &   0  &   0  &   1\\
     0  &   1  &   0  &   1\\
    \end{bmatrix}$};
\end{tikzpicture}}
}\\
\resizebox {0.8 \columnwidth}{!}{
\subfigure[Full]{\centering
\begin{tikzpicture}
\draw (0,0) node {$S= \begin{bmatrix}
     0  &   0  &   0  &   0\\
     1  &   0  &   0  &   0\\
     0  &   1  &   0  &   0\\
     0  &   0  &   1  &   0\\
     0  &   0  &   0  &   1\\
\end{bmatrix}$};
\end{tikzpicture}}
\subfigure[Star]{\centering
\begin{tikzpicture}
\draw (0,0) node {  $S= \begin{bmatrix}
     0  &   0  &   0  &   0\\
     1  &   0  &   0  &   0\\
     0  &   1  &   0  &   0\\
     0  &   0  &   1  &   0\\
     0  &   1  &   1  &   0\\
     0  &   0  &   0  &   1\\
     0  &   1  &   0  &   1\\
     0  &   0  &   1  &   1\\
     0  &   1  &   1  &   1\\
    \end{bmatrix}$};
\end{tikzpicture}}}
\caption{Action rule matrices for network graphs of figure \ref{NETEXAMPLE}}
\label{ACTIVATIONFIG}
\end{figure}

\end{document}                                        

which result in this Figure

enter image description here

Subfigures in a row are aligned with respect to their captions, (a) with (b) and (c) with (d). I would rather prefer to align matrices by the symbol S so that matrices in a row have this symbol at the same height. For example, like these four matrices have the Ssymbol aligned:

enter image description here

Regards

Note: referred question "How to align subfigures of different heights in the same row" uses the subcaptionpackage which give compile errors when added to the whole preamble of the document.

user1993416
  • 1,046
  • 3
    You can't have both the subfigure and subcaption packages in the same document, so if you replace subfigure with subcaption you won't get that error. Of course, then you must also change from \subfigure[...]{...} to the syntax given by subcaption, as in the answer to the other question. – Torbjørn T. Jun 20 '18 at 16:10

2 Answers2

3

an option is defining a specific size for each drawing in tikz, using a rectangle, in the example it is shown with red lines, and then with white lines, if you do not use watermark, there will be no problems, finally another option drawing everything using the matrix libraries and tikz positioning.

If you decide to draw everything in tikz you can draw whatever it is in another document and import it as pdf using the standalone environment as in Scaling different components of tikzpicture together.

RESULT: enter image description here

MWE:

% arara: pdflatex: {synctex: yes, action: nonstopmode}

\documentclass[journal,twocolumn,10pt]{IEEEtran}
\usepackage[compress]{cite}
\usepackage{times} % Font Times New Roman throughout the document
\usepackage{subfigure}
\usepackage{epsfig}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{array}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{tikz,pgfplots}
\usepackage{adjustbox}
\pgfplotsset{compat=1.14}
\usepgfplotslibrary{patchplots}
\usepgfplotslibrary{fillbetween}
\usepackage{caption}
\usetikzlibrary{matrix,positioning}
\usepackage{graphicx}
\usepackage{float}
\usepackage{mathtools}

\usepackage{lipsum}

\begin{document}
An option just delimiting some common dimenssion for tikzpicture using a rectangle shape.\\

    \begin{figure}[h!]
        \centering
        \subfigure[Line]{\centering
                \begin{tikzpicture}
                \draw[red] (-1.5,-2) rectangle (1.5,2);
                \draw (0,0) node {$S= \begin{bmatrix}
                    0  &   0  &   0  &   0\\
                    1  &   0  &   0  &   0\\
                    0  &   1  &   0  &   0\\
                    0  &   0  &   1  &   0\\
                    1  &   0  &   1  &   0\\
                    0  &   0  &   0  &   1\\
                    1  &   0  &   0  &   1\\
                    0  &   1  &   0  &   1\\
                    \end{bmatrix}$};
                \end{tikzpicture}}
            \subfigure[Square]{\centering
                \begin{tikzpicture}
                \draw[red] (-1.5,-2) rectangle (1.5,2);
                \draw (0,0) node {$S= \begin{bmatrix}
                    0  &   0  &   0  &   0\\
                    1  &   0  &   0  &   0\\
                    0  &   1  &   0  &   0\\
                    0  &   0  &   1  &   0\\
                    1  &   0  &   1  &   0\\
                    0  &   0  &   0  &   1\\
                    0  &   1  &   0  &   1\\
                    \end{bmatrix}$};
                \end{tikzpicture}}\\
        \subfigure[Full]{\centering
                \begin{tikzpicture}
                \draw[red] (-1.5,-2) rectangle (1.5,2);
                \draw (0,0) node {$S= \begin{bmatrix}
                    0  &   0  &   0  &   0\\
                    1  &   0  &   0  &   0\\
                    0  &   1  &   0  &   0\\
                    0  &   0  &   1  &   0\\
                    0  &   0  &   0  &   1\\
                    \end{bmatrix}$};
                \end{tikzpicture}}
            \subfigure[Star]{\centering
                \begin{tikzpicture}
                \draw[red] (-1.5,-2) rectangle (1.5,2);
                \draw (0,0) node {  $S= \begin{bmatrix}
                    0  &   0  &   0  &   0\\
                    1  &   0  &   0  &   0\\
                    0  &   1  &   0  &   0\\
                    0  &   0  &   1  &   0\\
                    0  &   1  &   1  &   0\\
                    0  &   0  &   0  &   1\\
                    0  &   1  &   0  &   1\\
                    0  &   0  &   1  &   1\\
                    0  &   1  &   1  &   1\\
                    \end{bmatrix}$};
                \end{tikzpicture}}
        \caption{Matrix using an auxiliar red box \ref{NETEXAMPLE}}
        \label{ACTIVATIONFIG}
    \end{figure}
If you choose to draw write you could obtaind this result.\\

\begin{figure}[h!]
    \centering
    \subfigure[Line]{\centering
        \begin{tikzpicture}
        \draw[white] (-1.5,-2) rectangle (1.5,2);
        \draw (0,0) node {$S= \begin{bmatrix}
            0  &   0  &   0  &   0\\
            1  &   0  &   0  &   0\\
            0  &   1  &   0  &   0\\
            0  &   0  &   1  &   0\\
            1  &   0  &   1  &   0\\
            0  &   0  &   0  &   1\\
            1  &   0  &   0  &   1\\
            0  &   1  &   0  &   1\\
            \end{bmatrix}$};
        \end{tikzpicture}}
    \subfigure[Square]{\centering
        \begin{tikzpicture}
        \draw[white] (-1.5,-2) rectangle (1.5,2);
        \draw (0,0) node {$S= \begin{bmatrix}
            0  &   0  &   0  &   0\\
            1  &   0  &   0  &   0\\
            0  &   1  &   0  &   0\\
            0  &   0  &   1  &   0\\
            1  &   0  &   1  &   0\\
            0  &   0  &   0  &   1\\
            0  &   1  &   0  &   1\\
            \end{bmatrix}$};
        \end{tikzpicture}}\\
    \subfigure[Full]{\centering
        \begin{tikzpicture}
        \draw[white] (-1.5,-2) rectangle (1.5,2);
        \draw (0,0) node {$S= \begin{bmatrix}
            0  &   0  &   0  &   0\\
            1  &   0  &   0  &   0\\
            0  &   1  &   0  &   0\\
            0  &   0  &   1  &   0\\
            0  &   0  &   0  &   1\\
            \end{bmatrix}$};
        \end{tikzpicture}}
    \subfigure[Star]{\centering
        \begin{tikzpicture}
        \draw[white] (-1.5,-2) rectangle (1.5,2);
        \draw (0,0) node {  $S= \begin{bmatrix}
            0  &   0  &   0  &   0\\
            1  &   0  &   0  &   0\\
            0  &   1  &   0  &   0\\
            0  &   0  &   1  &   0\\
            0  &   1  &   1  &   0\\
            0  &   0  &   0  &   1\\
            0  &   1  &   0  &   1\\
            0  &   0  &   1  &   1\\
            0  &   1  &   1  &   1\\
            \end{bmatrix}$};
        \end{tikzpicture}}
    \caption{Matrix using an auxiliar white box.}
    \label{ACTIVATIONFIG}
\end{figure}
\vspace{2\baselineskip}
%Some text
Drawing unsing tikz matrix library and positioning, you can control all, the distance from matrix nodes, distance between matrix.
\vspace{\baselineskip}  
\begin{figure}[h!]
    \centering
    \begin{tikzpicture}[
    Matrix/.style={
        matrix of math nodes,
        align=center,
        left delimiter=[,
        right delimiter=],
        column sep=0pt,
        row sep=0pt,
        inner sep=2pt,
        %nodes in empty cells,
        on grid,
    }
    ]

    \matrix[Matrix](M1){ % Matrix contents  
        0  &   0  &   0  &   0\\
        1  &   0  &   0  &   0\\
        0  &   1  &   0  &   0\\
        0  &   0  &   1  &   0\\
        1  &   0  &   1  &   0\\
        0  &   0  &   0  &   1\\
        1  &   0  &   0  &   1\\
        0  &   1  &   0  &   1\\
    };

    \matrix[Matrix, right=4.5cm of M1](M2){ % Matrix contents  
        0  &   0  &   0  &   0\\
        1  &   0  &   0  &   0\\
        0  &   1  &   0  &   0\\
        0  &   0  &   1  &   0\\
        1  &   0  &   1  &   0\\
        0  &   0  &   0  &   1\\
        0  &   1  &   0  &   1\\
    };

    \matrix[Matrix, below=4.5cm of M1](M3){ % Matrix contents  
        0  &   0  &   0  &   0\\
        1  &   0  &   0  &   0\\
        0  &   1  &   0  &   0\\
        0  &   0  &   1  &   0\\
        0  &   0  &   0  &   1\\
    };

    \matrix[Matrix, right=4.5cm of M3](M4){ % Matrix contents  
        0  &   0  &   0  &   0\\
        1  &   0  &   0  &   0\\
        0  &   1  &   0  &   0\\
        0  &   0  &   1  &   0\\
        1  &   0  &   1  &   0\\
        0  &   0  &   0  &   1\\
        0  &   1  &   0  &   1\\
    };
    \foreach \i/\j [count=\k from 1]in {a/Line,b/Square,c/Full,d/Star}{
        \draw node[on grid, left=1.5cm of M\k]{$S =$};
        \draw node[on grid, below=2cm of M\k]{\small(\i) \j};
    }


    \end{tikzpicture}
    \caption{Matrix using tikz matrix and positioning library}
    \label{ACTIVATIONFIG}
\end{figure}

\end{document} 
J Leon V.
  • 11,533
  • 16
  • 47
2

You are putting the matrices in TikZ pictures already (and I don't know why), and this offers you to do the alignment within such pictures.

\documentclass[journal,twocolumn,10pt]{IEEEtran}
    \usepackage{times} % Font Times New Roman throughout the document
    \usepackage{amsmath}
    \usepackage{amssymb}
    \usepackage{array}
    \usepackage{tikz}
    \usepackage{adjustbox}
    \usepackage{subcaption}
    \usetikzlibrary{positioning}

\begin{document}

\begin{figure}[t]
\centering
\captionsetup{justification=centering}
\resizebox {0.8 \columnwidth}{!}{
\begin{tikzpicture}[every node/.append style={baseline}]
\draw (0,0) node (A) {$S= \begin{bmatrix}
     0  &   0  &   0  &   0\\
     1  &   0  &   0  &   0\\
     0  &   1  &   0  &   0\\
     0  &   0  &   1  &   0\\
     1  &   0  &   1  &   0\\
     0  &   0  &   0  &   1\\
     1  &   0  &   0  &   1\\
     0  &   1  &   0  &   1\\
    \end{bmatrix}$};
\node[below=0pt of A,text width=4cm] {\subcaption{Line}};
\node[right=1cm of A] (B) {$S= \begin{bmatrix}
     0  &   0  &   0  &   0\\
     1  &   0  &   0  &   0\\
     0  &   1  &   0  &   0\\
     0  &   0  &   1  &   0\\
     1  &   0  &   1  &   0\\
     0  &   0  &   0  &   1\\
     0  &   1  &   0  &   1\\
    \end{bmatrix}$};
\node[below=0pt of B,text width=4cm] {\subcaption{Square}};
\end{tikzpicture}%}
}\\
\resizebox {0.8 \columnwidth}{!}{
\begin{tikzpicture}[every node/.append style={baseline}]
\draw (0,0) node (C) {$S= \begin{bmatrix}
     0  &   0  &   0  &   0\\
     1  &   0  &   0  &   0\\
     0  &   1  &   0  &   0\\
     0  &   0  &   1  &   0\\
     0  &   0  &   0  &   1\\
\end{bmatrix}$};
\node[below=0pt of C,text width=4cm] {\subcaption{Full}};
\node[right=1cm of C] (D) {  $S= \begin{bmatrix}
     0  &   0  &   0  &   0\\
     1  &   0  &   0  &   0\\
     0  &   1  &   0  &   0\\
     0  &   0  &   1  &   0\\
     0  &   1  &   1  &   0\\
     0  &   0  &   0  &   1\\
     0  &   1  &   0  &   1\\
     0  &   0  &   1  &   1\\
     0  &   1  &   1  &   1\\
    \end{bmatrix}$};
\node[below=0pt of D,text width=4cm] {\subcaption{Star}};
\end{tikzpicture}}%}
\caption{Action rule matrices for network graphs of figure \ref{NETEXAMPLE}}
\label{ACTIVATIONFIG}
\end{figure}
\end{document}                      

enter image description here

It is also easy to align the subcaptions at the same height. (And you were loading many packages that you are not using.)

\documentclass[journal,twocolumn,10pt]{IEEEtran}
    \usepackage{times} % Font Times New Roman throughout the document
    \usepackage{amsmath}
    \usepackage{amssymb}
    \usepackage{array}
    \usepackage{tikz}
    \usepackage{adjustbox}
    \usepackage{subcaption}
    \usetikzlibrary{positioning}

\begin{document}

\begin{figure}[t]
\centering
\captionsetup{justification=centering}
\resizebox {0.8 \columnwidth}{!}{
\begin{tikzpicture}[every node/.append style={baseline}]
\draw (0,0) node (A) {$S= \begin{bmatrix}
     0  &   0  &   0  &   0\\
     1  &   0  &   0  &   0\\
     0  &   1  &   0  &   0\\
     0  &   0  &   1  &   0\\
     1  &   0  &   1  &   0\\
     0  &   0  &   0  &   1\\
     1  &   0  &   0  &   1\\
     0  &   1  &   0  &   1\\
    \end{bmatrix}$};
\node[below=0pt of A,text width=4cm] (Acap) {\subcaption{Line}};
\node[right=1cm of A] (B) {$S= \begin{bmatrix}
     0  &   0  &   0  &   0\\
     1  &   0  &   0  &   0\\
     0  &   1  &   0  &   0\\
     0  &   0  &   1  &   0\\
     1  &   0  &   1  &   0\\
     0  &   0  &   0  &   1\\
     0  &   1  &   0  &   1\\
    \end{bmatrix}$};
\node[text width=4cm] at (Acap -| B) {\subcaption{Square}};
\end{tikzpicture}%}
}\\
\resizebox {0.8 \columnwidth}{!}{
\begin{tikzpicture}[every node/.append style={baseline}]
\draw (0,0) node (C) {$S= \begin{bmatrix}
     0  &   0  &   0  &   0\\
     1  &   0  &   0  &   0\\
     0  &   1  &   0  &   0\\
     0  &   0  &   1  &   0\\
     0  &   0  &   0  &   1\\
\end{bmatrix}$};
\node[right=1cm of C] (D) {  $S= \begin{bmatrix}
     0  &   0  &   0  &   0\\
     1  &   0  &   0  &   0\\
     0  &   1  &   0  &   0\\
     0  &   0  &   1  &   0\\
     0  &   1  &   1  &   0\\
     0  &   0  &   0  &   1\\
     0  &   1  &   0  &   1\\
     0  &   0  &   1  &   1\\
     0  &   1  &   1  &   1\\
    \end{bmatrix}$};
\node[below=0pt of D,text width=4cm] (Dcap) {\subcaption{Star}};
\node[text width=4cm] at (Dcap -| C) {\subcaption{Full}};
\end{tikzpicture}}%}
\caption{Action rule matrices for network graphs of figure \ref{NETEXAMPLE}}
\label{ACTIVATIONFIG}
\end{figure}
\end{document} 

enter image description here

EDIT: Added second option and baseline.