Creating figure with 4 subcaptions

109 views
Skip to first unread message

Filipa Carvalho

unread,
Oct 2, 2019, 3:37:05 PM10/2/19
to NOVAthesis
Hey,

I'd like to create a figure with 4 subcaptions. Ideally, they would be a 2x2 matrix. This is code I am using:

\begin{figure}[htbp]
    \centering
    \subbottom[Transverse LET deposition at z = 105 cm.] {%
        \label{fig:energy_depo_v3_fibres_105}
        \includegraphics[width=0.5\linewidth]{Chapters/Figures/Energy_Dist_v3.pdf}
    }
    \subbottom[Transverse LET deposition at z = 115 cm.] {%
        \label{fig:energy_depo_v3_fibres_115}
        \includegraphics[width=0.5\linewidth]{Chapters/Figures/Energy_Dist_v3.pdf}
    }
    \subbottom[Transverse LET deposition at z = 124 cm.] {%
        \label{fig:energy_depo_v3_fibres_124}
        \includegraphics[width=0.5\linewidth]{Chapters/Figures/Energy_Dist_v3.pdf}
    }
    \subbottom[Transverse LET deposition at z = 126 cm.] {%
        \label{fig:energy_depo_v3_fibres_126}
        \includegraphics[width=0.5\linewidth]{Chapters/Figures/Energy_Dist_v3.pdf}
    }
  \caption{Set of graphs of the transverse energy deposition for 200 MeV in the third simulation setup along the Bragg curve.}
  \label{fig:energy_depo_v3_fibres}
\end{figure}

Sadly the figures come out as a 4x1 figure. Is there any quick fix to this? Thanks!

Joao Lourenco

unread,
Oct 2, 2019, 3:41:23 PM10/2/19
to NOVAthesis
Tray adding "\\" after the "}" closing the definition of the second subfigure.
Let me know if it worked.
João L.

Filipa Carvalho

unread,
Oct 2, 2019, 5:06:30 PM10/2/19
to Joao Lourenco, NOVAthesis
\begin{figure}[htbp]
\centering
    \subbottom[Transverse LET deposition at z = 105 cm.] {%
\label{fig:energy_depo_v3_fibres_105}
\includegraphics[width=0.5\linewidth]{Chapters/Figures/Energy_Dist_v3.pdf}
    }
    \subbottom[Transverse LET deposition at z = 115 cm.] {%
\label{fig:energy_depo_v3_fibres_115}
\includegraphics[width=0.5\linewidth]{Chapters/Figures/Energy_Dist_v3.pdf}
    } \\
    \subbottom[Transverse LET deposition at z = 124 cm.] {%
\label{fig:energy_depo_v3_fibres_124}
\includegraphics[width=0.5\linewidth]{Chapters/Figures/Energy_Dist_v3.pdf}
    }
    \subbottom[Transverse LET deposition at z = 126 cm.] {%
\label{fig:energy_depo_v3_fibres_126}
\includegraphics[width=0.5\linewidth]{Chapters/Figures/Energy_Dist_v3.pdf}
    }
  \caption{Set of graphs of the transverse energy deposition for 200 MeV in the third simulation setup along the Bragg curve.}
  \label{fig:energy_depo_v3_fibres}
\end{figure}

Like this? Stayed the same :(

--
You received this message because you are subscribed to the Google Groups "NOVAthesis" group.
To unsubscribe from this group and stop receiving emails from it, send an email to novathesis+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/novathesis/9adcad8c-f8ba-4c8e-ab9f-4596da0683f7%40googlegroups.com.


--
logo   
Filipa Carvalho
Knowledge Management & Vivaldi Responsible
Grupo Local BEST Almada
Universidade Nova de Lisboa - Faculdade de Ciências e Tecnologia
+351 91 359 32 35 BESTAlmada.org 
      

Joao Lourenco

unread,
Oct 3, 2019, 10:58:30 AM10/3/19
to NOVAthesis
Try creating a tabular with 2x2 cells and have a subfigure in each one:

\begin{tabular*}{\textwidth}{@{}cc@{}}
    \subbottom[Transverse LET deposition at z = 105 cm.] {%
\label{fig:energy_depo_v3_fibres_105}
\includegraphics[width=0.5\linewidth]{Chapters/Figures/Energy_Dist_v3.pdf}
    } &

    \subbottom[Transverse LET deposition at z = 115 cm.] {%
\label{fig:energy_depo_v3_fibres_115}
\includegraphics[width=0.5\linewidth]{Chapters/Figures/Energy_Dist_v3.pdf}
    } \\
    \subbottom[Transverse LET deposition at z = 124 cm.] {%
\label{fig:energy_depo_v3_fibres_124}
\includegraphics[width=0.5\linewidth]{Chapters/Figures/Energy_Dist_v3.pdf}
    } &

    \subbottom[Transverse LET deposition at z = 126 cm.] {%
\label{fig:energy_depo_v3_fibres_126}
\includegraphics[width=0.5\linewidth]{Chapters/Figures/Energy_Dist_v3.pdf}
    }
\end{tabular*}
 
and check if it works for you!

If it does not, please create a minimal example that is failing:

\documentclass{memoir}
\usepackage{graphicx}
\begin{document}
your code for subfigures here
\end{document}

And post it here?  Together with the images attached?!  So that I can experiment and check wha is happening!

João L.

On Wednesday, October 2, 2019 at 10:06:30 PM UTC+1, Filipa Carvalho wrote:
\begin{figure}[htbp]
\centering
    \subbottom[Transverse LET deposition at z = 105 cm.] {%
\label{fig:energy_depo_v3_fibres_105}
\includegraphics[width=0.5\linewidth]{Chapters/Figures/Energy_Dist_v3.pdf}
    }
    \subbottom[Transverse LET deposition at z = 115 cm.] {%
\label{fig:energy_depo_v3_fibres_115}
\includegraphics[width=0.5\linewidth]{Chapters/Figures/Energy_Dist_v3.pdf}
    } \\
    \subbottom[Transverse LET deposition at z = 124 cm.] {%
\label{fig:energy_depo_v3_fibres_124}
\includegraphics[width=0.5\linewidth]{Chapters/Figures/Energy_Dist_v3.pdf}
    }
    \subbottom[Transverse LET deposition at z = 126 cm.] {%
\label{fig:energy_depo_v3_fibres_126}
\includegraphics[width=0.5\linewidth]{Chapters/Figures/Energy_Dist_v3.pdf}
    }
  \caption{Set of graphs of the transverse energy deposition for 200 MeV in the third simulation setup along the Bragg curve.}
  \label{fig:energy_depo_v3_fibres}
\end{figure}

Like this? Stayed the same :(

To unsubscribe from this group and stop receiving emails from it, send an email to novathesis+unsubscribe@googlegroups.com.

Filipa Carvalho

unread,
Oct 3, 2019, 11:11:30 AM10/3/19
to Joao Lourenco, NOVAthesis
\documentclass[
  docdegree=msc,        % phd(*), phdplan, phdprop, msc, mscplan, bsc
  school=nova/fct,      % nova/fct(*), nova/fcsh, nova/ims, ul/ist, ul/fc
  lang=en,              % en(*), fr, it, pt
  coverlang=en,         % defaults to main language
  copyrightlang=en,     % defaults to main language
  fontstyle=kpfonts,    % baskervaldx bookman charter ebgaramond fbb fourier garamond
                        % heuristica kpfonts(*) libertine mathpazo1 mathpazo2 newcent
                        % newpx newtx
  chapstyle=elegant,    % bianchi bluebox brotherton dash default elegant(*) ell ger
                        % hansen ist jenor lyhne madsen pedersen veelo vz14 vz34 vz43
  otherlistsat=front,   % front(*), back
  aftercover=false,     % false=don't true=include the aftercover file (even if exists)
  linkscolor=darkblue,  % darkblue, black (Set to 'black' for PRINTING)
  printcommittee=false,  % set to 'false' from submitted versins who should not have
                        % the list of committee memebers
  spine=false,          % (Set to 'true' for PRINTING the book spine)
  cdcover=false,         % (Set to 'true' for PRINTING the CD cover)
  biblatex={            % Options for biblatex (see biblatex documentation)
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%% uncomment for 'apa' like citations
    % backend=biber,    % must use biber as the backend (and not bibtex)
    % natbib=true,      % compatiblity with natbib (use \cite{…} or \citep{…})
    % style=apa,        % APA style
    % maxcitenames=2,   % use at most two names in citation
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%% uncomment for 'numeric-by-order-of-citation' like citations
    backend=bibtex,     % use bibtex if possible
    style=numeric-comp, % numeric(*), alphabetic, authoryear, bwl-FU
    sortcites=true,     % If numeric, sort cites by crescent order
    sorting=none,       % none, nyt(*), ynt
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%% uncomment for 'numeric-by-order-of-citation' like citations
    %backend=bibtex,     % use bibtex if possible
    %style=numeric-comp, % numeric(*), alphabetic, authoryear, bwl-FU
    %sortcites=true,     % If numeric, sort cites by crescent order
    %sorting=nyt,        % none, nyt(*), ynt
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%% uncomment for 'numeric-by-order-of-citation' like citations
    % backend=bibtex,   % use bibtex if possible
    % style=alphabetic, % numeric(*), alphabetic, authoryear, bwl-FU
    % sorting=nyt,      % none, nyt(*), ynt
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%% other options for biblatex
    maxbibnames=99,     % Never use 'et al' in the bibliography
    giveninits=true,    % render all first and middle names as initials
    hyperref=true       % Hyperlinks in citations: true(*) false
  },
  memoir={              % See the 'memoir' documentation
    % showtrims,          % DEBUG
    a4paper,            % the paper size/format
    11pt,               % 10pt, 11pt(*), 12pt
    final,              % draft, final  <= Replace 'draft' with 'final' in final version
  },
  media=screen,         % screen(*), paper
          % behavior to be defined in school options based in "\novathesis@opt@media"
          % definitions for screen: left and right margins are equal, colored links
          % definitions for paper: left and right margins are different, black links
]{novathesis}

%% VERY IMPORTANT
\usepackage{booktabs}    % Beautiful simple tables
\usepackage{paralist}    % To enable customizble enumerates

%%TABLES PACKAGES
\usepackage{adjustbox}   %adjusts table to margins of document
\usepackage{multirow}

%%FiGURES PACKAGES

%%CHEMICAL WRITING

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
 
\usepackage{chemfig}

%%UPLOAD PDF TO DOCUMENT
\usepackage{pdfpages}

%%TABLES
\usepackage{longtable}
\usepackage{graphicx}
\usepackage{makecell}

%colouring

%%FIGURES
\usepackage{caption}
\usepackage{subcaption}

\begin{document}
...
\begin{figure}[htbp]
\centering
    \subbottom[Graphical representation of the transverse LET deposition at z = 105 cm.] {%

\label{fig:energy_depo_v3_fibres_105}
\includegraphics[width=0.5\linewidth]{Chapters/Figures/Energy_Dist_v3.pdf}
    }
    \subbottom[Graphical representation of the transverse LET deposition at z = 115 cm.] {%

\label{fig:energy_depo_v3_fibres_115}
\includegraphics[width=0.5\linewidth]{Chapters/Figures/Energy_Dist_v3.pdf}
    } \\
    \subbottom[Graphical representation of the transverse LET deposition at z = 124 cm.] {%

\label{fig:energy_depo_v3_fibres_124}
\includegraphics[width=0.5\linewidth]{Chapters/Figures/Energy_Dist_v3.pdf}
    }
    \subbottom[Graphical representation of the transverse LET deposition at z = 126 cm.] {%

\label{fig:energy_depo_v3_fibres_126}
\includegraphics[width=0.5\linewidth]{Chapters/Figures/Energy_Dist_v3.pdf}
    }
  \caption{Set of graphs of the transverse energy deposition for 200 MeV in the third simulation setup along the Bragg curve.}
  \label{fig:energy_depo_v3_fibres}
\end{figure}

\end{document}

The code I have almost works - it just does not put the figures the way i want it. From my last days experience, I believe it has to do with the way the main.tex file is designed, leading to errors, i.e., when using subcaption package. I attached one of the pics, they are all pretty much the same, just I haven't created the plots yet.

Thanks

To unsubscribe from this group and stop receiving emails from it, send an email to novathesis+...@googlegroups.com.


--
logo   
Filipa Carvalho
Knowledge Management & Vivaldi Responsible
Grupo Local BEST Almada
Universidade Nova de Lisboa - Faculdade de Ciências e Tecnologia
+351 91 359 32 35 BESTAlmada.org 
      

--
You received this message because you are subscribed to the Google Groups "NOVAthesis" group.
To unsubscribe from this group and stop receiving emails from it, send an email to novathesis+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/novathesis/1a3f8a0a-08e7-4e13-8b13-24603cd4984a%40googlegroups.com.
Energy_Dist_v3.pdf

Filipa Carvalho

unread,
Oct 3, 2019, 11:17:46 AM10/3/19
to Joao Lourenco, NOVAthesis
Ok i tried minizing the image as much as possible and when I put the image super small it does what I want!

image.png

Joao Lourenco

unread,
Oct 3, 2019, 11:25:44 AM10/3/19
to NOVAthesis
This shall work (it did for me)!  :)
Note the "%" immediately following the "}" in the first and their subbottom command.
The problem was that fig 1.1 was 50% of line width and Fig 1.2 50% as well.
But you had a new-line between Fig1 and Fig2, which in LaTeX is converted to a space.
And the following sequence <Fig1><space><Fig2> was slightly wider than \linewidth, and LaTeX was putting Fig2 below Fig1 instead of side-by-side.

    \subbottom[Graphical representation of the transverse LET deposition at z = 105 cm.] {%
\label{fig:energy_depo_v3_fibres_105}
\includegraphics[width=0.5\linewidth]{Energy_Dist_v3.pdf}
    }%
    \subbottom[Graphical representation of the transverse LET deposition at z = 115 cm.] {%
\label{fig:energy_depo_v3_fibres_115}
\includegraphics[width=0.5\linewidth]{Energy_Dist_v3.pdf}
    } \\
    \subbottom[Graphical representation of the transverse LET deposition at z = 124 cm.] {%
\label{fig:energy_depo_v3_fibres_124}
\includegraphics[width=0.5\linewidth]{Energy_Dist_v3.pdf}
    }%
    \subbottom[Graphical representation of the transverse LET deposition at z = 126 cm.] {%
\label{fig:energy_depo_v3_fibres_126}
\includegraphics[width=0.5\linewidth]{Energy_Dist_v3.pdf}
    }
  \caption{Set of graphs of the transverse energy deposition for 200 MeV in the third simulation setup along the Bragg curve.}
  \label{fig:energy_depo_v3_fibres}
\end{figure}

Cheers,
João L.
To unsubscribe from this group and stop receiving emails from it, send an email to novathesis+unsubscribe@googlegroups.com.


--
logo   
Filipa Carvalho
Knowledge Management & Vivaldi Responsible
Grupo Local BEST Almada
Universidade Nova de Lisboa - Faculdade de Ciências e Tecnologia
+351 91 359 32 35 BESTAlmada.org 
      

--
You received this message because you are subscribed to the Google Groups "NOVAthesis" group.
To unsubscribe from this group and stop receiving emails from it, send an email to novathesis+unsubscribe@googlegroups.com.

Filipa Carvalho

unread,
Oct 3, 2019, 11:31:46 AM10/3/19
to Joao Lourenco, NOVAthesis
Thanks for the help :)

To unsubscribe from this group and stop receiving emails from it, send an email to novathesis+...@googlegroups.com.


--
logo   
Filipa Carvalho
Knowledge Management & Vivaldi Responsible
Grupo Local BEST Almada
Universidade Nova de Lisboa - Faculdade de Ciências e Tecnologia
+351 91 359 32 35 BESTAlmada.org 
      

--
You received this message because you are subscribed to the Google Groups "NOVAthesis" group.
To unsubscribe from this group and stop receiving emails from it, send an email to novathesis+...@googlegroups.com.


--
logo   
Filipa Carvalho
Knowledge Management & Vivaldi Responsible
Grupo Local BEST Almada
Universidade Nova de Lisboa - Faculdade de Ciências e Tecnologia
+351 91 359 32 35 BESTAlmada.org 
      

--
You received this message because you are subscribed to the Google Groups "NOVAthesis" group.
To unsubscribe from this group and stop receiving emails from it, send an email to novathesis+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/novathesis/a1bb3aa9-148d-43bb-a4bb-139fd3eb4864%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages