10

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}
robert
  • 1,285

3 Answers3

6

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}
David Carlisle
  • 757,742
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}
Mico
  • 506,678
  • 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 06: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.

yo'
  • 51,322
  • 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