0

The following 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}

produces the following picture: enter image description here

which horizontally align the matrices setting the captions in the same row to be aligned. I would like to align matrices of the same row to have the S= at the same height (aligned S's in two rows).

Regards

user1993416
  • 1,046

2 Answers2

2
  • package subfigure is superseded with subfig
  • but better is used more poverfull subcaption:

    \documentclass[journal,twocolumn,10pt]{IEEEtran}
    \usepackage{caption}
    \usepackage{tikz}
    \usetikzlibrary{arrows.meta}
    \usepackage{graphicx}
    \usepackage{subcaption}
    \usepackage{amsmath}
    
    \begin{document}
    
    \begin{figure}[htb]
    \centering
    \captionsetup{justification=centering}
    \begin{subfigure}[t]{0.45\linewidth} % with option "t" subfigure is aligned to its top
    \[
    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}
    \]
    \caption{Square}
    \end{subfigure}\hfil
    \begin{subfigure}[t]{0.45\linewidth}
    \[
    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}
    \]
    \caption{Square}
    \end{subfigure}
    
    \begin{subfigure}[t]{0.45\linewidth}
    \[
    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}
    \]
    \caption{Full}
    \end{subfigure}\hfil
    \begin{subfigure}[t]{0.45\linewidth}
    \[
    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}
    \]
    \caption{Star}
    \end{subfigure}
    \caption{Action rule matrices for network graphs of figure \ref{NETEXAMPLE}}
    \label{ACTIVATIONFIG}
    \end{figure}
    
    \end{document}
    

which gives:

enter image description here

is this what you looking for?

note: i don't understand why you enclose matrices in tikz nodes. i use simple display math environment for them.

edit (1): in case, that you like to top align first two matrices than at second pair remove option [t] or add option [b]:

\documentclass[journal,twocolumn,10pt]{IEEEtran}
\usepackage{caption}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{amsmath}

\begin{document}

\begin{figure}[htb]
\centering
\captionsetup{justification=centering}
\begin{subfigure}[t]{0.45\linewidth}% with option "t" subfigure is aligned t its top
\[
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}
\]
\caption{Square}
\end{subfigure}\hfil
\begin{subfigure}[t]{0.45\linewidth}
\[
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}
\]
\caption{Square}
\end{subfigure}

\begin{subfigure}{0.45\linewidth}% without option subfigure is alignet t its center
\[
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}
\]
\caption{Full}
\end{subfigure}\hfil
\begin{subfigure}{0.45\linewidth}
\[
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}
\]
\caption{Star}
\end{subfigure}

\begin{subfigure}[b]{0.45\linewidth}% with option "b" subfigure is aligned to its bottom
\[
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}
\]
\caption{Full}
\end{subfigure}\hfil
\begin{subfigure}[b]{0.45\linewidth}
\[
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}
\]
\caption{Star}
\end{subfigure}
\caption{Action rule matrices for network graphs of figure \ref{NETEXAMPLE}}
\label{ACTIVATIONFIG}
\end{figure}

\end{document}

enter image description here

edit (2) considering marmot comment below, the first two matrices can be aligned also as follows:

enter image description here

\documentclass[journal,twocolumn,10pt]{IEEEtran}
\usepackage{caption}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{amsmath}

\begin{document}

\begin{figure}[t]
\centering
\captionsetup{justification=centering}
\begin{subfigure}[t]{0.45\linewidth}
\[
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}
\]
\caption{Square}
\end{subfigure}\hfil
\begin{subfigure}[t]{0.45\linewidth}
\begin{gather*}  % enable stacking phantom matrices below main
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}\\       
    \vphantom{\begin{bmatrix}
     0\\
    \end{bmatrix}}
\end{gather*}
\caption{Square}
\end{subfigure}

\end{figure}
\end{document}
Zarko
  • 296,517
  • @Zarko thank you. With tikzpicture the captions look better because matrices are figures. In the solution the first and the second row are justified up. I was looking to justify up only the first row and leave the second row the same, with figures and captions (c) and (d) at the same level. – user1993416 Jun 19 '18 at 20:47
  • @marmot Thanks. Can I change something in my code to raise just the matrix (b)? – user1993416 Jun 19 '18 at 21:04
  • @user1993416, sory, i don't understand you. can you illustrate this with some sketch. regarding tikz node, i don't see any benefits in its use. if you like the top alignment of matrices only at first two subfigures, remove [t] at third in forth subfigure. – Zarko Jun 19 '18 at 21:13
  • @marmot thanks. I have made an edit of the initial question. It seems I can not use the subcaption package in my paper. – user1993416 Jun 20 '18 at 07:08
  • @user1993416, please let me know with which packages you find incompatibility of subcaption with other packages. so far i didn't met any. also is not nice to change question and with this nullified received answer. i suggest to close your question as "not clear what you asking for". – Zarko Jun 20 '18 at 10:49
  • You are right. My question is not clear enough. I have just modified the question and I hope now the goal to achieve is clearer. – user1993416 Jun 20 '18 at 14:02
1
  • new content of question, so new answer ...
  • like this (i still don't know, what you like to obtain, now i guess that you like to align subcaptions as well S in equations):

enter image description here

    \documentclass[journal,twocolumn,10pt]{IEEEtran}
    \usepackage{caption, subcaption}
    \usepackage{amsmath}
    \usepackage{array}

    \usepackage{lipsum}

    \begin{document}
    \lipsum[11]
    \begin{figure}[htb]
    \centering
    \captionsetup{justification=centering}
    \begin{tabular}{*{2}{m{\dimexpr0.45\linewidth-2\tabcolsep}}}
    \[
    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}
    \]
    &
    \[
    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}
    \]                      \\
    \subcaption{Line}
    &
    \subcaption{Square}     \\
    \[
    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}
    \]
    &
    \[
    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}
    \]                      \\
    \subcaption{Full}
    &
    \subcaption{Star}
    \end{tabular}
    \caption{Action rule matrices for network graphs of figure \ref{NETEXAMPLE}}
    \label{ACTIVATIONFIG}
    \end{figure}
    \end{document}
Zarko
  • 296,517