In category theory, a **2-category** is a category with "morphisms between morphisms"; that is, where each hom-set itself carries the structure of a category. It can be formally defined as a category enriched over **Cat** (the category of categories and functors, with the monoidal structure given by product of categories).

A 2-category **C** consists of:

A class of *0-cells* (or *objects*) A, B, ....
For all objects A and B, a category
C
(
A
,
B
)
. The objects
f
,
g
:
A
→
B
of this category are called *1-cells* and its morphisms
α
:
f
⇒
g
are called *2-cells*; the composition in this category is usually written
∘
or
∘
1
and called *vertical composition* or *composition along a 1-cell*.
For any object A there is a functor from the terminal category (with one object and one arrow) to
C
(
A
,
A
)
, that picks out the identity 1-cell id_{A} on A and its identity 2-cell id_{idA}. In practice these two are often denoted simply by A.
For all objects A, B and C, there is a functor
∘
0
:
C
(
A
,
B
)
×
C
(
B
,
C
)
→
C
(
A
,
C
)
, called *horizontal composition* or *composition along a 0-cell*, which is associative and admits the identity 1 and 2-cells of id_{A} as identities. The composition symbol
∘
0
is often omitted, the horizontal composite of 2-cells
α
:
f
⇒
g
:
A
→
B
and
β
:
f
′
⇒
g
′
:
B
→
C
being written simply as
β
α
:
f
′
f
⇒
g
′
g
:
A
→
C
.
The notion of 2-category differs from the more general notion of a bicategory in that composition of 1-cells (horizontal composition) is required to be strictly associative, whereas in a bicategory it needs only be associative up to a 2-isomorphism. The axioms of a 2-category are consequences of their definition as **Cat**-enriched categories:

Vertical composition is associative and unital, the units being the identity 2-cells id_{f}.
Horizontal composition is also (strictly) associative and unital, the units being the identity 2-cells id_{idA} on the identity 1-cells id_{A}.
The interchange law holds; i.e. it is true that for composable 2-cells
α
,
β
,
γ
,
δ
(
α
∘
0
β
)
∘
1
(
γ
∘
0
δ
)
=
(
α
∘
1
γ
)
∘
0
(
β
∘
1
δ
)
The interchange law follows from the fact that
∘
0
is a functor between hom categories. It can be drawn as a pasting diagram as follows:

Here the left-hand diagram denotes the vertical composition of horizontal composites, the right-hand diagram denotes the horizontal composition of vertical composites, and the diagram in the centre is the customary representation of both.

In mathematics, a **doctrine** is simply a 2-category which is heuristically regarded as a system of theories. For example, algebraic theories, as invented by Lawvere, is an example of a doctrine, as are multi-sorted theories, operads, categories, and toposes.

The objects of the 2-category are called *theories*, the 1-morphisms
f
:
A
→
B
are called *models* of the A in B, and the 2-morphisms are called *morphisms between models.*

The distinction between a 2-category and a doctrine is really only heuristic: one does not typically consider a 2-category to be populated by theories as objects and models as morphisms. It is this vocabulary that makes the theory of doctrines worth while.

For example, the 2-category **Cat** of categories, functors, and natural transformations is a doctrine. One sees immediately that all presheaf categories are categories of models.

As another example, one may take the subcategory of **Cat** consisting only of categories with finite products as objects and product-preserving functors as 1-morphisms. This is the doctrine of multi-sorted algebraic theories. If one only wanted 1-sorted algebraic theories, one would restrict the objects to only those categories that are generated under products by a single object.

Doctrines were invented by J. M. Beck.