CTex学习笔记之插入图片篇

\documentclass[a4paper,12pt]{article}
\usepackage{graphicx} %use graph format
\usepackage{subfig}    %%%%%%%%%% 用fig效果比figure好,注意一下
%\usepackage{subfigure}%%%%%%%%%%%%%%插入并列图必备宏包

\usepackage{CJK}
%%%%%%%%%%%%%%%%插入图片%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%一、指定位置插图片%%%%%%%%%%%%%
\usepackage{graphicx}%%%%%%%%%%%%%%%加载宏包
\usepackage{float}%%%%%%%%%%%%%控制图片出现在指定的位置,下面在  \begin{figure}后加 [H]
\begin{document}
This is only a test.
\begin{figure}[H]%%%%%%%%%%%%%%%%%禁止图片浮动
  \centering
  % Requires \usepackage{float}来禁止浮动
  % Requires \usepackage{graphicx}
  \includegraphics[width=0.8\textwidth]{spider.jpg}\\%%%%%%%%%%% [width=0.8\textwidth]指定图片大小
                                                     %%%%%%%%%%%去掉0.8,图片宽度和文本宽度一样(这个图片更好看些)
  \caption{Spider Web}
\end{figure}
Now you can see that the figure is on the specific place.\\

%%%%%%%%%%%%二、浮动图形%%%%%%%%%%%%%%%%%%%%%%
Now let the Ctex place the figure automatically.
\begin{figure}[htbp]%%%%%%%%%%%根据 h-t-b-p 顺序摆放图片,分别为 here,top,bottom,float page(单独的浮动页)
  \centering
  % Requires \usepackage{graphicx}
  \includegraphics[width=\textwidth,height=6cm]{spider.jpg}\\%%%%%%可以用cm,或in
  \caption{Spider web again}\label{hello world}%%%%%%%%%%%%%%% label仅仅是为了自己写作时区分
\end{figure}
These words are to test the place of the figure, and you see they all don't  under the figure.

%%%%%%%%%%%%%%%三,两个并列图%%%%%%%%%%%%%%%%%%%
%\usepackage{subfigure} 需要加载的宏包
%\usepackage{subfig}  下面代码用的时这个,可以取消默认前缀    
%%%%%%% 需要minipage 环境

    %%%%%%%%%%%方法一、每张图各有标题,而且两张有一个公共的标题%%%%%%%%%%%%%%%%%%%
\begin{figure}[!htbp]   %%%%加!取消浮动
    \begin{minipage}[t]{0.5\linewidth}%%%%%%%%%%% t-text, 即图片的解释文字,设置为0.5行宽,因为插入两个并列图片
    \centering
    \includegraphics[height=6cm,width=8cm]{spider.jpg}
    \caption*{(a) Spider Web}%%%%%%%%%%%%%%    加*可以取消默认前缀
    %%%%%%此处已省略label
    \end{minipage}
    %%%%%%%%%%%%%%%%%%%%%%%%%绝对不可以在这里为了读代码方便而空出一行,一空你就输了,不信尽管试试
    \begin{minipage}[t]{0.5\linewidth}
    \centering
    \includegraphics[height=6cm,width=8cm]{figure.jpg}
    \caption*{(b) figure }
    \end{minipage}
    \caption{Common name}
\end{figure}

    %%%%%%%%%%%方法二、每张图各有标题,而且两张有一个公共的标题%%%%%%%%%%%%%%%%%%%
    %%%%%%%% subfloat是在宏包subfig里面的命令
    \begin{figure}[!htbp]   %%%%加!取消浮动
    \subfloat[Method 2.1]{
    \begin{minipage}[t]{0.5\linewidth}%%%%%%%%%%% t-text, 即图片的解释文字,设置为0.5行宽,因为插入两个并列图片
    \centering
    \includegraphics[height=6cm,width=8cm]{spider.jpg}
    \end{minipage}
    }
    \subfloat[Method 2.2]{
    \begin{minipage}[t]{0.5\linewidth}
    \centering
    \includegraphics[height=6cm,width=8cm]{figure.jpg}
    \end{minipage}
    }
    \caption{Common name}
\end{figure}

    %%%%%%%%%两张共用有一个标题%%%%%%%%%%%%%%%%%%%
    \begin{figure}[!htbp]
        %\begin{minipage}[t]{0.5\linewidth}%设定图片下字的宽度,在此基础尽量满足图片的长宽,文字为0.5 行宽
        \centering
        \includegraphics[height=4.4cm,width=5.8cm]{figure.jpg}
        \includegraphics[height=4.4cm,width=5.8cm]{spider.jpg}
        \caption{This is total name.}%n张图片共享的说明
    \end{figure}
\end{document}

你可能感兴趣的:(CTex学习笔记之插入图片篇)