TransWikia.com

Nested Undersets

TeX - LaTeX Asked by underset-nester on April 29, 2021

how would you achieve something like this?

desired output

right now my code looks like this:

90underset{+90}{underset{huge smile}{underset{+90}{underset{huge smile}{}}180underset{+180}{underset{huge smile}{}}}}360underset{+240}{underset{huge smile}{}}600

The code itself is obviously a huge mess but it produces the output above, the problem is that I can’t seem to get the second nested underset working, by that i mean the underset which is not in the figure from +180 to +240. Any ideas? Also, if you have a better way of doing this, please tell me 😛

3 Answers

Here, I introduce

bsmile[<under-depth-offset>]{<main-text>}{<underset-text>}

If #2 is blank, the width of the typeset is derived from the smile...otherwise it is derived from the width of #2.

The MWE

documentclass{article}
usepackage{stackengine}
newcommandbsmile[3][0pt]{ifrelax#2relaxdeftmp{F}elsedeftmp{T}fi
  ensurestackMath{stackengine{#1}{#2}{%
  stackengine{1pt}{mbox{huge$smile$}}{scriptstyle#3}{U}{c}{F}{T}{S}}
  {U}{c}{F}{tmp}{S}}}
begin{document}

$90bsmile{}{+90}bsmile[16pt]{180}{+90}bsmile{}{+180}360bsmile{}{+240}600$
end{document}

enter image description here

Correct answer by Steven B. Segletes on April 29, 2021

Here is a simple array.

documentclass[fleqn]{article}
usepackage{mathtools}
usepackage{relsize}
newcommand{scriptclap}[1]{mathclap{scriptstyle #1}}
newcommand{LargerSmile}{mathlarger{mathlarger{mathlarger{mathlargersmile}}}}
begin{document}
Some text.
[ begin{array}[t]{*7{c@{}}}
 90 && 180 && 360 && 600[-1ex]
 & LargerSmile & & LargerSmile & & LargerSmile &[-1ex]
 &scriptclap{+90} & &scriptclap{+180} && scriptclap{+240}&[-1ex]
 & & LargerSmile & & & &[-1ex]
 & & scriptclap{+90} & & & &
end{array} quaddots text{more stuff} ]
More text.
end{document}

enter image description here

The more stuff is just to show that you can align the top row with other parts of the formula. If this is not needed, remove [t] after begin{array}.

For more complicated tasks I recommend TikZ with the tikzmark library.

Answered by user229669 on April 29, 2021

With a not so complicated syntax:

documentclass{article}
usepackage{amsmath,array}

newcommand{differences}[1]{%
  begingroup
  def?##1{hidewidthscriptstylemathstrut##1hidewidthkern0pt}%
  defU{mbox{huge$smile$}}%
  settowidth{dimen255}{U}
  renewcommand{arraystretch}{0}%
  setlength{arraycolsep}{0pt}%
  begin{array}{*{20}{w{c}{dimen255}}}
  #1
  end{array}%
  endgroup
}

begin{document}

[
differences{
  90 && 180 && 360 && 600 
  & U && U && U  
  & ?{+90} && ?{+180} && ?{+240} 
  && U && U 
  && ?{+90} && ?{+60} 
  &&& U 
  &&& ?{+30}
}
]

[
differences{
  640 && 231 && 100 && 91 && 1003 
  & U && U && U && U 
  & ?{-409} && ?{-131} && ?{-9} && ?{+912} 
  && U && U && U 
  && ?{+278} && ?{+122} && ?{921} 
  &&& U && U 
  &&& ?{-156} && ?{+799} 
  &&&& U 
  &&&& ?{955}
}
]

end{document}

No more than four digits in the main numbers.

enter image description here

Answered by egreg on April 29, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP