[Tex/LaTex] New command for filtered colimits and limits

macros

I would like to define a new command (called colim) for filtered colimit (also sometimes called direct limit …) as nice as the command $\varinjlim$ in amsmath package.

So far, I tried $\newcommand{\colim{\operatornamewithlimits{\underset{\longrightarrow{colim}}$

but I find the arrow too thin and its positioning too low compare to $\varinjlim$. How can I get exactly the same (and centered) arrow than this command ?

Edit: with the answer of egreg, it is easy to also get a new command for filtered limit obviously (called colim with a leftarrow below)

Best Answer

Adapt the definition of \varinjlim:

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand{\colim@}[2]{%
  \vtop{\m@th\ialign{##\cr
    \hfil$#1\operator@font colim$\hfil\cr
    \noalign{\nointerlineskip\kern1.5\ex@}#2\cr
    \noalign{\nointerlineskip\kern-\ex@}\cr}}%
}
\newcommand{\colim}{%
  \mathop{\mathpalette\colim@{\rightarrowfill@\textstyle}}\nmlimits@
}
\makeatother

\begin{document}

\[
\colim_{\delta\in\Delta}F_\delta=F
\]

\end{document}

enter image description here

A variant, suggested by Manuel, with a smaller arrow. However, this also requires a redefinition of \varprojlim and \varinjlim for uniformity:

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand{\colim@}[2]{%
  \vtop{\m@th\ialign{##\cr
    \hfil$#1\operator@font colim$\hfil\cr
    \noalign{\nointerlineskip\kern1.5\ex@}#2\cr
    \noalign{\nointerlineskip\kern-\ex@}\cr}}%
}
\newcommand{\colim}{%
  \mathop{\mathpalette\colim@{\rightarrowfill@\scriptscriptstyle}}\nmlimits@
}
\renewcommand{\varprojlim}{%
  \mathop{\mathpalette\varlim@{\leftarrowfill@\scriptscriptstyle}}\nmlimits@
}
\renewcommand{\varinjlim}{%
  \mathop{\mathpalette\varlim@{\rightarrowfill@\scriptscriptstyle}}\nmlimits@
}
\makeatother

\begin{document}

\[
\colim_{\delta\in\Delta}F_\delta
\quad
\varinjlim_{\delta\in\Delta}F_\delta
\quad
\varprojlim_{\delta\in\Delta}F_\delta
\]

\end{document}

enter image description here

Related Question