[Tex/LaTex] Subfigures in MDPI template Overleaf

floatsmdpisubcaption

I've been trying to deploy subfigures in the MDPI article template using the subcaption package , however every time I attempt to deploy it , the figures overlap with the captionenter image description here

Here is my tex file

\begin{figure}[ht ]
 \centering
   \begin{subfigure}[t]{0.2\textwidth}
       \centering
       \includegraphics[height=1.2in]{frog.jpg}
       \caption{Subfigure 1}
   \end{subfigure}%
   ~
  \begin{subfigure}[t]{0.2\textwidth}
       \centering
       \includegraphics[height=1.2in]{frog.jpg}
       \caption{Subfigure 1}
   \end{subfigure}
   ~
   \begin{subfigure}[t]{0.2\textwidth}
       \centering
       \includegraphics[height=1.2in]{frog.jpg}
       \caption{Subfigure 2}
   \end{subfigure}
   ~
   \begin{subfigure}[t]{0.2\textwidth}
       \centering
       \includegraphics[height=1.2in]{frog.jpg}
       \caption{Subfigure 3}
   \end{subfigure}
   ~
   \begin{subfigure}[t]{0.2\textwidth}
       \centering
       \includegraphics[height=1.2in]{frog.jpg}
       \caption{Subfigure 4}
   \end{subfigure}
   ~
   \begin{subfigure}[t]{0.2\textwidth}
       \centering
       \includegraphics[height=1.2in]{frog.jpg}
       \caption{Subfigure 5}
   \end{subfigure}
   ~
   \begin{subfigure}[t]{0.2\textwidth}
       \centering
       \includegraphics[height=1.2in]{frog.jpg}
       \caption{Subfigure 6}
   \end{subfigure}
   ~
   \begin{subfigure}[t]{0.2\textwidth}
       \centering
       \includegraphics[height=1.2in]{frog.jpg}
       \caption{Subfigure 7}
   \end{subfigure}
   ~
   \begin{subfigure}[t]{0.2\textwidth}
       \centering
       \includegraphics[height=1.2in]{frog.jpg}
       \caption{Subfigure 8}
   \end{subfigure}
    ~
   \begin{subfigure}[t]{0.2\textwidth}
       \centering
       \includegraphics[height=1.2in]{frog.jpg}
       \caption{Subfigure 9}
   \end{subfigure}
   \caption{Data Figures\label{dataex}}

\end{figure}```

Best Answer

I assume you downloaded the class mdpi and put it in a new directory. It should have a file template.tex and a Definitions subdirectory.

The class mdpi defines \captionsetup for figure but not for subfigure.

Using a short template.tex and adding the package subcaption and \captionsetup[sub]{...} with the same style defined for figures, the issue is solved.

a

Code for [26/08/2021 MDPI paper class]

    % !TeX TS-program = pdflatex
    
    %=================================================================
    \documentclass[journal,article,submit,moreauthors,pdftex]{Definitions/mdpi} %[26/08/2021 MDPI paper class]
    %=================================================================

    \usepackage{subcaption} % added<<<<<<<<<<<

    \captionsetup[sub]{position=bottom,
        labelfont={bf, small, stretch=1.17},
        labelsep=space,
        textfont={small, stretch=1.5},
        aboveskip=6pt, 
        belowskip=6pt,
        singlelinecheck=off,
        justification=justified}        
    
    % MDPI internal commands
    \firstpage{1} 
    \makeatletter 
    \setcounter{page}{\@firstpage} 
    \makeatother
    \pubvolume{1}
    \issuenum{1}
    \articlenumber{0}
    %\doinum{}
    \pubyear{2021}
    \copyrightyear{2020}
    %\externaleditor{Academic Editor: Firstname Lastname} % For journal Automation, please change Academic Editor to "Communicated by"
    \datereceived{} 
    \dateaccepted{} 
    \datepublished{} 
    \hreflink{https://doi.org/} % If needed use \linebreak
    %------------------------------------------------------------------
    
    % Full title of the paper (Capitalized)
    \Title{Title}
    
    % MDPI internal command: Title for citation in the left column
    \TitleCitation{Title}
    
    % Author Orchid ID: enter ID or remove command
    \newcommand{\orcidauthorA}{0000-0000-0000-000X} % Add \orcidA{} behind the author's name
    
    % Authors, for the paper (add full first names)
    \Author{Firstname Lastname $^{1,\dagger,\ddagger}$\orcidA{}, Firstname Lastname $^{1,\ddagger}$ and Firstname Lastname $^{2,}$*}
    
    % MDPI internal command: Authors, for metadata in PDF
    \AuthorNames{Firstname Lastname, Firstname Lastname and Firstname Lastname}
    
    % MDPI internal command: Authors, for citation in the left column
    \AuthorCitation{Lastname, F.; Lastname, F.; Lastname, F.}
    % If this is a Chicago style journal: Lastname, Firstname, Firstname Lastname, and Firstname Lastname.
    
    % Affiliations / Addresses (Add [1] after \address if there is only one affiliation.)
    \address{%
    $^{1}$ \quad Affiliation 1; e-mail@e-mail.com\\
    $^{2}$ \quad Affiliation 2; e-mail@e-mail.com}
    
    % Contact information of the corresponding author
    \corres{Correspondence: e-mail@e-mail.com; Tel.: (optional; include country code; if there are multiple corresponding authors, add author initials) +xx-xxxx-xxx-xxxx (F.L.)}
    
    % Current address and/or shared authorship
    \firstnote{Current address: Affiliation 3} 
    \secondnote{These authors contributed equally to this work.}
    
    % Abstract (Do not insert blank lines, i.e. \\) 
    \abstract{A single paragraph of about 200 words maximum. For research articles, abstracts should give a pertinent overview of the work. We strongly encourage authors to use the following style of structured abstracts, but without headings: (1) Background: place the question addressed in a broad context and highlight the purpose of the study; (2) Methods: describe briefly the main methods or treatments applied; (3) Results: summarize the article's main findings; (4) Conclusion: indicate the main conclusions or interpretations. The abstract should be an objective representation of the article, it must not contain results which are not presented and substantiated in the main text and should not exaggerate the main conclusions.}
    
    % Keywords
    \keyword{keyword 1; keyword 2; keyword 3 (List three to ten pertinent keywords specific to the article; yet reasonably common within the subject discipline.)} 
    
    
    \begin{document}
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \setcounter{section}{-1} %% Remove this when starting to work on the template.
    \section{How to Use this Template}
    
    The template details the sections that can be used in a manuscript. Note that the order and names of article sections may differ from the requirements of the journal (e.g., the positioning of the Materials and Methods section). Please check the instructions on the authors' page of the journal to verify the correct order and names. For any questions, please contact the editorial office of the journal or support@mdpi.com. For LaTeX-related questions please contact latex@mdpi.com.
    
    \section{Introduction}
    
    The introduction should briefly place the study in a broad context and highlight why it is important. It should define the purpose of the work and its significance. The current state of the research field should be reviewed carefully and key publications cited. Please highlight controversial and diverging hypotheses when necessary. Finally, briefly mention the main aim of the work and highlight the principal conclusions. As far as possible, please keep the introduction comprehensible to scientists outside your particular field of research. 

    \begin{figure}[ht ]
        \centering
        \begin{subfigure}[t]{0.2\textwidth}
    %           \centering
            \includegraphics[height=1.2in]{example-grid-100x100pt}
            \caption{Subfigure 1}
        \end{subfigure}%
        ~
        \begin{subfigure}[t]{0.2\textwidth}
    %           \centering
            \includegraphics[height=1.2in]{example-grid-100x100pt}
            \caption{Subfigure 2}
        \end{subfigure}
        ~
        \begin{subfigure}[t]{0.2\textwidth}
    %           \centering
            \includegraphics[height=1.2in]{example-grid-100x100pt}
            \caption{Subfigure 3}
        \end{subfigure}
        ~
        \begin{subfigure}[t]{0.2\textwidth}
    %           \centering
            \includegraphics[height=1.2in]{example-grid-100x100pt}
            \caption{Subfigure 4}
        \end{subfigure}
        ~
        \begin{subfigure}[t]{0.2\textwidth}
    %           \centering
            \includegraphics[height=1.2in]{example-grid-100x100pt}
            \caption{Subfigure 5}
        \end{subfigure}
        ~
        \begin{subfigure}[t]{0.2\textwidth}
    %           \centering
            \includegraphics[height=1.2in]{example-grid-100x100pt}
            \subcaption{Subfigure 6}
        \end{subfigure}
        ~
        \begin{subfigure}[t]{0.2\textwidth}
    %           \centering
            \includegraphics[height=1.2in]{example-grid-100x100pt}
            \subcaption{Subfigure 7}
        \end{subfigure}
        ~
        \begin{subfigure}[t]{0.2\textwidth}
    %           \centering
            \includegraphics[height=1.2in]{example-grid-100x100pt}
            \subcaption{Subfigure 8}
        \end{subfigure}
        ~
        \begin{subfigure}[t]{0.2\textwidth}
    %           \centering
            \includegraphics[height=1.2in]{example-grid-100x100pt}
            \subcaption{Subfigure 9}
        \end{subfigure}
        ~
        \begin{subfigure}[t]{0.2\textwidth}
    %           \centering
            \includegraphics[height=1.2in]{example-grid-100x100pt}
            \subcaption{Subfigure 10}
        \end{subfigure}
        \caption{Data Figures For journal Automation, \\ please change Academic Editor to "Communicated by" \label{dataex}}
        
    \end{figure}

    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \end{paracol} % needed <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

    \end{document}

UPDATE [20/12/2021 MDPI paper class]

Now the class MDPI loads the package subfigure.

The complete code to get the above figure is

    % !TeX TS-program = pdflatex        
    %=================================================================
    \documentclass[journal,article,submit,moreauthors,pdftex]{Definitions/mdpi} % version [20/12/2021 MDPI paper class] <<<<<<<<<<<<        
    %=================================================================

    % MDPI internal commands
    \firstpage{1} 
    \makeatletter 
    \setcounter{page}{\@firstpage} 
    \makeatother
    \pubvolume{1}
    \issuenum{1}
    \articlenumber{0}
    %\doinum{}
    \pubyear{2021}
    \copyrightyear{2020}
    %\externaleditor{Academic Editor: Firstname Lastname} % For journal Automation, please change Academic Editor to "Communicated by"
    \datereceived{} 
    \dateaccepted{} 
    \datepublished{} 
    \hreflink{https://doi.org/} % If needed use \linebreak
    %------------------------------------------------------------------
    
    % Full title of the paper (Capitalized)
    \Title{Title}
    
    % MDPI internal command: Title for citation in the left column
    \TitleCitation{Title}
    
    % Author Orchid ID: enter ID or remove command
    \newcommand{\orcidauthorA}{0000-0000-0000-000X} % Add \orcidA{} behind the author's name
    
    % Authors, for the paper (add full first names)
    \Author{Firstname Lastname $^{1,\dagger,\ddagger}$\orcidA{}, Firstname Lastname $^{1,\ddagger}$ and Firstname Lastname $^{2,}$*}
    
    % MDPI internal command: Authors, for metadata in PDF
    \AuthorNames{Firstname Lastname, Firstname Lastname and Firstname Lastname}
    
    % MDPI internal command: Authors, for citation in the left column
    \AuthorCitation{Lastname, F.; Lastname, F.; Lastname, F.}
    % If this is a Chicago style journal: Lastname, Firstname, Firstname Lastname, and Firstname Lastname.
    
    % Affiliations / Addresses (Add [1] after \address if there is only one affiliation.)
    \address{%
    $^{1}$ \quad Affiliation 1; e-mail@e-mail.com\\
    $^{2}$ \quad Affiliation 2; e-mail@e-mail.com}
    
    % Contact information of the corresponding author
    \corres{Correspondence: e-mail@e-mail.com; Tel.: (optional; include country code; if there are multiple corresponding authors, add author initials) +xx-xxxx-xxx-xxxx (F.L.)}
    
    % Current address and/or shared authorship
    \firstnote{Current address: Affiliation 3} 
    \secondnote{These authors contributed equally to this work.}
    
    % Abstract (Do not insert blank lines, i.e. \\) 
    \abstract{A single paragraph of about 200 words maximum. For research articles, abstracts should give a pertinent overview of the work. We strongly encourage authors to use the following style of structured abstracts, but without headings: (1) Background: place the question addressed in a broad context and highlight the purpose of the study; (2) Methods: describe briefly the main methods or treatments applied; (3) Results: summarize the article's main findings; (4) Conclusion: indicate the main conclusions or interpretations. The abstract should be an objective representation of the article, it must not contain results which are not presented and substantiated in the main text and should not exaggerate the main conclusions.}
    
    % Keywords
    \keyword{keyword 1; keyword 2; keyword 3 (List three to ten pertinent keywords specific to the article; yet reasonably common within the subject discipline.)} 
    
    
    \begin{document}
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \setcounter{section}{-1} %% Remove this when starting to work on the template.
    \section{How to Use this Template}
    
    The template details the sections that can be used in a manuscript. Note that the order and names of article sections may differ from the requirements of the journal (e.g., the positioning of the Materials and Methods section). Please check the instructions on the authors' page of the journal to verify the correct order and names. For any questions, please contact the editorial office of the journal or support@mdpi.com. For LaTeX-related questions please contact latex@mdpi.com.
    
    \section{Introduction}
    
    The introduction should briefly place the study in a broad context and highlight why it is important. It should define the purpose of the work and its significance. The current state of the research field should be reviewed carefully and key publications cited. Please highlight controversial and diverging hypotheses when necessary. Finally, briefly mention the main aim of the work and highlight the principal conclusions. As far as possible, please keep the introduction comprehensible to scientists outside your particular field of research. 
    
    
    \begin{figure}%
    \centering  
    \label{fig:first}%
        \subfigure[Subfigure 1.\label{fig:firstA}]{\includegraphics[height=1.2in]{example-grid-100x100pt}}%
        \hfill
        \subfigure[Subfigure 2.\label{fig:firstB}]{\includegraphics[height=1.2in]{example-grid-100x100pt}}%
        \hfill
        \subfigure[Subfigure 3.\label{fig:firstC}]{\includegraphics[height=1.2in]{example-grid-100x100pt}}%
        \par
        \subfigure[Subfigure 4.\label{fig:firstD}]{\includegraphics[height=1.2in]{example-grid-100x100pt}}%
        \hfill
        \subfigure[Subfigure 5.\label{fig:firstE}]{\includegraphics[height=1.2in]{example-grid-100x100pt}}%
        \hfill
        \subfigure[Subfigure 6.\label{fig:firstF}]{\includegraphics[height=1.2in]{example-grid-100x100pt}}%
        \par
        \subfigure[Subfigure 7.\label{fig:firstG}]{\includegraphics[height=1.2in]{example-grid-100x100pt}}%
        \hfill
        \subfigure[Subfigure 8.\label{fig:firstH}]{\includegraphics[height=1.2in]{example-grid-100x100pt}}%
        \hfill
        \subfigure[Subfigure 9.\label{fig:firstI}]{\includegraphics[height=1.2in]{example-grid-100x100pt}}%
        \par
        \subfigure[Subfigure 10.\label{fig:firstJ}]{\includegraphics[height=1.2in]{example-grid-100x100pt}}%            
    \caption{Data Figures For journal Automation, \\ please change Academic Editor to "Communicated by" \label{dataex}}
    \end{figure}

    \end{document}
Related Question