Latex插入图片

来源:互联网 发布:如何查看淘宝消费记录 编辑:程序博客网 时间:2024/05/17 21:55

Latex是一个专业论文制作工具,在国外,大多高水平的论文都使用Latex对论文进行排版。Latex以其页面的美观整洁,以及功能的强大受到国际专家学者的重视。
在Latex插入图片对于新手来说是件麻烦的事情,弄不好让人心情急躁。比如,Latex对系统时间检测得比较严,需要将系统时间设置为2005年,否则会出现编译错误:LaTeX source files more than 5 years old!.这是令人比较苦恼的事情,可能我使用的CTex不是正版的缘故吧!
无论在Latex插入什么图片,都需要在导言区导入宏包\usepackage{graphics},latex最有名的就是支持eps(Encapsulated PostScript)格式的图片的插入,不过Latex对图形插入的格式进行了扩展,比如支持插入pdf格式的图片,需要在导言区插入\usepackage{graphicx},一般使用\usepackage{graphicx}就能对graphics进行支持。不过需要注意的是插入eps格式的图片时,必须使用latex和dvipdf两个命令,在编辑器WinEdt中有两个按钮;而插入pdf格式的图片时,使用的命令就是pdflatex了,它可以直接将源文件*.tex编译生成*.pdf文件。本文主要讲述使用graphics宏包插入图片,当然还有其他方法。

在latex中,对于双栏格式的排版,插入一栏图片时,使用的是\begin{figure}……\end{figure} ,插入双栏图片时需在figure的上标中加入符号“*”,如\begin{figure*}……\end{figure*}。
1.在latex插入一张图片(占一栏)比较简单,插入一张图片的代码如下:

\begin{figure}{h}
\centering %使插入的图片居中显示
\includegraphics[height=5cm ,width=8cm,angle=0,scale=]{fig.eps}
\caption{Example twig query and documents } %插入图片的标题,一般放在图片的下方,放在表格的上方
\end{figure}

关键性的语句是:\includegraphics[选项]{图片.eps}
选项:height %指定图片的高度
width %指定图片的宽度
angle %指定图片旋转的角度
还有一个指标叫scale,之缩放图形。
2.在latex插入多张图片(占双栏)就不是那么简单了,笔者知道有两种方法:
法一:使用\begin{minipage}[pos]{width} text \end{minipage}


\begin{figure*}
\centering
\begin{minipage}[!htbp]{0.3\linewidth}
\includegraphics[width=1.5in,angle=-90]{52.eps}
%\caption{fig1}
\label{fig:side:a}
\end{minipage}%
\begin{minipage}[!htbp]{0.3\linewidth}
\includegraphics[width=1.5in,angle=-90]{51.eps}
%\caption{fig2}
\label{fig:side:b}
\end{minipage}
\begin{minipage}[!htbp]{0.3\linewidth}
\includegraphics[width=1.5in,angle=-90]{53.eps}
%\caption{fig3}
\label{fig:side:c}
\end{minipage}
\caption{3 figure}
\end{figure*}

注:笔者不太喜欢这种方法,原因是这种插入方式如果在每个图中使用\caption{fig3 name}给图片做注释的时候不是把三个图片当做一个figure,而是每个图片即每个minipage各使用一个fig标记,三个mingpage相当于三个图片了,当然也可以不单独对每个图片写个\caption,而是在\caption{3 figure}中对每个figure进行解释说明,所以笔者推崇第二种方法。当然,笔者也许不知道如何设置,有望业内人士指教。
法二:使用subfigure命令,但必须在导演区加入\usepackage{subfigure},否则无法编译过去。


\begin{figure*}[!t]
\centering
\subfigure[Number of elements read] {\includegraphics[height=2in,width=2in,angle=-90]{52.eps}}
\subfigure[Size of disk files scanned] {\includegraphics[height=2in,width=2in,angle=-90]{51.eps}}
\subfigure[Execution time] {\includegraphics[height=2in,width=2in,angle=-90]{53.eps}}
\caption{ PathStack versus TJFast using XMark data }
\label{fig5}
\end{figure*}

这种方法很好,即插入三个子图,可以将三个图片合成一个大图,而且每个图片还可以添加caption,即于subfigure[*]中*内进行解释说明。

原创粉丝点击