3

I am struggling to align the sub-figure, especially the captions, but could not find some way.

\documentclass[twocolumn]{article}
\usepackage{geometry}
\geometry{legalpaper, landscape, margin=2in}
\usepackage{tkz-graph}
\usepackage{subfig}

\begin{document}
\begin{figure*}
\centering
\subfloat[][]{
    \label{fig:ex1}
    \begin{tikzpicture}[baseline=(a1.base),->,>=stealth',shorten >=1pt,auto,node distance=1.24cm, main node/.style={circle,draw, minimum size=1em}]
    \node[main node] (a1) {\small $n_1$};
    \node[main node] (a2) [below left of=a1] {\small $n_2$};
    \node[main node] (a3) [below right of=a1] {\small $n_3$};
    \path (a1) edge [] node {} (a3)
    (a1) edge [] node {} (a2);
    \end{tikzpicture}
}
\quad
\centering
\subfloat[][]{
    \label{fig:ex2}
    \begin{tikzpicture}[baseline=(b1.base),->,>=stealth',shorten >=1pt,auto,node distance=1.24cm, main node/.style={circle,draw}]
    \node[main node] (b1) {\small $n_1$};
    \node[main node] (b2) [below left of=b1] {\small $n_2$};
    \node[main node] (b3) [below right of=b1] {\small $n_3$};
    \path
    (b1) edge [] node {} (b3)
    (b1) edge [] node {} (b2)
    (b3) edge [in=45,out=315, looseness=1.5] node {} (b1);
    \end{tikzpicture}
}
\quad
\centering
\subfloat[][]{
    \label{fig:ex3}
    \begin{tikzpicture}[baseline=(c1.base),->,>=stealth',shorten >=1pt,auto,node distance=1.24cm, main node/.style={circle,draw}]
    \node[main node] (c1) {\small $n_1$};
    \node[main node] (c2) [below left of=c1] {\small $n_2$};
    \node[main node] (c3) [below right of=c1] {\small $n_3$};
    \path
    (c1) edge [] node {} (c3)
    (c1) edge [] node {} (c2)
    (c3) edge [in=-45,out=315, looseness=1.5] node {} (c2);
    \end{tikzpicture}
}
\quad
\centering
\subfloat[][]{
    \label{fig:ex4}
    \begin{tikzpicture}[baseline=(d1.base),->,>=stealth',shorten >=1pt,auto,node distance=1.24cm, main node/.style={circle,draw}]
    \node[main node] (d1) {\small $n_1$};
    \node[main node] (d2) [below left of=d1] {\small $n_2$};
    \node[main node] (d3) [below right of=d1] {\small $n_3$};
    \path
    (d1) edge [] node {} (d3)
    (d1) edge [] node {} (d2)
    (d3) edge [in=45,out=315,loop] node {} (d3);
    \end{tikzpicture}
}
\quad
\centering
\subfloat[][]{
    \label{fig:ex5}
    \begin{tikzpicture}[baseline=(e1.base),->,>=stealth',shorten >=1pt,auto,node distance=1.24cm, main node/.style={circle,draw}]
    \node[main node] (e1) {\small $n_1$};
    \node[main node] (e2) [below left of=e1] {\small $n_2$};
    \node[main node] (e3) [below right of=e1] {\small $n_3$};
    \node[main node, dashed] (e4) [below right of=e3] {\small $n_4$};
    \path
    (e1) edge [] node {} (e3)
    (e1) edge [] node {} (e2)
    (e3) edge [in=135,out=315] node {} (e4);
    \end{tikzpicture}
}
\caption{Steps in Korat exploration to find an extendable candidate vector}
\end{figure*}

\end{document}

Please help me to align the (a), (b), (c) substations. enter image description here

  • Please edit your question to make your code compilable. – cfr Aug 24 '17 at 2:54
  • @cfr edited. But ignore the page size. – Muhammad Nawaz Aug 24 '17 at 3:08
  • Both of the solutions suggested by @cfr and @John Kormylo worked for this specific problem. But I'm choosing given by @John otherwise I have to modify all other diagrams which use \subfig – Muhammad Nawaz Aug 24 '17 at 4:48
3

You can use a tabular. Note: subcaptions do not show up in the \listoffigures.

I'm not sure why you want labels, but I put them in anyway. Frankly remembering a,b,c... is a lot easier than \ref{fig:ex1} etc. If you eventually plan on adding hyperref, you can use \hyperlink and \hypertarget just as easily.

\documentclass[twocolumn]{article}
\usepackage{geometry}
\geometry{legalpaper, landscape, margin=2in,showframe}% added showframe
\usepackage{tkz-graph}
\usepackage{subfig}% not used here

\begin{document}
\begin{figure*}
\centering
\settowidth{\tabcolsep}{\quad}
\tabcolsep=0.5\tabcolsep
\begin{tabular}{ccccc}
  \expandafter\advance\csname c@figure\endcsname by 1
  \refstepcounter{subfigure}\label{fig:ex1}%
    \begin{tikzpicture}[baseline=(a1.base),->,>=stealth',shorten >=1pt,auto,node distance=1.24cm, main node/.style={circle,draw, minimum size=1em}]
    \node[main node] (a1) {\small $n_1$};
    \node[main node] (a2) [below left of=a1] {\small $n_2$};
    \node[main node] (a3) [below right of=a1] {\small $n_3$};
    \path (a1) edge [] node {} (a3)
    (a1) edge [] node {} (a2);
    \end{tikzpicture}
&
  \refstepcounter{subfigure}\label{fig:ex2}%
    \begin{tikzpicture}[baseline=(b1.base),->,>=stealth',shorten >=1pt,auto,node distance=1.24cm, main node/.style={circle,draw}]
    \node[main node] (b1) {\small $n_1$};
    \node[main node] (b2) [below left of=b1] {\small $n_2$};
    \node[main node] (b3) [below right of=b1] {\small $n_3$};
    \path
    (b1) edge [] node {} (b3)
    (b1) edge [] node {} (b2)
    (b3) edge [in=45,out=315, looseness=1.5] node {} (b1);
    \end{tikzpicture}
&
  \refstepcounter{subfigure}\label{fig:ex3}%
    \begin{tikzpicture}[baseline=(c1.base),->,>=stealth',shorten >=1pt,auto,node distance=1.24cm, main node/.style={circle,draw}]
    \node[main node] (c1) {\small $n_1$};
    \node[main node] (c2) [below left of=c1] {\small $n_2$};
    \node[main node] (c3) [below right of=c1] {\small $n_3$};
    \path
    (c1) edge [] node {} (c3)
    (c1) edge [] node {} (c2)
    (c3) edge [in=-45,out=315, looseness=1.5] node {} (c2);
    \end{tikzpicture}
&
  \refstepcounter{subfigure}\label{fig:ex4}%
    \begin{tikzpicture}[baseline=(d1.base),->,>=stealth',shorten >=1pt,auto,node distance=1.24cm, main node/.style={circle,draw}]
    \node[main node] (d1) {\small $n_1$};
    \node[main node] (d2) [below left of=d1] {\small $n_2$};
    \node[main node] (d3) [below right of=d1] {\small $n_3$};
    \path
    (d1) edge [] node {} (d3)
    (d1) edge [] node {} (d2)
    (d3) edge [in=45,out=315,loop] node {} (d3);
    \end{tikzpicture}
&
  \refstepcounter{subfigure}\label{fig:ex5}%
    \begin{tikzpicture}[baseline=(e1.base),->,>=stealth',shorten >=1pt,auto,node distance=1.24cm, main node/.style={circle,draw}]
    \node[main node] (e1) {\small $n_1$};
    \node[main node] (e2) [below left of=e1] {\small $n_2$};
    \node[main node] (e3) [below right of=e1] {\small $n_3$};
    \node[main node, dashed] (e4) [below right of=e3] {\small $n_4$};
    \path
    (e1) edge [] node {} (e3)
    (e1) edge [] node {} (e2)
    (e3) edge [in=135,out=315] node {} (e4);
    \end{tikzpicture}
\\
(a) & (b) & (c) & (d) & (e)
\end{tabular}
\caption{Steps in Korat exploration to find an extendable candidate vector}
\end{figure*}

\end{document}
| improve this answer | |
4

You could use floatrow. However, I now avoid this whenever possible as it is not entirely all there, as packages go. However, it can handle this kind of situation with some elegance.

Hopefully, somebody will offer a solution which is both elegant and not floatrow-dependent. Otherwise, a little hackery can produce good results. For example,

\documentclass[twocolumn]{article}
\usepackage{geometry}
\geometry{legalpaper, landscape, margin=2in}
\usepackage{tkz-graph}
% \usepackage{subfig}
\usepackage{subcaption}

\begin{document}
\begin{figure*}
\centering
\subcaptionbox{\label{fig:ex1}}{%
  \begin{tikzpicture}[baseline=(a1.base),->,>=stealth',shorten >=1pt,auto,node distance=1.24cm, main node/.style={circle,draw, minimum size=1em}]
    \node[main node] (a1) {\small $n_1$};
    \node[main node] (a2) [below left of=a1] {\small $n_2$};
    \node[main node] (a3) [below right of=a1] {\small $n_3$};
    \node[main node, draw=none] (a4) [below right of=a2] {\phantom{\small $n_4$}};
    \path (a1) edge [] node {} (a3)
    (a1) edge [] node {} (a2);
  \end{tikzpicture}%
}\quad
\subcaptionbox{\label{fig:ex2}}{%
    \begin{tikzpicture}[baseline=(b1.base),->,>=stealth',shorten >=1pt,auto,node distance=1.24cm, main node/.style={circle,draw}]
    \node[main node] (b1) {\small $n_1$};
    \node[main node] (b2) [below left of=b1] {\small $n_2$};
    \node[main node] (b3) [below right of=b1] {\small $n_3$};
    \node[main node, draw=none] (b4) [below right of=b2] {\phantom{\small $n_4$}};
    \path
    (b1) edge [] node {} (b3)
    (b1) edge [] node {} (b2)
    (b3) edge [in=45,out=315, looseness=1.5] node {} (b1);
    \end{tikzpicture}%
}\quad
\subcaptionbox{\label{fig:ex3}}{%
    \begin{tikzpicture}[baseline=(c1.base),->,>=stealth',shorten >=1pt,auto,node distance=1.24cm, main node/.style={circle,draw}]
    \node[main node] (c1) {\small $n_1$};
    \node[main node] (c2) [below left of=c1] {\small $n_2$};
    \node[main node] (c3) [below right of=c1] {\small $n_3$};
    \node[main node, draw=none] (c4) [below right of=c2] {\phantom{\small $n_4$}};
    \path
    (c1) edge [] node {} (c3)
    (c1) edge [] node {} (c2)
    (c3) edge [in=-45,out=315, looseness=1.5] node {} (c2);
    \end{tikzpicture}%
}\quad
\subcaptionbox{\label{fig:ex4}}{%
    \begin{tikzpicture}[baseline=(d1.base),->,>=stealth',shorten >=1pt,auto,node distance=1.24cm, main node/.style={circle,draw}]
    \node[main node] (d1) {\small $n_1$};
    \node[main node] (d2) [below left of=d1] {\small $n_2$};
    \node[main node] (d3) [below right of=d1] {\small $n_3$};
    \node[main node, draw=none] (d4) [below right of=d2] {\phantom{\small $n_4$}};
    \path
    (d1) edge [] node {} (d3)
    (d1) edge [] node {} (d2)
    (d3) edge [in=45,out=315,loop] node {} (d3);
    \end{tikzpicture}%
}\quad
\subcaptionbox{\label{fig:ex5}}{%
    \begin{tikzpicture}[baseline=(e1.base),->,>=stealth',shorten >=1pt,auto,node distance=1.24cm, main node/.style={circle,draw}]
    \node[main node] (e1) {\small $n_1$};
    \node[main node] (e2) [below left of=e1] {\small $n_2$};
    \node[main node] (e3) [below right of=e1] {\small $n_3$};
    \node[main node, dashed] (e4) [below right of=e3] {\small $n_4$};
    \path
    (e1) edge [] node {} (e3)
    (e1) edge [] node {} (e2)
    (e3) edge [in=135,out=315] node {} (e4);
    \end{tikzpicture}%
}
\caption{Steps in Korat exploration to find an extendable candidate vector}
\end{figure*}

\end{document}

aligned alignments

Note that below right of etc. is deprecated. However, maybe tkz-graph still uses it for some reason.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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