Sharelatex中的并排子图形

Sharelatex中的并排子图形,latex,tex,latex-environment,Latex,Tex,Latex Environment,我有兴趣制作一个具有多个子图形的图形。通过一些搜索,我找到了不同的方法,但并不适合我。可能是我使用的是shareLatex,而其他人使用的是正确的Latex(我不知道有什么不同,所以如果我说了一些奇怪的话,很抱歉)。下面给出的是代码 \begin{figure}[t!] \centering \begin{subfigure}[t]{0.5\textwidth} \centering \includegraphics[height=1.2in]{B

我有兴趣制作一个具有多个子图形的图形。通过一些搜索,我找到了不同的方法,但并不适合我。可能是我使用的是shareLatex,而其他人使用的是正确的Latex(我不知道有什么不同,所以如果我说了一些奇怪的话,很抱歉)。下面给出的是代码

\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}
我的输出是这样的

这与建议的解决方案既不理想也不相同。 建议的溶液样本如下所示。如何修复它


我找到了这段代码,它对子图形非常有效。对于两个子图形,请使用

\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}
带样本输出

对于级联子图形

\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}
4个子图的示例


应记住导入文件顶部的子图形\usepackage{subfigure}百分比符号是什么?他们不是刚开始评论吗?在
%
字符之后还有一个换行符。LaTeX不会忽略换行符(它们的工作方式与空白字符类似)。避免所有可能引起的副作用的一个技巧是将换行符“隐藏”到注释中,以便LaTeX真正忽略它。使用此技巧,LaTeX将带有注释的行和下一行视为一行,中间没有空格。技巧的另一个重要部分是注释前不能有空白字符(即
}
%
),以免该字符引入与换行符相同的副作用。