关于将一张图片放在左边,将另一张图片放在右边的问题

关于将一张图片放在左边,将另一张图片放在右边的问题

我想把两个图表放在一起,一个在左边,另一个在右边。我使用“minipage”。但是,使用下面的代码,第一个图表位于第二个图表的顶部。有人能帮我吗?

这是我的代码:

 \documentclass[tikz]{standalone}
    \usepackage{tikz}
    \usepackage{scalefnt}
    \usetikzlibrary{shapes}
    \begin{document}
    \begin{figure}[htbp]
    \hspace{-4mm}
    \begin{minipage}{0.5\linewidth}]
    \centering
    %\includegraphics[width=2.3in]{image/CompositionalStucture}
    %\input{trans}
    \tikzset{
     block/.style = {circle, draw,align=center,inner sep=0pt},
     line/.style = {draw,->},
     }
    {\scalefont{1}
    \begin{tikzpicture}[node distance=10mm]
    \node[block,minimum size=3mm](s2) {1};
    \node[block,right of =s2,anchor=center,minimum size=2mm] (s3){2};
    \node[block, right of=s2,anchor=center,,minimum size=3mm] (s4) {};

    \path[line] (-0.8,0)-- (s2){};
    \path[line] (s2)-- node[above]{stop}(s4);
    \path[line] (s2) to [out=120,in=40,looseness=5] node[above] {$\Sigma$}(s2);
    \path[line] (s4) to [out=120,in=40,looseness=5]node[above] {$\Sigma$}(s4);
    \end{tikzpicture}
    }
    \caption{Travel Agency Service (\TAS{})}
    \label{fig:TAS}
    \red{2}
    \end{minipage}

    \begin{minipage}{0.5\linewidth}
    \centering
    %\includegraphics[width=2.3in]{image/CompositionalStucture}
    %\input{trans1}
    \tikzset{
     block/.style = {ellipse, draw,align=center,inner sep=0pt},
     line/.style = {draw,->},
     }
    {\scalefont{1}
    \begin{tikzpicture}[node distance=10mm]
    \node[block,minimum size=3.5mm](s1) {(6,1)};
    \node[block,minimum size=3.5mm,below of =s1](s2) {(7,1)};
    \node[block,minimum size=3.5mm,below of = s2](s3) {(22,2)};

    \path[line] (s1)-- node[right]{gc}(s2);
    \path[line] (s2)-- node[right]{TER}(s3);
    \end{tikzpicture}
    }
    \caption{Travel Agency Service (\TAS{})}
    \label{fig:TAS}
    \red{3}
    \end{minipage}
    \end{figure}
    \end{document}

答案1

由于未定义的控制序列,我无法编译您的示例,但我相信问题可能是由小页面之间的空格引起的。小页面之间有一个空行,这意味着它们将位于不同的段落中。即使您删除此行,它们仍将位于不同的行上,因为它们之间的换行符将在它们之间插入一个空格,而换行算法会将它们放在不同的行上。

你想要做的事情是这样的:

\begin{minipage}{0.5\linewidth}
    % some contents here
\end{minipage}% <--- the percent character will "comment out" the new line    
\begin{minipage}{.5\linewidth}
     % some content here
\end{minipage

相关内容