Boxes

Boxes #

Author: Erhua

Keywords: boxes

In this section, we discuss boxes. A box is a basic unit in LaTeX, which can represent a piece of text, an image, a table, a page, etc.

Small boxes can be combined to form larger boxes, ultimately forming the overall document.

Horizontal Boxes #

Horizontal boxes cannot contain paragraph breaks, i.e., they cannot be divided into new lines or paragraphs.

Boxes without Borders #
\mbox{text}
\makebox[width][position(clrs)]{content}
Boxes with Borders #
\fbox{text}
\framebox[width][position]{text}

Vertical Boxes #

Vertical boxes can contain multiple paragraphs.

There are two forms of commands for vertical boxes: command\parbox{width}{box contents} and environment\begin{minipage}{width}…

Simplified command format
\parbox{width(typically expressed as 0.48\textwidth)}{box contents}
------
Simplified environment format
\begin{minipage}{width(typically expressed as 0.48\textwidth)}% The width of this box is 0.48 times \textwidth
box contents
\end{minipage}

NOTICE: The width parameter is required and represents the width of the content. If the content exceeds this width, it will automatically wrap to a new line.

\documentclass[]{article}
\usepackage{ctex}
\begin{document}
\parbox{0.6\textwidth}{
	The harp has fifty strings which vibrate with no cause. One string, one column, reminds me of the passing years. The dawn dreams of a butterfly lost in love, the deep embrace of spring is held by cuckoos. The moon shines on the sea, and it has tears like pearls.
	The harp has fifty strings which vibrate with no cause. One string, one column, reminds me of the passing years. The dawn dreams of a butterfly lost in love, the deep embrace of spring is held by cuckoos. The moon shines on the sea, and it has tears like pearls.
}
\vskip 1cm
\begin{minipage}{0.45\linewidth}
	The harp has fifty strings which vibrate with no cause. One string, one column, reminds me of the passing years. The dawn dreams of a butterfly lost in love, the deep embrace of spring is held by cuckoos. The moon shines on the sea, and it has tears like pearls.
	The harp has fifty strings which vibrate with no cause. One string, one column, reminds me of the passing years. The dawn dreams of a butterfly lost in love, the deep embrace of spring is held by cuckoos. The moon shines on the sea, and it has tears like pearls.
\end{minipage}
\end{document}

\raisebox{distance}{content}
This box is used to control the vertical position, where a positive distance moves it up and a negative distance moves it down.
\documentclass[]{article}
\usepackage{ctex}
\begin{document}
T\hspace{-0.5em}
\raisebox{-0.2em}{E}
\hspace{-0.5em}X
\end{document}