4

please consider following code:

\documentclass[a4paper]{article}

\usepackage{ngerman}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}

\newcommand{\uunderline}[1]{\underline{\underline{#1}}}

\begin{document}
\[  
    s=\left(
    a_1,
    \underset{\big\uparrow}{a_2},
    a_3,
    \uunderline{a_4},
    a_5,
    a_6
    \underset{\underset{\big{a_0}}{\big\uparrow}}{,}
    a_7,
    d^{\left(k\right)},
    a_8,
    a_9
    \right)
\]
\end{document}

enter image description here

  1. As you see the \underset produces ugly spacing around the comma. Is it possbile to prevent that so the commas and thier spacings are all the same?
  2. Is it possible to let the left/right-parenthesis not to consider the \underset's / \uparrow's?
  3. With my Miktex distribution pdflatex throws a error: Missing delimiter (. inserted). ...set{\underset{\big{a_0}}{\big\uparrow}}{,}. I guess thats related to the \big but if leave it out the a_0 gets too small (desired is the same size as the other a_i's). How can I fix that?

4 Answers 4

0

The stackengine package has an explicit definition\useanchorwidth which, if set True), ignores the width of the stacked material and takes only the width of the "anchor" material. Of course you have to use the stackengine syntax.

Optional arguments are available to change the gap of the underset, as demonstrated in the case of the a_0 term.

\documentclass[a4paper]{article}
\usepackage{ngerman}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{stackengine}
\def\useanchorwidth{T}
\stackMath
\newcommand{\uunderline}[1]{\underline{\underline{#1}}}
\begin{document}
\[
    s=\bigl(
    a_1,
    \stackunder{a_2}{\scriptstyle\big\uparrow},
    a_3,
    \uunderline{a_4},
    a_5,
    a_6
    \stackunder[8pt]{,{}}{\stackunder{\scriptstyle\big\uparrow}{a_0}}
    a_7,
    d^{\left(k\right)},
    a_8,
    a_9
    \bigr)
\]
\end{document}

enter image description here

2
  • there's an awfully large gap above the second arrow. Commented Apr 6, 2016 at 18:16
  • @barbarabeeton It was done purely for demonstration purposes, as explained in the last line of the text before the MWE. Commented Apr 6, 2016 at 18:27
2

this approach requires mathtools rather than amsmath.

the two \underset elements can be ignored by using \smash; note that this eliminated depth will have to be compensated for later if something is to print below this equation. since the height of either smashed element is not greater than that of the unsmashed elements, no compensation is needed.

the a_0 below the second arrow can be restored to normal size by setting it in an \mbox, which doesn't scale, and its width can be ignored by setting all that within \mathclap.

since the arrow is also wider than the comma, that also needs to be enclosed in the \mathclap, but that leaves the width of that element a bit narrow, so the comma looks too tight. therefore, the class of that entire element is reset to \mathpunct to restore the proper comma behavior.

finally, the \mboxed a_0 is closer to the arrow than it would be if left unboxed, so a \mathstrut is inserted to restore the height.

a bit complicated, but it gives good practice at segmenting math structures and putting them back together with the proper spacing.

\documentclass[a4paper]{article}

\usepackage{ngerman}
\usepackage[utf8]{inputenc}
%\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{amssymb}

\newcommand{\uunderline}[1]{\underline{\underline{#1}}}

\begin{document}
\thispagestyle{empty}
\[  
    s=\left(
    a_1,
   \smash{\underset{\big\uparrow}{a_2}},
    a_3,
    \uunderline{a_4},
    a_5,
    a_6
    \mathpunct{
     \smash{\underset{\mathclap{\underset{\mbox{$a_0\mathstrut$}}{\big\uparrow}}}{,}}}
    a_7,
    d^{\left(k\right)},
    a_8,
    a_9
    \right)
    \vphantom{\underset{\mathclap{\underset{\mbox{$a_0\mathstrut$}}{\big\uparrow}}}{,}}
\]
\end{document}

output of example code

edit:

Prompted by a comment, a \vphantom has been added so that text following the display will be spaced properly. (Again, not tested.)

6
  • You sure about the vertical spacing of what follows?
    – egreg
    Commented Apr 6, 2016 at 19:36
  • @egreg -- you mean the space between the arrow and the a^0 or the likelihood that the \smash will leave the expression with no depth greater than the parens and double underline? (i didn't test that, so didn't want to swear to it.) Commented Apr 6, 2016 at 20:07
  • I meant: try with some text after the equation. There will be overlap, because of \smash.
    – egreg
    Commented Apr 6, 2016 at 20:08
  • @egreg -- i did mention that, in the second paragraph (but weaseled because i didn't actually test it). of course, if i'd been smart enough to use \big rather than \left, etc., that wouldn't have been a concern, and i could have forgotten about the \smash. Commented Apr 6, 2016 at 20:14
  • 1
    you should always complement your smashs with vphantoms.
    – peter
    Commented May 7, 2021 at 19:00
1

Just don't use \left and \right, whilst fixing the underset in a different way.

\documentclass[a4paper]{article}

\usepackage{ngerman}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}

\newcommand{\uunderline}[1]{\underline{\underline{#1}}}

\begin{document}
\[
    s=\bigl(
    a_1,
    \underset{\big\uparrow}{a_2},
    a_3,
    \uunderline{a_4},
    a_5,
    a_6
    \mathpunct{\underset{\underset{\makebox[0pt]{$a_0$}}{\makebox[0pt]{$\big\uparrow$}}}{,}}
    a_7,
    d^{\left(k\right)},
    a_8,
    a_9
    \bigr)
\]
\end{document}

enter image description here

More human input:

\documentclass[a4paper]{article}

\usepackage{ngerman}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}

\newcommand{\uunderline}[1]{\underline{\underline{#1}}}

\makeatletter
\newcommand{\zerounderset}[3][\mathord]{%
  #1{\vtop{
    \let\\\cr
    \baselineskip\z@skip\lineskip.25ex
    \ialign{\hidewidth$##$\hidewidth\crcr
      \omit$#3$\cr
      #2\crcr
    }%
  }}%
}
\makeatother

\begin{document}
\[  
    s=\bigl(
    a_1,
    \zerounderset{\big\uparrow}{a_2},
    a_3,
    \uunderline{a_4},
    a_5,
    a_6
    \zerounderset[\mathpunct]{\big\uparrow\\a_0}{,}
    a_7,
    d^{\left(k\right)},
    a_8,
    a_9
    \bigr)
\]
\end{document}
0

Three suggestions and a comment:

  • Load the ulem package and use its \uuline macro instead of defining a macro called \uunderline.

  • Use the \substack and \mathclap macros to place the arrow and a_0 terms below the comma. If desired, use a \mathpunct directive to assure the normal spacing around the comma in question.

  • Don't autosize the parentheses; instead, use \bigl( and \bigr).

  • Incidentally, the ngerman package is deprecated; load babel with the option ngerman instead.

enter image description here

\documentclass[a4paper]{article}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{mathtools}
\usepackage[normalem]{ulem}  % <- new 

\begin{document}
\[  
    s=\bigl(
    a_1,
    \underset{\big\uparrow}{a_2},
    a_3,
    \uuline{a_4},
    a_5,
    a_6
    \mathpunct{\underset{\mathclap{\substack{\big\uparrow \\ \textstyle a_0}}}{,}}
    a_7,
    d^{(k)},
    a_8,
    a_9
    \bigr)
\]
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .