この記事では、LaTeXの定理環境について解説します。
まず、プリアンブル(\documentclassと\begin{document}の間)に次の行を追加してamsthmパッケージを読み込みます。
\usepackage{amsthm}
次に、新しい定理スタイルを定義します。
次のように\newtheoremコマンドを使用します。
\newtheorem{theorem}{定理}
\newtheorem{lemma}{補題}
このコードは、新しい"theorem"環境と"lemma"環境を作成します。 各環境は番号付けられ、適切な名前("定理"と"補題")が与えられます。
次に、定理を使いたい場所で、次のようにコマンドを使用します。
\begin{theorem}
これは定理の内容です。
\end{theorem}
\begin{lemma}
これは補題の内容です。
\end{lemma}
これらのコマンドを使用すると、LaTeXは自動的に適切な番号を割り当て、定理や補題の本文を整形します。
\documentclass[12pt]{jsarticle}
\usepackage{amsthm}
\newtheorem{theorem}{定理}
\newtheorem{lemma}{補題}
\begin{document}
\begin{theorem}
これは定理の内容です。
\end{theorem}
\begin{theorem}
定理の内容です。
\end{theorem}
\begin{lemma}
これは補題の内容です。
\end{lemma}
\end{document}
定理1. これは定理の内容です。
定理2. 定理の内容です。
補題1. これは補題の内容です。
このコードをコンパイルすると、LaTeXドキュメントに定理と補題が表示され、それぞれ番号が振られます。
\theoremstyleは定理環境のスタイルを設定するコマンドです。
\newtheoremコマンドの前に入力します。
\theoremstyle{スタイル名}
\theoremstyleコマンドによって指定される定理環境のスタイルは次の4つから構成されます。
\textitや\textbfなどのコマンドを使用)。\documentclass[12pt]{jsarticle}
\usepackage{amsthm}
\theoremstyle{plain} % デフォルトのスタイル
\newtheorem{theorem}{定理}
\theoremstyle{definition}
\newtheorem{definition}{定義}
\begin{document}
\begin{theorem}
これはデフォルトのスタイルの定理です。
\end{theorem}
\begin{definition}
これはdefinitionスタイルの定義です。
\end{definition}
\end{document}
定理1. これはデフォルトのスタイルの定理です。
定義1. これはdefinitionスタイルの定義です。
この例では、\theoremstyleを使用して"plain"スタイル(デフォルトスタイル)と"definition"スタイルを指定し、それぞれに対応する定理環境を作成しています。
スタイルによって定理の外観は異なります。
amsthmパッケージには、\theoremstyleコマンドで指定できるいくつかの定義済みのスタイルがあります。以下に一般的な\theoremstyleのスタイルのいくつかを示します。
| コマンド | |
|---|---|
| plain | (デフォルトのスタイル): タイトルを斜体(italic)で表示します。 定理本文は斜体ではなく、ボールド(bold)で表示します。 |
| definition | タイトルと定理本文を両方正体(roman)で表示します。 |
| remark | タイトルを斜体で表示し、定理本文を正体で表示します。 |
これらのスタイルは一般的なもので、\newtheoremstyleコマンドを用いて、独自のスタイルを定義できます:
\documentclass[12pt]{jsarticle}
\usepackage{amsthm}
\newtheoremstyle{mystyle}
{3pt} % スペース前
{3pt} % スペース後
{\itshape} % 本文フォント
{} % インデント
{\bfseries} % タイトルフォント
{} % タイトルの句読点
{0.8em} % タイトルからのスペース
{} % タイトルの指定
\theoremstyle{mystyle}
\newtheorem{theorem}{定理}
\begin{document}
\begin{theorem}
これはカスタムスタイルの定理です。
\end{theorem}
\end{document}
定理1 これはカスタムスタイルの定理です。
このようにドット「.」をなくすことができます。