注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

随机过程

http://superware.blog.163.com

 
 
 

日志

 
 

Floats, Figures and Captions  

2013-11-13 09:33:31|  分类: 默认分类 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

I.  Floats

        Floats are containers for things in a document that cannot be broken over a page. LaTeX by default recognizes "table" and "figure" floats, but you can define new ones of your own. Floats are there to deal with the problem of the object that won't fit on the present page, and to help when you really don't want the object here just now.

        Floats are not part of the normal stream of text, but separate entities, positioned in a part of the page to themselves. They always have a caption describing them and they are always numbered so they can be referred to from elsewhere in the text. LaTeX automatically floats Tables and Figures, depending on how much space is left on the page at the point that they are processed. 
If there is not enough room on the current page, the float is moved to the top of the next page.


II.  Figures

        To create a figure the floats, use the figure environment

\begin{figure}[placement specifier]

... figure contents ...

\end{figure}



III. Figures with borders

       
It's possible to get a thin border around all figures. You have to write the following once at the beginning of the document:

\usepackage{float}

\floatstyle{boxed}

\restylefloat{figure}



IV.  Tables

        Floating tables are covered in a seperate chapter. Let's give a quick reminder here. The tabular  environment that was used to construct the tables is not a float by default. therefore, for tables you wish to float, wrap the tabular environment within a table environment, like this:

\begin{table}

\begin{tabular}{tabular seperation}

... table data ...

\end{tabular}

\end{table}

You may feel that it is a bit long winded, but such distinctions are necessary, because you may not want all tables to be treated as a float.

V.  Captions
 
        It is always good practice to add a caption to any figure or table. Fortunately, this is very simple in LaTeX. All you need to do is use the \caption{"text"} command within the float environment.
specifier  |   permission
h | here

t | top

b | bottom

p | page specified for floats only

! | internal parameters for determining "good" position

H | precise location in the LaTeX code.it is somewhat equivalent to h!.

Note that the command \reflectbox{...} flips its content horizontally.

\documentclass[a4paper,12pt]{article}
\usepackage[english]{babel}

\usepackage{graphicx}


\begin{document}

\begin{figure}[h!]
  \caption{A picture of a gull.}
  \centering
    \includegraphics[width=0.5\textwidth]{gull}
\end{figure}
\begin{figure
}[h!]
  \centering
  \reflectbox{\includegraphics[width=0.5\textwidth]{gull}}
  \caption{A picture of the same gull looking the other way!}
\end{figure}
\begin{table}[h!]
  \begin{center}
    \begin{tabular}{|lcr|}
    \hline
    1 & 2 & 3 \\
    4 & 5 & 6 \\
    7 & 8 & 9 \\
    \hline
    \end{tabular}
  \end{center}
  \caption{A simple table}
\end{table}

Floats, Figures and Captions - superware - 随机过程
VI.  Side captions
 
        It is sometimes desirable to have a caption appear on the side of a float, rather than above or below. The sidecap package can be used to place a caption beside a figure or table. The following example demonstrates this for a figure by using a SCfigure environment in place of the figure environment.

\documentclass{article}
\usepackage[pdftex]{graphicx}
\usepackage{sidecap}

\begin{document}
\begin{SCfigure
}
  \centering
  \includegraphics[width=0.5\textwidth]{Giraff_picture} % picture filename
  \caption{ ... caption text ... }
\end{SCfigure}

\end{document}

Floats, Figures and Captions - superware - 随机过程
VI.  Lists of figures and tables
 
        Captions can be listed at the beginning of a paper or report in a "List of Tables" or a "List of Figures" section by using the \listoftables or \listoffigures commands, respectively. The caption used for each figure will appear in these lists, along with the figure numbers, and page numbers that they appear on.

\documentclass[12pt]{article}
\usepackage{graphicx}
\begin{document}
\listoffigures
\section{Introduction}
\begin{figure}[hb]
  \centering
  \includegraphics[width=4in]{gecko}
  \caption[Close up of \textit{Hemidactylus} sp.]{

Close up of \textit{Hemidactylus}

sp., which is part the genus of the gecko family. It is the
   second most speciose genus in the family.}
\end{figure}
\end{document
}


Floats, Figures and Captions - superware - 随机过程

 
VII.  Subfloats

        A useful extension is the subcaption package, (The subfigure and subfig packages are deprecated and shouldn't be used anymore), which uses subfloats within a single float. This gives the author the ability to have subfigures within figures, or subtables within table floats. Subfloats have their own caption, and an optional global caption. An example will best illustrate the usage of this package:

\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\begin{figure}
\centering
  \begin{subfigure}[b]{0.3\textwidth}
  \includegraphics[width=\textwidth]{gull}
    \caption{A gull}
      \label{fig:gull}
    \end{subfigure
}%
    ~ %add desired spacing between images, e. g. ~, \quad, \qquad etc.
      %(or a blank line to force the subfigure onto a new line)

    \begin{subfigure}[b]{0.3\textwidth}
    \includegraphics[width=\textwidth]{tiger}
    \caption{A tiger}
      \label{fig:tiger}
    \end{subfigure
}
    ~ %add desired spacing between images, e. g. ~, \quad, \qquad etc.
      %(or a blank line to force the subfigure onto a new line)

    \begin{subfigure}[b]{0.3\textwidth}
    \includegraphics[width=\textwidth]{mouse}
      \caption{A mouse}
      \label{fig:mouse}
    \end{subfigure}
    \caption{Pictures of animals}\label{fig:animals}
\end{figure
}


Floats, Figures and Captions - superware - 随机过程
 
 

        If you intend to cross-reference any of the subfloats, see where the label is inserted; \caption outside the subfigure-environment will provide the global caption. subcaption will arrange the figures or tables side-by-side providing they can fit, otherwise, it will automatically shift subfloats below. This effect can be added manually, by putting the newline command (\\) before the figure you wish to move to a newline. (可以用新行命令 \\ 以手工方式图表进行换行)

        Horizontal spaces between figures are controlled by one of several commands, which are placed in between \begin{subfigure} and \end{subfigure}:

  • A non-breaking space (specified by ~ as in the example above) can be used to insert a space in between the subfigs.
  • Math spaces: \qquad, \quad, \;, and \,
  • Generic space: \hspace{''length''}
  • Automatically expanding/contracting space: \hfill
  评论这张
 
阅读(62)| 评论(0)
推荐

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017