Table Drawing (Part 3) - Title Control and Floating Objects (Basic)

Table Drawing (Part 3): Title Control and Floating Objects (Basic) #

Author: Erhua

Keywords: tables, floating objects, titles

What are floating objects: Floating objects are movable boxes that are typically used in places where they occupy a large block of space. They allow the box to be moved to a suitable position before or after the current location, preventing the article from looking unattractive due to fixed boxes causing excessive white space.

Floating objects not only serve the above purpose, but also allow titles to be added to tables or images, and can be numbered.

Floating Object Environments #

LaTeX has two floating object environments: “figure” and “table”, used for typesetting images and tables, respectively.

\begin{table}[position]
Other content (usually table or image options)
\end{table}

The position options are as follows:

  • h: Place the float here
  • t: Place at the top of the page
  • p: Place on a separate page
  • b: Place at the bottom of the page

The options can be combined, such as [htpb].

The common usage of floating objects is to directly place a “tabular” table in the “table” environment, or to place an image inserted with “\includegraphics” in the “figure” environment, which will use “\centering” inside the float environment to center the table or image.

NOTICE:

It is worth noting that although we use the names “figure” and “table” as the environment names, they do not necessarily have to contain images or tables. In other words, the environment name has no necessary connection to its content.

Title Settings #

Floating objects can have titles set for images, tables, or other forms of content using the “\caption” command.

\caption{Title}
\caption[Short Title]{Long Title}

The placement of titles is determined by the image or table, with the title of an image usually placed below the image and the title of a table placed above the table.

The label for cross-referencing “\label” should be placed after the “\caption”.

\documentclass[]{article}
\usepackage{ctex}
\usepackage{graphics}
\begin{document}
\begin{figure}[htp]
\centering
\includegraphics{/Users/fplee/blog/public/yeyuqiudeng.jpg}
\caption [logo]{夜雨秋灯到天明}\label{夜雨秋灯}
\end{figure}
\end{document}

When we want to control the font spacing and alignment of table headers or figure captions, we can use the “caption” package.

The “caption” package provides two ways to use it:

  • As an optional argument when importing the package “\usepackage [font = 11pt, labelfont = 13pt]{caption}”

  • Use “\captionsetup” inside the floating object to set it

\usepackage{caption}
\captionsetup{font = 11pt,……}

It is also possible to modify all tables or figures only

\usepackage{caption}
\captionsetup [figure]{font = 11pt,……}

Please refer to the package documentation for specific “caption” operations.