side-by-side subfigure in Sharelatex
<p>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...</p>

<pre><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}
</code></pre>

<p>My Output is something like this.</p>

<p><a href="https://i.stack.imgur.com/3ReZr.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/3ReZr.jpg" alt="enter image description here"></a></p>

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

<p><a href="https://i.stack.imgur.com/VMQne.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/VMQne.jpg" alt="enter image description here"></a></p>