# Text Environments (III) - Theorem Environments #

Author: Erhua

Keywords: Theorem Environments

In this section, we discuss theorem environments.

In fact, theorem environments are not used very often in formal paper writing.

```
\newtheorem{theory}{Theorem}
The above command, placed in the preamble, declares a theorem environment. It takes two parameters: the former is the newly defined environment name, and the latter is the displayed output title name in the document.
\begin{theory}[Optional Subtitle]
Theorem content
\end{theory}
```

When customizing styles, we need to use the theorem package, which includes several important commands.

```
\usepackage{theorem}
\theorembodyfont{font} sets the font for theorem content. It is recommended to define the font beforehand.
\theoremheaderfont{font} sets the font for theorem headers. It is recommended to define the font beforehand.
\theorempreskipamount is a variable for the vertical distance before the theorem. Use \setlength to set it.
\theorempostskipamount is a variable for the vertical distance after the theorem.
```

```
\documentclass{article}
\usepackage{ctex}
\usepackage{theorem}
\usepackage{fontspec}
\newCJKfontfamily\qingsong[ItalicFont = FZQKBYSJW--GB1-0,BoldFont = FZQKBYSJW--GB1-0]{FZQKBYSJW--GB1-0}
\newCJKfontfamily\fs[ItalicFont = STFangsong,BoldFont = STFangsong]{STFangsong}
\newtheorem{theory}{Night Rain and Autumn Lamp}
\theorembodyfont{\fs} % set the font for theorem content
\theoremheaderfont{\qingsong} % set the font for theorem headers
\setlength{\theorempreskipamount}{0.2cm} % set the variable for the vertical distance before the theorem
\setlength{\theorempostskipamount}{0cm} % set the variable for the vertical distance after the theorem
\begin{document}
\noindent{\qingsong Night Rain and Autumn Lamp}\qquad{\fs The shortest line segment between two points}\\
\vskip 1cm
\begin{theory}
The shortest line segment between two points
\end{theory}
\begin{theory}
Congruent angles
\end{theory}
\begin{theory}
The sum of two sides of a triangle is greater than the third side
\end{theory}
\end{document}
```