DEV Community

latexteada
latexteada

Posted on

LaTeX: The theorem Like Environment

Hello, how are you? :)

In this post I talk about

  • How to declare theorem like environments

Introduction

In past post I have talked about macros, but these just are instructions, they are shortens to do something bigger and avoid writing the same instruction many times, what about if we want to create environments?

The theorem like environment is an environment which you can personalize to be numbered according to a certain enumeration, this is useful because you can have the same format to different mathematical proofs, theorems, lemmas, etc, and instead of declaring or writing the same instruction, you just call the environment and it's all

The theorem environment

We say that it is a theorem environment because it is the name of the command, as you are about to notice, but you can create Lemmas, Proofs, and many other stuff, it is just a matter that you put the appropriate name to that

The general instruction is

\newtheorem{name}{print}[numbered]
Enter fullscreen mode Exit fullscreen mode

Where

  • name is the name of the environment
  • print is the word to be shown in the document
  • numbered is the sectional unit based on which the environments is to be numbered (this is optional, you can see it because it has [] instead of {}

An example

Image description

Produces

Image description

See? the environment puts a default enumeration, in this case, it has not any reference, but, in numbered we can put according to what we want that enumeration, for example

  • section for section
  • subsection for subsection

Image description

Produces

Image description

You can play with this!!

Referencing to a theorem

Remember that we say theorem because it is the name of the command

Do you remember the instruction ref and label, if not you can check them here and here, there are good news, you can refer theorems too, the suggested way to call theorems and mathematical stuff is

\eqref{name}
Enter fullscreen mode Exit fullscreen mode

Remember to import the amsmath package in the preamble

Where name is the name of the label, let's see some examples

Image description

Produces

Image description

Did you see, the eqref adds some parentheses

Some conventions to use while labeling the theorem are

  • thm theorem
  • prop proposition
  • dfn definition
  • prf proof
  • cor corollary
  • princ principle
  • lem lemma

Useful Tricks

Names of the theorems

What if we want to be more specific in a theorem? What if we want to add a name, well we have two options, use [] or ()

Image description

Produces

Image description

Delete the cursive

When we are using any math theorem it puts the mathematical equations in cursive, and the theorems are in cursive, it is a mess because sometimes it is difficult to differentiate between normal text and math stuff, so, if we want to delete the cursive in the theorems we just need to add

\usepackage{amsthm}
\theoremstyle{definition}
Enter fullscreen mode Exit fullscreen mode

Image description

Produces

Image description

We need to import the amsthm package and if we put the environment before \theoremstyle{definition} it won't be affected, but if we put the environment after it it will be affected

Top comments (0)