9

Assume the following MWE/Screenshot. How to get the "limits" x and y correctly vertically aligned?

I tried already: \mathstrut and \vphantom{g} as discussed in How to align limits of double integrals? but not a lot of luck.

enter image description here

MWE:

\documentclass{article}
\usepackage{amsmath}
\newcommand{\argmin}{\operatornamewithlimits{argmin}}
\newcommand{\bla}{\operatornamewithlimits{blabla}}
\begin{document}
\begin{equation}
\argmin_{x...} \bla_{y...} .....
\end{equation}
\end{document}
  • In additions see \adjustlimits from mathtools. – daleif Sep 12 '15 at 13:55
  • @daleif - I anticipated your suggestion with my answer. :-) – Mico Sep 12 '15 at 23:13
5

enter image description here

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\newcommand{\argmin}{\operatornamewithlimits{\mathstrut argmin}}
\newcommand{\bla}{\operatornamewithlimits{\mathstrut blabla}}
\begin{equation}
\argmin_{x...} \bla_{y...} .....
\end{equation}
\renewcommand{\argmin}{\operatornamewithlimits{argmin}}
\renewcommand{\bla}{\operatornamewithlimits{\vphantom{\mathrm{g}}blabla}}
\begin{equation}
\argmin_{x...} \bla_{y...} .....
\end{equation}
\renewcommand{\argmin}{\operatornamewithlimits{\smash{\mathrm{argmin}}}}
\renewcommand{\bla}{\operatornamewithlimits{blabla}}
\begin{equation}
\argmin_{x...} \bla_{y...} .....
\end{equation}
\end{document}
  • Thanks. So you need to use \mathstruts in the line itself, and not in the 'limits' part. – robert Sep 12 '15 at 10:47
  • @jos -- you need the \mathstruts on both the line itself and in the limits. easy to demonstrate by using, say, a d as a limit. – barbara beeton Sep 12 '15 at 13:13
  • Hmm, \operatornamewithlimits has become \operatorname* several years ago. – egreg Sep 12 '15 at 21:33
  • @egreg thought I didn't recognise it but copied from OP:-) – David Carlisle Sep 12 '15 at 22:28
6

Instead of modifying the macros \argmin and \bla to include math-struts, I suggest you load the mathtools package -- a superset of the amsmath package -- and use that package's \adjustlimits macro to align the expressions in the limits.

Remark: As @egreg has noted in a comment, the instruction \operatornamewithlimits has been deprecated for quite a few years. I suggest you use \DeclareMathOperator* instead.

enter image description here

\documentclass{article}
\usepackage{mathtools}% for "\adjustlimits"
\usepackage{amsfonts} % for "\mathfrak"
% Use "\DeclareMathOperator*" instead of "\operatornamewithlimits"
\DeclareMathOperator*{\argmin}{arg\,min} 
\DeclareMathOperator*{\bla}{blabla}
\begin{document}
\begin{align*}
\text{without \texttt{\string\adjustlimits}:} \quad
&\argmin_{x\in\mathfrak{X}} \bla_{y\in\mathfrak{Y}} \dots\\
\text{with \texttt{\string\adjustlimits}:} \quad
&\adjustlimits\argmin_{x\in\mathfrak{X}} \bla_{y\in\mathfrak{Y}} \dots
\end{align*}
\end{document}
  • This is the correct answer. But, please, also fix it with \DeclareMathOperator*{\argmin}{arg\,min} (the \, is better, in my opinion) and similarly for \bla. Note that \operatornamewithlimits has been deprecated several years ago in favor of \operatorname*. – egreg Sep 12 '15 at 21:37
  • @egreg - Thanks! I've implemented both of your suggestions. – Mico Sep 12 '15 at 23:13
  • \arglimits? Typo in your text? – daleif Sep 13 '15 at 6:07
0

I don't have TL installed, but this should work:

\documentclass{article}
\usepackage{amsmath}
\newcommand{\argmin}{\operatornamewithlimits{argmin}}
\newcommand{\blawithdepth}{\operatornamewithlimits{bla\vphantom{g}bla}}
\newcommand{\bla}{\operatornamewithlimits{blabla}}
\begin{document}
\begin{equation}
\argmin_{x...} \blawithdepth_{y...} .....
\end{equation}
\end{document}

Use \bla where it's fine, and \blawithdepth where you want the limits to align. However, I would recommend simply keeping them unaligned.

  • I use something similar for \cos: I have some situations where a symmetry with \sin, which has an ascender; I'd not generally add struts to operator names otherwise. – egreg Sep 12 '15 at 21:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.