3

I have always disliked the amsmath commands \varinjlim and \varprojlim for categorical limits. The arrows are too big and dominating, and the whole things take up too much vertical space, messing up the line spacing. I therefore usually define my own commands, see below, and would like to know if they can be improved and made more robust? In the current form, they use \raisebox which uses absolute dimensions and therefore causes issues when used e.g. in an index (see picture below). How can my construction be improved?

This question has some interesting solutions, but one uses PGF, which seems like extreme overkill to me, and the second one does not scale properly when used e.g. in indices. Oh yes, and there is a package called halloweenmath, but I’m not sure I trust a package with such a name. I think I prefer a solution by some TeX guru in here.

\documentclass{article}

\usepackage{amsmath,graphicx}

\makeatletter \newcommand\dirlimformat[1]{ \mathop{ \smash{ \operatorname*{#1}\limits_{ {} \raisebox{.21em}[0pt][0pt]{\scalebox{.85}{$\m@th \xrightarrow{% \hphantom {% !! \scalebox{1.17}{$\m@th {\operatorname{#1}} $} !! } } $}} } } \vphantom{\textstyle\lim_n} } }

\newcommand\invlimformat[1]{ \mathop{ \smash{ \operatorname*{#1}\limits_{ {} \raisebox{.21em}[0pt][0pt]{\scalebox{.85}{$\m@th \xleftarrow{% \hphantom {% !! \scalebox{1.17}{$\m@th {\operatorname{#1}} $} !! } } $}} } } \vphantom{\textstyle\lim_n} } } \makeatother

\newcommand\dirlim{\dirlimformat{lim}} \newcommand\invlim{\invlimformat{lim}}

\begin{document}

( \varinjlim X_n ) vs.\ ( \dirlim X_n )

( \varprojlim X_n ) vs.\ ( \invlim X_n )

( a^{\invlim X_n} )

\end{document}

enter image description here

Gaussler
  • 12,801
  • Are you familiar with the old-arrows package? It generates much smaller arrowheads. – Mico Nov 17 '20 at 13:51
  • @Mico No, but it seems very much focused on Computer Modern, which is a font I avoid my all means (except when creating MWEs on TeX.SX). – Gaussler Nov 17 '20 at 13:52
  • Why do you claim that the old-arrows package is "very much focused on Computer Modern"? That's decidedly not the case. It works fine with newtxmath, mtpro2, txfonts, mathptmx, newpxmath, pxfonts, mathpazo, and likely many more math font packages too. – Mico Nov 17 '20 at 16:56
  • @Mico I just read the abstract and got that impression. Maybe I was wrong. Meanwhile, the old arrows were so much prettier. The standard CM arrows are disgusting to look at. – Gaussler Nov 17 '20 at 16:59

2 Answers2

4

The definitions of \varinjim and \varptojlim in amsopn.sty are

\def\varinjlim{%
  \mathop{\mathpalette\varlim@{\rightarrowfill@\textstyle}}\nmlimits@
}
\def\varprojlim{%
  \mathop{\mathpalette\varlim@{\leftarrowfill@\textstyle}}\nmlimits@
}

The arrows are thus always in \textstyle. You can make your own definitions (or change the default ones---with the usual caveats) using \scriptstyle

\documentclass{article}

\usepackage{amsmath}

\makeatletter \newcommand\dirlim{\mathop{\mathpalette\varlim@{\rightarrowfill@\scriptstyle}}\nmlimits@} \newcommand\invlim{\mathop{\mathpalette\varlim@{\leftarrowfill@\scriptstyle}}\nmlimits@} \makeatother

\begin{document}

\parskip=\medskipamount

( \varinjlim X_n ) vs.\ ( \dirlim X_n )

( \varprojlim X_n ) vs.\ ( \invlim X_n )

( a^{\varprojlim X_n} ) vs.\ ( a^{\invlim X_n} )

\end{document}

enter image description here

Of course this will be sub-optimal in \scriptscriptstyle; you could add a \mathpalette workaround which looks slightly less bad

\documentclass{article}

\usepackage{amsmath}

\makeatletter

% same as above \newcommand\dirlimA{\mathop{\mathpalette\varlim@{\rightarrowfill@\scriptstyle}}\nmlimits@} \newcommand\invlimA{\mathop{\mathpalette\varlim@{\leftarrowfill@\scriptstyle}}\nmlimits@}

% alternative version \def\varlim@@#1#2{% \vtop{\m@th\ialign{##\cr \hfil$#1\operator@font lim$\hfil\cr \noalign{\nointerlineskip\kern1.5\ex@} \expandafter#2\ifx#1\scriptscriptstyle\scriptscriptstyle\else\scriptstyle\fi\cr \noalign{\nointerlineskip\kern-\ex@}\cr}}% } \newcommand\dirlimB{\mathop{\mathpalette\varlim@@\rightarrowfill@}\nmlimits@} \newcommand\invlimB{\mathop{\mathpalette\varlim@@\leftarrowfill@}\nmlimits@}

\makeatother

\begin{document}

\parskip=\medskipamount

$\varinjlim_{\varinjlim_{\varinjlim}}$

$\dirlimA_{\dirlimA_{\dirlimA}}$

$\dirlimB_{\dirlimB_{\dirlimB}}$

\end{document}

enter image description here

campa
  • 31,130
  • I actually think the scriptscriptstyle \dirlimB has a bit too much spacing between the arrow and the lim. But that could of course be a result of the reduced height of the math font in scriptscriptstyle. – Gaussler Nov 17 '20 at 14:33
  • @Gaussler I see what you mean, but this is a 600% magnification screenshot. Imagine it printed at real size. On the other hand, in the present code said vertical spacing is given in terms of \ex@. Since we are already in a \mathpalette we could easily add something which scales with the current math style. – campa Nov 17 '20 at 14:36
3

You may want to use old-arrows. With the option old, the standard arrows are not modified, but we can patch \varinjlim and \varprojlim to use the smaller arrow tips.

\documentclass{article}
\usepackage{amsmath}
\usepackage[old]{old-arrows}
\usepackage{xpatch}

\makeatletter \xpatchcmd{\varinjlim}{\rightarrowfill@}{\varrightarrowfill@}{}{} \xpatchcmd{\varprojlim}{\leftarrowfill@}{\varleftarrowfill@}{}{} \makeatother

\begin{document}

[ \rightarrow\varrightarrow\varinjlim_{x\in X} \quad \varprojlim_{x\in X} ]

\end{document}

enter image description here

With even smaller arrows:

\documentclass{article}
\usepackage{amsmath}
\usepackage[old]{old-arrows}
\usepackage{xpatch}

\makeatletter \xpatchcmd{\varinjlim}{\rightarrowfill@}{\varrightarrowfill@}{}{} \xpatchcmd{\varinjlim}{\textstyle}{\scriptstyle}{}{} \xpatchcmd{\varprojlim}{\leftarrowfill@}{\varleftarrowfill@}{}{} \xpatchcmd{\varprojlim}{\textstyle}{\scriptstyle}{}{} \makeatother

\begin{document}

[ \varinjlim_{x\in X} \quad \varprojlim_{x\in X} ]

\end{document}

enter image description here

egreg
  • 1,121,712
  • Two questions: (a) How will this compare in practise to @campa‘s solution? (b) How do you most easily replicate this directly, without loading old-arrows? – Gaussler Nov 17 '20 at 17:11
  • @Gaussler The arrows are different. That's all. – egreg Nov 17 '20 at 17:22
  • As much as I like the output, I don’t quite feel comfortable about using a package whose main purpose is to return a part of TeX to its 1992 version. That feels like relying on the tabu package or some LaTeX 2.09-era solution. – Gaussler Nov 17 '20 at 17:29
  • 2
    @Gaussler No, it's a completely different matter; the old-arrows package provides additional glyphs (if called with the old option). It's a well written package fully compatible with the current LaTeX kernel. The glyphs happen to be the pre-1992 version of the arrows (which are much better than the post-1992 arrows, IMHO). – egreg Nov 17 '20 at 17:44