9

how would you achieve something like this?

desired output

right now my code looks like this:

90\underset{+90}{\underset{\huge \smile}{\underset{+90}{\underset{\huge \smile}{}}180\underset{+180}{\underset{\huge \smile}{}}}}360\underset{+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 :P

  • Welcome to TeX.SE. – Mico Nov 29 '20 at 21:37
8

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}
\newcommand\bsmile[3][0pt]{\if\relax#2\relax\def\tmp{F}\else\def\tmp{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}

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

enter image description here

6

With a not so complicated syntax:

\documentclass{article}
\usepackage{amsmath,array}

\newcommand{\differences}[1]{%
  \begingroup
  \def\?##1{\hidewidth\scriptstyle\mathstrut##1\hidewidth\kern0pt}%
  \def\U{\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

6

Here is a simple array.

\documentclass[fleqn]{article}
\usepackage{mathtools}
\usepackage{relsize}
\newcommand{\scriptclap}[1]{\mathclap{\scriptstyle #1}}
\newcommand{\LargerSmile}{\mathlarger{\mathlarger{\mathlarger{\mathlarger\smile}}}}
\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} \quad\dots \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.

  • that's a nice solution thank you very much – underset-nester Nov 29 '20 at 22:18

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.