"A Category Object in another Category"? In a seminar I heard things like a groupoid in the category of vector bundles, a group in the category (..). 
Since I don't know much category theory I'm wondering if there is a general theory of things like a category object in another category? If so, what would be references?
Thanks
 A: My favorite references are the treatment in Vol. 1 of Borceux's Handbook of Categorical Algebra and that of Johnstone's Topos Theory.
The guiding idea is that in $\mathbf{Set}$ a small category can be described as a pair of sets and morphisms with certain commutativity conditions. The generalised idea is that an internal category is a pair of objects, one for the "morphisms" and one for the "objects" with morphisms that do the work of domain and codomain, composition, and assignment of identities that satisfy the category axioms. From there one can define internal functors, internal presheaves, internal limits, etc.
A: Indeed there's a fun way to define what are called internal categories to a category $\mathcal C$, at least when it has pullbacks.
Recall that a $2$-category is just like a category, but now with 2-morphisms between morphims. A monad in a $2$-category $\mathcal A$ is just an object $a$, a morphism $t:a\to a$ and two 2-morphisms $\eta:1_a\to t$ and $\mu:t^2\to t$ such that $\mu\circ \mu t=\mu \circ t\mu$ and $\mu\circ t\eta=\mu\circ \eta t=1_t$. (compare with the usual notion of monads: they're monads in the 2-category of categories, functors and natural transformations)
Now, define a 2-category $\mathtt{span}(\mathcal C)$ as follows:

*

*its objects are the objects in $\mathcal C$ ;

*a morphism $x\to y$ is a span in $\mathcal C$, that is a pair of morphisms $x\stackrel{f_s}{\leftarrow} t\stackrel{f_t}{\rightarrow} y$. Composition of two morphisms $x\stackrel{f_s}{\leftarrow} t\stackrel{f_t}{\rightarrow} y$ and $y\stackrel{g_s}{\leftarrow} t'\stackrel{g_t}{\rightarrow} z$ is given by the pullback $(a,b)$ of $f_t$ and $g_s$ : $x\stackrel{f_s\circ a}{\leftarrow} t\times_y t'\stackrel{g_t\circ b}{\rightarrow} z$ ;

*a 2-morphism $(x\stackrel{f_s}{\leftarrow} t\stackrel{f_t}{\rightarrow} y)\to (x\stackrel{g_s}{\leftarrow} t'\stackrel{g_t}{\rightarrow} y)$ is just a map $h:t\to t'$ making the obvious diagram commute ($g_s=f_s\circ h, g_t=f_t\circ h$).

Then a category internal to $\mathcal C$ is just a monad in the $2$-category $\mathtt{span}(\mathcal C)$! Lets see how by unwrapping the definitions. Such a monad is given by:

*

*an object $o$ in $\mathtt{span}(\mathcal C)$, that is an object in $\mathcal C$ that we should think about as the object of objects ;

*a morphism $(s,t):o\to o$ in $\mathtt{span}(\mathcal C)$, that is a $\mathcal C$-object $m$ (that we should think about as the object of morphisms) together with a pair of morphisms $s:m\to o$ (the source map) and $t:m\to o$ (the target map) ;

*a 2-morphism $\mathtt{id}:1_o\to (s,t)$, that is a map $\mathtt{id}:o\to m$, (the identity assignation map) such that $s\circ \mathtt{id}=1_o$ and $t\circ \mathtt{id}=1_o$ (the source and the target of the identity morphism of an object should be the object itself) ;

*a 2-morphism $\mathfrak c: (s,t)^2\to (s,t)$ (the composition map), that is a morphism from the pullback of $(t,s)$ to $m$. Pullback encodes the fact that you should only compose morphisms whose target and source match, and the source (resp. target) of the composed morphism is the source (resp. target) of the first morphism (resp. second).

such that :

*

*$\mathfrak c\circ (s,t)\mathtt{id}=1_{(s,t)}=\mathfrak c\circ \mathtt{id}(s,t)$ : by writting down the relevant diagrams and pullbacks, one can read that it means that composing identity amounts to doing nothing : that's the internal unitarity of composition axiom ;

*$\mathfrak c \circ \mathfrak c(s,t)=\mathfrak c\circ (s,t)\mathfrak c$ : this one is the internal associativity of composition axiom.

So, in short, an internal category to $\mathcal C$ is:

*

*an object of objects $o$ and an object of morphisms $m$ ;

*two morphisms $s,t:m\to o$ that "assigns to a morphism its source and its target" ;

*a morphism $\mathtt{id}:o\to m$ that "assigns to each object an identity morphism", such that its source and its target is the object itself ;

*a morphism $\mathfrak c:m\times_o m\to m$ that "assigns to each compatible pair of morphisms their composition", whose source and target are the ones expected ;

*those respect the usual internalized axioms, such as unitarity and associativity.

Furthermore, you can define a groupoid internal to $\mathcal C$ as all of the above with an additional morphism $i:m\to m$ (an internal inversion) such that :

*

*$s\circ i=t$ and $t\circ i=s$ (the inversion swaps source and target) ;

*$\mathfrak c \circ (i\times 1_m)\circ \Delta_t = \mathtt{id}\circ s$ with $\Delta_t:m\to m\times_o^{t,t} m$ being the diagonal morphism into the pullback of $t$ along itself : "composing on the left with the inverse yields the identity of the source" ;

*$\mathfrak c \circ (1_m\times i)\circ \Delta_s = \mathtt{id}\circ t$ with $\Delta_s:m\to m\times_o^{s,s} m$ being the diagonal morphism into the pullback of $s$ along itself : "composing on the right with the inverse yields the identity of the target".

I hope that answer helps you!
