Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

side-by-side subfigure in Sharelatex

I am interested to make a figure with multiple subfigures. By some search I found different ways but not working for me. May be I am using shareLatex and others use proper Latex (I don't know very much difference so sorry if I say something odd). Given below is the code...

\begin{figure}[t!]
    \centering
    \begin{subfigure}[t]{0.5\textwidth}
        \centering
        \includegraphics[height=1.2in]{Bilder/sample.png}
        \caption{Sample1}
    \end{subfigure}%
    ~ 
    \begin{subfigure}[t]{0.5\textwidth}
        \centering
        \includegraphics[height=1.2in]{Bilder/sample.png}
        \caption{sample2}
    \end{subfigure}
    \caption{Caption place holder}
\end{figure}

My Output is something like this.

enter image description here

This is neither desired nor same as by the suggested Solutions. Sample of suggested solution is as below. How to fix it?

enter image description here

like image 898
Khan Aaqib Avatar asked Dec 08 '16 14:12

Khan Aaqib


People also ask

How do you plot a Subfigure in latex?

To create subfigure in latex, you can use both \begin{minipage}... \end{minipage} and \begin{subfigure}... \end{subfigure} block to insert subfigures or sub-images. Subfigurs are generally inserted horizontally in one or multiple rows.

How do you do Subfigures overleaf?

To start with, we create a new figure, centre it and then create a new subfigure. In the subfigure command we need to add a placement specifier and then give it a width. Because we want three images next to each other we set a width of 0.3 times the value of \textwidth .


Video Answer


1 Answers

I found this code and it is working perfectly for subfigures. For two subfigures use

\begin{figure}%
\centering
\subfigure[Sample1]{%
\label{fig:first}%
\includegraphics[height=2in]{Bilder/sample.png}}%
\qquad
\subfigure[Sample2]{%
\label{fig:second}%
\includegraphics[height=2in]{Bilder/sample.png}}%
\caption{sample}
\end{figure}

with sample output

enter image description here

And for cascading subfigures....

\begin{figure}%
\centering
\subfigure[][]{%
\label{fig:ex3-a}%
\includegraphics[height=2in]{Bilder/sample.png}}%
\hspace{8pt}%
\subfigure[][]{%
\label{fig:ex3-b}%
\includegraphics[height=2in]{Bilder/sample.png}} \\
\subfigure[][]{%
\label{fig:ex3-c}%
\includegraphics[height=2in]{Bilder/sample.png}}%
\hspace{8pt}%
\subfigure[][]{%
\label{fig:ex3-d}%
\includegraphics[height=2in]{Bilder/sample.png}}%
\caption[A set of four subfigures.]{A set of four subfigures:
\subref{fig:ex3-a} describes the first subfigure;
\subref{fig:ex3-b} describes the second subfigure;
\subref{fig:ex3-c} describes the third subfigure; and,
\subref{fig:ex3-d} describes the last subfigure.}%
\label{fig:ex3}%
\end{figure}

sample for 4 subfigure

enter image description here

like image 77
Khan Aaqib Avatar answered Sep 18 '22 08:09

Khan Aaqib