2

I have the following figure, containing three subfigures:

My figure

I'm using the following code to produce it/them:

\begin{figure}[htbp]%
\tikzstyle{morpho} = [circle,draw,minimum size=1cm,thick,fill=white,font=\tiny]%
\tikzstyle{grouping} = [thick,rounded corners=5pt,fill=#1!20]%
\pgfmathsetmacro{\O}{0.6}%
\pgfmathsetmacro{\P}{1.5}%
\centering
\begin{subfigure}[b]{0.3\textwidth}
\centering
\begin{tikzpicture}
\coordinate (A)  at (0,0);
\coordinate (O)  at (\P,0);
\coordinate (Sa) at (0,-\P);
\coordinate (Ss) at (\P,-\P);
\draw[grouping=blue]
    ($(A)+(-\O,\O)$) --($(A)+(\O,\O)$)  -- ($(Sa)+(\O,\O)$) --
    ($(Ss)+(\O,\O)$) -- ($(Ss)+(\O,-\O)$) -- ($(Sa)+(-\O,-\O)$) -- cycle;
\draw[grouping=red]
    ($(O)+(-\O,\O)$) -- ($(O)+(\O,\O)$) -- ($(O)+(\O,-\O)$) -- ($(O)+(-\O,-\O)$) -- cycle;
\node[morpho] at (A)  {Agent};
\node[morpho] at (O)  {Patient};
\node[morpho] at (Sa) {Active};
\node[morpho] at (Ss) {Stative};
\end{tikzpicture}
\caption{Nominative-Accusative}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}
\centering
\begin{tikzpicture}
\coordinate (A)  at (0,0);
\coordinate (O)  at (\P,0);
\coordinate (Sa) at (0,-\P);
\coordinate (Ss) at (\P,-\P);
\draw[grouping=red]
    ($(O)+(-\O,\O)$) --($(O)+(\O,\O)$)  -- ($(Ss)+(\O,-\O)$) --
    ($(Sa)+(-\O,-\O)$) -- ($(Sa)+(-\O,\O)$) -- ($(Ss)+(-\O,\O)$) -- cycle;
\draw[grouping=blue]
    ($(A)+(-\O,\O)$) -- ($(A)+(\O,\O)$) -- ($(A)+(\O,-\O)$) -- ($(A)+(-\O,-\O)$) -- cycle;
\node[morpho] at (A)  {Agent};
\node[morpho] at (O)  {Patient};
\node[morpho] at (Sa) {Active};
\node[morpho] at (Ss) {Stative};
\end{tikzpicture}
\caption{Ergative-Absolutive}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}%
\centering
\begin{tikzpicture}
\coordinate (A)  at (0,0);
\coordinate (O)  at (\P,0);
\coordinate (Sa) at (0,-\P);
\coordinate (Ss) at (\P,-\P);
\draw[grouping=red]
    ($(O)+(-\O,\O)$) -- ($(O)+(\O,\O)$) -- ($(O)+(\O,-\O)$) -- ($(O)+(-\O,-\O)$) -- cycle;
\draw[grouping=blue]
    ($(A)+(-\O,\O)$) -- ($(A)+(\O,\O)$) -- ($(A)+(\O,-\O)$) -- ($(A)+(-\O,-\O)$) -- cycle;
\draw[grouping=green]
    ($(Sa)+(-\O,\O)$) --($(Ss)+(\O,\O)$)  -- ($(Ss)+(\O,-\O)$) -- ($(Sa)+(-\O,-\O)$) -- cycle;
\node[morpho] at (A)  {Agent};
\node[morpho] at (O)  {Patient};
\node[morpho] at (Sa) {Active};
\node[morpho] at (Ss) {Stative};
\end{tikzpicture}
\caption{Ergative-Accusative (Tripartite)}
\end{subfigure}
\caption{Morphosyntactic Alignments}
\end{figure}

There are several obvious problems with this. One, the tops of the drawings are not aligned (it looks like LaTeX is aligning to the bottom of the captions). Second, the captions themselves look really ugly. For figure 5.1a, there's the leading space in front of "Nominative-". For figure 5.1c, I think the layout of the text doesn't look very good. Instead of

(c)   Ergative-Accusative
(Tripartite)

I would prefer something like

(c)   Ergative-Accusative
      (Tripartite)

Update:

So thanks to a commenter, I was able to figure out the alignment problem: I had forgotten about the "b" option left in from an example I had originally copy/pasted. Here's what my output looks like now:

enter image description here

I increased the width of each of the subfigures from 0.3 to 0.32 of the textwidth, so there's no line breaking anymore for "Nominative-Accusative." However, I still have the problem with 5.1c. It has the leading space, which looks bad, and I can't figure out how to get it to align as mentioned earlier. I should also mention that I'm using the subcaption package.

  • 2
    It looks to me as the b option to subfigure bottom aligns the subfigures vertically. As the three TikZ pictures look as if they all have the same size, they do not matter for this question. However, it matters how your preamble looks like. (Which class do use? Do you use a package that changes captions? Which package does provide the subfigure environment?) – Qrrbrbirlbel May 28 '16 at 22:24
  • Oh right, that's what the b option does! (I copy and pasted the code originally). I'm using the subcaption package. – Kevin Keith May 28 '16 at 22:26
  • 1
    I'm voting to close this question as off-topic because the problem -- wrong use of positioning option -- was solved by comments. – Zarko May 28 '16 at 22:49
  • 2
    @Zarko You are right but maybe not so fast? There is still the problem of the subcaption. I suggest to reformulate the question so that it only asks after the \subcaption problem. This would also mean to get rid of the whole tikz-pgf stuff and to include the full caption setup, if any. – Qrrbrbirlbel May 28 '16 at 23:00
  • Preferably in the form of a complete minimal example document we can copy-paste-compile to reproduce the issue. @OP You can use images from the mwe package or just dummy text or boxes for the subfigures' contents. – cfr May 28 '16 at 23:06
3

Let me convert my comment to an answer:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{ragged2e}% <-- added package
\usepackage[justification=RaggedRight,
            format=hang]{subcaption}% <-- definition of the subcaption format 

\begin{document}
    \begin{figure}
\tikzset{% <-- \tikzstyle is replaced by \tikzset
  morpho/.style = {circle,draw,thick,
                   fill=white,minimum size=1cm,
                   inner sep=2pt,% <-- changed inner sep
                   font=\scriptsize},% <-- changed font size
grouping/.style = {thick,rounded corners=5pt,fill=#1!20}
        }
\pgfmathsetmacro{\O}{0.6}%
\pgfmathsetmacro{\P}{1.5}%

\begin{subfigure}[t]{0.32\textwidth}% <--- increased size of subfigure
\centering
\begin{tikzpicture}
\coordinate (A)  at (0,0);
\coordinate (O)  at (\P,0);
\coordinate (Sa) at (0,-\P);
\coordinate (Ss) at (\P,-\P);
\draw[grouping=blue]
    ($(A)+(-\O,\O)$) --($(A)+(\O,\O)$)  -- ($(Sa)+(\O,\O)$) --
    ($(Ss)+(\O,\O)$) -- ($(Ss)+(\O,-\O)$) -- ($(Sa)+(-\O,-\O)$) -- cycle;
\draw[grouping=red]
    ($(O)+(-\O,\O)$) -- ($(O)+(\O,\O)$) -- ($(O)+(\O,-\O)$) -- ($(O)+(-\O,-\O)$) -- cycle;
\node[morpho] at (A)  {Agent};
\node[morpho] at (O)  {Patient};
\node[morpho] at (Sa) {Active};
\node[morpho] at (Ss) {Stative};
\end{tikzpicture}
    \caption{Nominative-Accusative}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.32\textwidth}% <--- increased size of subfigure
\centering
\begin{tikzpicture}
\coordinate (A)  at (0,0);
\coordinate (O)  at (\P,0);
\coordinate (Sa) at (0,-\P);
\coordinate (Ss) at (\P,-\P);
\draw[grouping=red]
    ($(O)+(-\O,\O)$) --($(O)+(\O,\O)$)  -- ($(Ss)+(\O,-\O)$) --
    ($(Sa)+(-\O,-\O)$) -- ($(Sa)+(-\O,\O)$) -- ($(Ss)+(-\O,\O)$) -- cycle;
\draw[grouping=blue]
    ($(A)+(-\O,\O)$) -- ($(A)+(\O,\O)$) -- ($(A)+(\O,-\O)$) -- ($(A)+(-\O,-\O)$) -- cycle;
\node[morpho] at (A)  {Agent};
\node[morpho] at (O)  {Patient};
\node[morpho] at (Sa) {Active};
\node[morpho] at (Ss) {Stative};
\end{tikzpicture}
\caption{Ergative-Absolutive}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.32\textwidth}% <--- increased size of subfigure
\centering
\begin{tikzpicture}
\coordinate (A)  at (0,0);
\coordinate (O)  at (\P,0);
\coordinate (Sa) at (0,-\P);
\coordinate (Ss) at (\P,-\P);
\draw[grouping=red]
    ($(O)+(-\O,\O)$) -- ($(O)+(\O,\O)$) -- ($(O)+(\O,-\O)$) -- ($(O)+(-\O,-\O)$) -- cycle;
\draw[grouping=blue]
    ($(A)+(-\O,\O)$) -- ($(A)+(\O,\O)$) -- ($(A)+(\O,-\O)$) -- ($(A)+(-\O,-\O)$) -- cycle;
\draw[grouping=green]
    ($(Sa)+(-\O,\O)$) --($(Ss)+(\O,\O)$)  -- ($(Ss)+(\O,-\O)$) -- ($(Sa)+(-\O,-\O)$) -- cycle;
\node[morpho] at (A)  {Agent};
\node[morpho] at (O)  {Patient};
\node[morpho] at (Sa) {Active};
\node[morpho] at (Ss) {Stative};
\end{tikzpicture}
\caption{Ergative-Accusative (Tripartite)}
\end{subfigure}
\caption{Morphosyntactic Alignments}
    \end{figure}
\end{document}

Above MWE gives:

enter image description here

The formatting of main caption is left to default settings defined in article document class. It can be changed with caption package.

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.