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.
This is neither desired nor same as by the suggested Solutions. Sample of suggested solution is as below. How to fix it?
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.
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 .
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With