Place images as one row on latex

来源:互联网 发布:windows xp 怎么升级 编辑:程序博客网 时间:2024/06/15 06:57

In this blog,  I will introduce four approaches for placing images as one row in latex.

First, use the minipage order, the code is as follows:

\begin{figure*}[!htb]
\begin{minipage}{a\linewidth}
  \includegraphics[width=4.0cm]{1color.png}
\end{minipage}\hfill
\begin{minipage}{b\linewidth}
  \includegraphics[width=4.0cm]{1depth.png}
\end{minipage}\hfill
\begin{minipage}{c\linewidth}
  \includegraphics[width=4.0cm]{1mask.png}  
\end{minipage}\hfill
\begin{minipage}{d\linewidth}
  \includegraphics[width=4.0cm]{1result.png}  
\end{minipage}
\begin{figure*}

notes that  a + b + c + d <= 1, and you should use the[!htb] to ignore the beautiful default design. 

if you want to place image as m*n form, the above method is also capable of doing such issue.


Second, use the array operator. 

\begin{figure*}
\begin{center}
$
\begin{array}{cc}
\includegraphics[width=1.15in]{1color.png} 
\includegraphics[width=1.15in]{1color.png} \includegraphics[width=1.15in]{1color.png} 
\includegraphics[width=1.15in]{1color.png} \includegraphics[width=1.15in]{1color.png}
\includegraphics[width=1.15in]{1color.png}
\end{array}
$
\end{center}
\caption{my caption}
\end{figure*}
if you want to place image as m*n form, you can utilize the & and \\ operator.

Third, use the subfigure operator. Notes you should add the package.

\usepackage{subfigure}

\begin{figure*}[!htb]
\subfigure[text]{
\includegraphics[width=.24\textwidth]{1color.png}
}\hfill
\subfigure[text]{
\includegraphics[width=.24\textwidth]{1color.png}
}\hfill
\subfigure[text]{
\includegraphics[width=.24\textwidth]{1color.png}
}\hfill
\subfigure[text]{
\includegraphics[width=.24\textwidth]{1color.png}
}\hfill
\caption{blablabla}
\label{fig:whatever}
\end{figure*}
Four, use the subfloat operator. Notes you should add the package.
\usepackage{subfig}
\begin{figure*}[!htb]
\begin{center}
\subfloat{\includegraphics[width=4cm]{1color.png}} 
\subfloat{\includegraphics[width=4cm]{1color.png}}
\subfloat{\includegraphics[width=4cm]{1color.png}}
\subfloat{\includegraphics[width=4cm]{1color.png}}
\end{center}
\end{figure*}

Summary: if you want to place all images as one row, you'd better use the !htb.
Author: sgliu 11/22/2012 at Beijing

原创粉丝点击