## DEV Community is a community of 846,721 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

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]


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

Produces

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

Produces

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}


Remember to import the amsmath package in the preamble

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

Produces

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 ()

Produces

### 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}


Produces

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