2

enter image description here

How can I put insert figures in a grid? Each figures will have 4 captions. I tried using subfloat but it doesn't seem to work.

\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}

\begin{figure}[ht] \label{ fig7} 
  \begin{minipage}[b]{0.5\linewidth}
   \includegraphics[width=0.35\linewidth,valign=c]{1.jpg} 
\caption{The first caption}
\caption{The second caption}
\caption{The third caption}
\caption{The fourth caption}
  \end{minipage} 
  \begin{minipage}[b]{0.5\linewidth}
   \includegraphics[width=0.35\linewidth,valign=c]{2.jpg} 
\caption{The first caption}
\caption{The second caption}
\caption{The third caption}
\caption{The fourth caption}
  \end{minipage} 
  \begin{minipage}[b]{0.5\linewidth}
   \includegraphics[width=0.35\linewidth,valign=c]{2.jpg} 
\caption{The first caption}
\caption{The second caption}
\caption{The third caption}
\caption{The fourth caption}
  \end{minipage}
  \hfill
  \begin{minipage}[b]{0.5\linewidth}
    \includegraphics[width=0.35\linewidth,valign=c]{3.jpg} 
\caption{The first caption}
\caption{The second caption}
\caption{The third caption}
\caption{The fourth caption}
  \end{minipage} 
\end{figure}

\end{document}
blues
  • 39
  • 1
    Welcome to TeX.SE. You could see here, for example, https://tex.stackexchange.com/questions/126818/minipage-with-four-figures-avoiding-too-much-whitespace or here https://tex.stackexchange.com/questions/162824/vertical-spacing-between-subfloat – Sebastiano Mar 01 '19 at 17:15
  • one figure with four captions? please, show a sketch of how this should look like. – Zarko Mar 01 '19 at 18:02
  • @Zarko, added. sorry about the orientation. – blues Mar 01 '19 at 18:33
  • and where are captions? how they are numbered? and really each image has four caption? i never seen something like this demand ... (to my opinion, it does not make sense) – Zarko Mar 01 '19 at 18:37
  • @Sebastiano, thanks very much but is there any option to have multiple caption for each figure in separate lines? – blues Mar 01 '19 at 18:37
  • 1
    Hey @blues5, are you sure you need actual captions? Wouldn't 4 simple lines of text be sufficient? – sheß Mar 01 '19 at 18:39
  • @sheß, this four captions would be four model ouputs. i've posted the code that i'm using currently but it's too spacious. – blues Mar 01 '19 at 18:46
  • @Zarko. i've posted the code. but i need to reframe that in a grid to reduce space. – blues Mar 01 '19 at 18:47
  • I made an edit to your post to fix your figure and add code highlighting. Always try to do this yourself, it will increase your chances of getting help.

    What you mean by "model" is probably context specific, but it sounds very much to me like what you're looking for is either a key for your figure or simply to write text next to it.

    – sheß Mar 01 '19 at 18:52
  • please extend your code fragment to complete document beginning with \documentclass{...} and ending with \end{document}. in preamble of this document should be loaded only relevant packages needed for document compilation. – Zarko Mar 01 '19 at 19:03
  • @blues Excuse me, but I have read now. When I have seen your picture I have undertsood your question :-(. Sorry. I'm pretty sure that the greats leandris and Zarko have found the right solution for you. – Sebastiano Mar 01 '19 at 20:36

2 Answers2

3

edit: still guessing ... but now images are in array of 2 x 2 images:

enter image description here

\documentclass[twocolumn]{article}
\usepackage[export]{adjustbox}
\usepackage{tabularx}
\usepackage{caption}
\usepackage{subcaption}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\begin{document}    
    \begin{figure*}
    \setkeys{Gin}{width=\linewidth}
    \captionsetup{font=footnotesize, labelfont=bf, 
                  justification=raggedright,
                  skip=0.5ex, singlelinecheck=false}
    \setlength\tabcolsep{3pt}
\begin{tabularx}{\linewidth}{@{} *{4}{X} @{}}
\includegraphics[valign=T]{example-image-duck}
    &   \caption{The first caption}
        \caption{The second caption}
        \caption{The third caption}
        \caption{The fourth caption}
        &   \includegraphics[valign=T]{example-image-duck}
                &   \caption{The first caption}
                    \caption{The second caption}
                    \caption{The third caption}
                    \caption{The fourth caption}    \\
\includegraphics[valign=T]{example-image-duck}
    &   \caption{The first caption}
        \caption{The second caption}
        \caption{The third caption}
        \caption{The fourth caption}
        &   \includegraphics[valign=T]{example-image-duck}
                &   \caption{The first caption}
                    \caption{The second caption}
                    \caption{The third caption}
                    \caption{The fourth caption}    
\end{tabularx}
    \end{figure*}
\end{document}
Zarko
  • 296,517
  • This seems to me is a very correct answer to the literal question the OP asked, but I doubt that this is actually what the OP wants to do. @blues5, please correct me if I'm wrong. – sheß Mar 01 '19 at 18:54
  • posted the new code. but it still looks terrible. inserting a minipage within minipage might take care for the alignment i guess – blues Mar 01 '19 at 19:06
  • @blues, your mwe contain errors (missed packages, etc}. anyway, see, if my edited answer is close to what you like to have. – Zarko Mar 01 '19 at 19:26
  • @sheß, you are right. meanwhile i correct my answer (according to quite unclear sketch in question}. i still woundering about four captions per images ... mabe op looks for \caption*{< some description>} or simple list of options. who knows. let us wait what will op say. – Zarko Mar 01 '19 at 19:37
  • sorry for the poor description. there would be four system output corresponding to each image. say for image 1, i have the original description and three system output. – blues Mar 01 '19 at 19:44
  • also the image is pretty misleading.i'm not able to delete it myself – blues Mar 01 '19 at 19:45
  • @Zarko, thanks so much for helping out so far. the 2*2 grid did work but i'm not able to disable figure1, figure 2,..labels – blues Mar 01 '19 at 20:04
  • @blues, as i mentioned in comment to sheß, instead \caption{...} use \caption*{...}. however, your document example has \caption{...}. temporary i'm without my crystal ball, it went to the carnival ... :-), so i can only guess what you like to have. – Zarko Mar 01 '19 at 20:11
  • @Zarko, perfect! what a great learning platform is this! – blues Mar 01 '19 at 20:21
3

enter image description here

The above shown output is achieved using nested tables as shown in the following MWE:

\documentclass{article}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage[export]{adjustbox}
\usepackage{ragged2e}
\newcolumntype{L}[1]{>{\RaggedRight\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}

\begin{document}

\begin{tabularx}{\textwidth}{p{2cm}Xp{2cm}X}
\includegraphics[width=\linewidth,valign=t]{example-image} &
\begin{tabular}[t]{lL{3cm}}
Original:&  Two people walking on the beach.\\ 
Model21:&   Zwei Personen gehen am Strand. \\
Model2:&   Zwei Personen gehen am Strand. \\
Model23:&  Zwei Personen gehen am Strand. \\
\end{tabular} &
\includegraphics[width=\linewidth,valign=t]{example-image} &
\begin{tabular}[t]{lL{3cm}}
Original:&  Two people walking on the beach.\\ 
Model21:&   Zwei Personen gehen am Strand. \\
Model2:&   Zwei Personen gehen am Strand. \\
Model23:&  Zwei Personen gehen am Strand. \\
\end{tabular}\\
\\
\includegraphics[width=\linewidth,valign=t]{example-image} &
\begin{tabular}[t]{lL{3cm}}
Original:&  Two people walking on the beach.\\ 
Model21:&   Zwei Personen gehen am Strand. \\
Model2:&   Zwei Personen gehen am Strand. \\
Model23:&  Zwei Personen gehen am Strand. \\
\end{tabular} &
\includegraphics[width=\linewidth,valign=t]{example-image} &
\begin{tabular}[t]{lL{3cm}}
Original:&  Two people walking on the beach.\\ 
Model21:&   Zwei Personen gehen am Strand. \\
Model2:&   Zwei Personen gehen am Strand. \\
Model23:&  Zwei Personen gehen am Strand. \\
\end{tabular}
\end{tabularx}
\end{document}

enter image description here

Here is a variant using the description environment instead of nested tables:

\documentclass{article}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{ragged2e}

\newcolumntype{Z}{>{\RaggedRight\let\newline\\\arraybackslash\hspace{0pt}}X}

\usepackage{enumitem}
\setlist[description]{after=\vspace{-\baselineskip},before=\vspace{-\baselineskip},topsep=0pt,partopsep=0pt}

\begin{document}

\begin{tabularx}{\textwidth}{p{2cm}Zp{2cm}Z}
\includegraphics[width=\linewidth,valign=t]{example-image} &
\begin{description}
\item[Original]  Two people walking on the beach.
\item[Model21]   Zwei Personen gehen am Strand. 
\item[Model2]   Zwei Personen gehen am Strand. 
\item[Model23]  Zwei Personen gehen am Strand. 
\end{description} &
\includegraphics[width=\linewidth,valign=t]{example-image} &
\begin{description}
\item[Original]  Two people walking on the beach.
\item[Model21]   Zwei Personen gehen am Strand. 
\item[Model2]   Zwei Personen gehen am Strand. 
\item[Model23]  Zwei Personen gehen am Strand. 
\end{description}
\end{tabularx}


\end{document}
leandriis
  • 62,593