1

I would like to get 3 tikz pictures side by side like these but with captions under each of them:

\documentclass[a4paper,12pt]{article}
\usepackage[a4paper, margin=2cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[spanish,es-tabla]{babel}
\usepackage{tikz}
\usepackage{tkz-tab}
\usepackage{caption}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{subcaption} 
\usetikzlibrary{quotes,angles,babel}

\begin{document}
     \begin{tikzpicture}
        \coordinate (O) at (0,0);
        \draw [->,>=stealth,thick] (0,0) -- (3,0) coordinate (xpos) node[right, at end] {\large{x}};
        \draw [<-,>=stealth,thick] (0,3)coordinate (NM) node[right] {NM} node[left] {y}  -- (0,0) coordinate (SM);
        \draw [->,>=stealth,thick] (O)  -- (-2,-2) coordinate (rumbo);
        \path pic["HDG",draw=red,<-,>=stealth,thick,angle eccentricity=1.2,angle radius=2cm,pic text options={shift={(+.3cm,0)}}] {angle=rumbo--O--NM};
        \path pic["-$\alpha$",draw=blue,<-,>=stealth,thick,angle eccentricity=1.2,angle radius=1cm] {angle=rumbo--O--xpos};
    \end{tikzpicture}
    %\captionof{figure}{$\alpha$=BLA}
    \hspace{1cm}
    \begin{tikzpicture}
        \coordinate (O) at (0,0);
        \draw [->,>=stealth,thick] (0,0) -- (3,0) coordinate (xpos) node[right, at end] {\large{x}};
        \draw [<-,>=stealth,thick] (0,3)coordinate (NM) node[right] {NM} node[left] {y}  -- (0,0) coordinate (SM);
        \draw [->,>=stealth,thick] (O)  -- (-2,2) coordinate (rumbo);
        \path pic["HDG",draw=red,<-,>=stealth,thick,angle eccentricity=1.2,angle radius=2cm,pic text options={shift={(0,1.25cm)}}] {angle=rumbo--O--NM};
        \path pic["$\alpha$",draw=blue,->,>=stealth,thick,angle eccentricity=1.2,angle radius=1cm] {angle=xpos--O--rumbo};
    \end{tikzpicture}
    \hspace{1cm}
    \begin{tikzpicture}
        \coordinate (O) at (0,0);
        \draw [->,>=stealth,thick] (0,0) -- (3,0) coordinate (xpos) node[right, at end] {\large{x}};
        \draw [<-,>=stealth,thick] (0,3)coordinate (NM) node[right] {NM} node[left] {y}  -- (0,0) coordinate (SM);
        \draw [->,>=stealth,thick] (O)  -- (2,2) coordinate (rumbo);
        \draw [->,>=stealth,thick,white] (O)  -- (0,-2.2cm);
        \path pic["\small{HDG}",draw=red,<-,>=stealth,thick,angle eccentricity=1.2,angle radius=2cm] {angle=rumbo--O--NM};
        \path pic["$\alpha$",draw=blue,->,>=stealth,thick,angle eccentricity=1.2,angle radius=1cm] {angle=xpos--O--rumbo};
    \end{tikzpicture}
\end{document}

I have also tried following this answer, but I can't manage to find why \resizebox does not allow my code to compile, I have tried using \graphicx with no luck, also adding % after the {. And if you try to do it without \resizebox, it does not end alligned vertically, ending like this:

enter image description here

Finally as you see in the code (%\captionof{figure}{$\alpha$=BLA}), I have tried using the \captionof solution, but it ends up giving an utterly extrange solution:

enter image description here

2 Answers 2

1

You are already loading subcaption so you may want to use it.

\documentclass[a4paper,12pt]{article}
\usepackage[a4paper, margin=2cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[spanish,es-tabla]{babel}
\usepackage{tikz}
\usepackage{tkz-tab}
\usepackage{caption}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{subcaption} 
\usetikzlibrary{quotes,angles,babel}

\begin{document}
\begin{figure}
\centering
\begin{subfigure}{.34\textwidth}
    \centering
     \begin{tikzpicture}
        \coordinate (O) at (0,0);
        \draw [->,>=stealth,thick] (0,0) -- (3,0) coordinate (xpos) node[right, at end] {\large{x}};
        \draw [<-,>=stealth,thick] (0,3)coordinate (NM) node[right] {NM} node[left] {y}  -- (0,0) coordinate (SM);
        \draw [->,>=stealth,thick] (O)  -- (-2,-2) coordinate (rumbo);
        \path pic["HDG",draw=red,<-,>=stealth,thick,angle eccentricity=1.2,angle radius=2cm,pic text options={shift={(+.3cm,0)}}] {angle=rumbo--O--NM};
        \path pic["-$\alpha$",draw=blue,<-,>=stealth,thick,angle eccentricity=1.2,angle radius=1cm] {angle=rumbo--O--xpos};
    \end{tikzpicture}
    \caption{$\alpha$=BLA}
\end{subfigure}
\hfill
\begin{subfigure}{.34\textwidth}
    \centering
    \begin{tikzpicture}
        \coordinate (O) at (0,0);
        \draw [->,>=stealth,thick] (0,0) -- (3,0) coordinate (xpos) node[right, at end] {\large{x}};
        \draw [<-,>=stealth,thick] (0,3)coordinate (NM) node[right] {NM} node[left] {y}  -- (0,0) coordinate (SM);
        \draw [->,>=stealth,thick] (O)  -- (-2,2) coordinate (rumbo);
        \path pic["HDG",draw=red,<-,>=stealth,thick,angle eccentricity=1.2,angle radius=2cm,pic text options={shift={(0,1.25cm)}}] {angle=rumbo--O--NM};
        \path pic["$\alpha$",draw=blue,->,>=stealth,thick,angle eccentricity=1.2,angle radius=1cm] {angle=xpos--O--rumbo};
    \end{tikzpicture}
    \caption{$\alpha$=PFT}
\end{subfigure}
\hfill
\begin{subfigure}{.27\textwidth}
    \centering
    \begin{tikzpicture}
        \coordinate (O) at (0,0);
        \draw [->,>=stealth,thick] (0,0) -- (3,0) coordinate (xpos) node[right, at end] {\large{x}};
        \draw [<-,>=stealth,thick] (0,3)coordinate (NM) node[right] {NM} node[left] {y}  -- (0,0) coordinate (SM);
        \draw [->,>=stealth,thick] (O)  -- (2,2) coordinate (rumbo);
        \draw [->,>=stealth,thick,white] (O)  -- (0,-2.2cm);
        \path pic["\small{HDG}",draw=red,<-,>=stealth,thick,angle eccentricity=1.2,angle radius=2cm] {angle=rumbo--O--NM};
        \path pic["$\alpha$",draw=blue,->,>=stealth,thick,angle eccentricity=1.2,angle radius=1cm] {angle=xpos--O--rumbo};
    \end{tikzpicture}
    \caption{$\alpha$=BLUB}
\end{subfigure}
\caption{Meow.}
\end{figure}    
\end{document}

enter image description here

2
  • Oh, will try first thing in the morning. Hope you are healthy. Thanks! Also, is there a way not to show the (a). (b) and (c)?
    – ElSabio
    Commented Mar 19, 2020 at 23:08
  • The easiest way is to NOT use a caption. \node[below] at (current bounding box.south) {...}; should do it. Commented Mar 20, 2020 at 14:53
0

If you want these figures to be labelled as figures (not subfigures) you can use the floatrow environment:

    \documentclass[a4paper,12pt]{article}
    \usepackage[a4paper, margin=2cm]{geometry}
    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
    \usepackage[spanish,es-tabla, es-noshorthands]{babel}
    \usepackage{tikz}
    \usepackage{tkz-tab}
    \usepackage{caption}
    \usepackage{latexsym}
    \usepackage{amssymb}
    \usepackage{amsmath}
    \usepackage{subcaption}
    \usetikzlibrary{quotes,angles,babel}
    \usepackage{floatrow}

    \begin{document}

    \begin{figure}
    \begin{floatrow}[3]
    \ffigbox[\FBwidth]{\caption{$\alpha$=BLA}\label{bla}}{%
         \begin{tikzpicture}
            \coordinate (O) at (0,0);
            \draw [->,>=stealth,thick] (0,0) -- (3,0) coordinate (xpos) node[right, at end] {\large{x}};
            \draw [<-,>=stealth,thick] (0,3)coordinate (NM) node[right] {NM} node[left] {y} -- (0,0) coordinate (SM);
            \draw [->,>=stealth,thick] (O) -- (-2,-2) coordinate (rumbo);
            \path pic["HDG",draw=red,<-,>=stealth,thick,angle eccentricity=1.2,angle radius=2cm,pic text options={shift={(+.3cm,0)}}] {angle=rumbo--O--NM};
            \path pic["-$\alpha$",draw=blue,<-,>=stealth,thick,angle eccentricity=1.2,angle radius=1cm] {angle=rumbo--O--xpos};
        \end{tikzpicture}}%
    %
    \ffigbox[\FBwidth]{\caption{$\beta$=BLI}\label{bli}}{%
        \begin{tikzpicture}
            \coordinate (O) at (0,0);
            \draw [->,>=stealth,thick] (0,0) -- (3,0) coordinate (xpos) node[right, at end] {\large{x}};
            \draw [<-,>=stealth,thick] (0,3)coordinate (NM) node[right] {NM} node[left] {y} -- (0,0) coordinate (SM);
            \draw [->,>=stealth,thick] (O) -- (-2,2) coordinate (rumbo);
            \path pic["HDG",draw=red,<-,>=stealth,thick,angle eccentricity=1.2,angle radius=2cm,pic text options={shift={(0,1.25cm)}}] {angle=rumbo--O--NM};
            \path pic["$\alpha$",draw=blue,->,>=stealth,thick,angle eccentricity=1.2,angle radius=1cm] {angle=xpos--O--rumbo};
        \end{tikzpicture}}%
        %
    \ffigbox[\FBwidth]{\caption{$\gamma$=BLO}\label{blo}}{%
        \begin{tikzpicture}
            \coordinate (O) at (0,0);
            \draw [->,>=stealth,thick] (0,0) -- (3,0) coordinate (xpos) node[right, at end] {\large{x}};
            \draw [<-,>=stealth,thick] (0,3)coordinate (NM) node[right] {NM} node[left] {y} -- (0,0) coordinate (SM);
            \draw [->,>=stealth,thick] (O) -- (2,2) coordinate (rumbo);
            \draw [->,>=stealth,thick,white] (O) -- (0,-2.2cm);
            \path pic["\small{HDG}",draw=red,<-,>=stealth,thick,angle eccentricity=1.2,angle radius=2cm] {angle=rumbo--O--NM};
            \path pic["$\alpha$",draw=blue,->,>=stealth,thick,angle eccentricity=1.2,angle radius=1cm] {angle=xpos--O--rumbo};
        \end{tikzpicture}}%
       % \hspace{1cm}
    \end{floatrow}
    \end{figure}

    \end{document} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .