3

The following code provides this result:

enter image description here

I would like to get a small "{" fitting the text and not the upper and down box.

Any idea?


\documentclass[preview]{standalone}
 \usepackage{mathtools}
 \usepackage{tikz}
 \setlength{\textwidth}{15cm}

\makeatletter \define@key{janbertdims}{align}{\def\janbert@align{\hspace{#1}}} \define@key{janbertdims}{arrow}{\def\janbert@arrow{#1}} \define@key{janbertdims}{color}{\def\janbert@color{#1}} \setkeys{janbertdims}{ align=0cm,
arrow=\bigg\downarrow, color=orange, } \newcommand\underbox[3][]{% \begingroup \setkeys{janbertdims}{#1}% the current values \underset{\mathclap{\substack{\janbert@arrow \[0.1cm] \tikz\node[draw=\janbert@color, align=center, rounded corners]{#2}; \janbert@align }}}{#3} \endgroup } \newcommand\overbox[3][]{% \begingroup \setkeys{janbertdims}{#1}% the current values \overset{\mathclap{\substack{\tikz\node[draw=\janbert@color, align=center, rounded corners]{#2}; \janbert@align \[0.1cm] \janbert@arrow }}}{#3} \endgroup } \makeatother

\begin{document} $$ a_{n+2}=b_n a_n \underbox[align=2cm]{ $a_n=b_{n-2}a_{n-2}$}{=} b_n b_{n-2} a_{n-2}\underbox[align=0.6cm,arrow={\Bigg\downarrow}]{$a_{n-2}=b_{n-4}a_{n-4}$}{=} \dots \overbox[align=4.25cm]{this process concludes when \[0.1cm] $n-2k$ is $0$ ou $1$}{=} \begin{cases} b_n b_{n-2}\dots b_{2} b_0 a_0 \overbox{$a_0=0$}{=}0 & \text{if $n=2k$} \ b_n b_{n-2} \dots b_3b_1 a_1 \underbox{$a_1=1$ }{=} b_n b_{n-2} \dots b_3b_1 & \text{if $n=2k+1$} \end{cases} $$ \end{document}

Mico
  • 506,678

1 Answers1

3

I suggest you encase the first part of the first row in the cases environment in a \smash[t]{...} wrapper and the first part of the second row in a \smash[b]{...} wrapper. This works because the bubbles to the left of the cases environment exceed the height and depth of the bubbles inside the cases environment.

I would also replace 3 of the 4 instances of \dots with \dotsb.

Oh, and don't use $$ to initiate and terminate displaymath mode in a LaTeX document. For more information on this subject, please see the posting Why is \[ ... \] preferable to $$ ... $$?

enter image description here

\documentclass[preview,,border=2pt]{standalone}
 \usepackage{mathtools}
 \usepackage{tikz}
 \setlength{\textwidth}{15cm}

\makeatletter \define@key{janbertdims}{align}{\def\janbert@align{\hspace{#1}}} \define@key{janbertdims}{arrow}{\def\janbert@arrow{#1}} \define@key{janbertdims}{color}{\def\janbert@color{#1}} \setkeys{janbertdims}{ align=0cm,
arrow=\bigg\downarrow, color=orange, } \newcommand\underbox[3][]{% \begingroup \setkeys{janbertdims}{#1}% the current values \underset{\mathclap{\substack{\janbert@arrow \[0.1cm] \tikz\node[draw=\janbert@color, align=center, rounded corners]{#2}; \janbert@align }}}{#3} \endgroup } \newcommand\overbox[3][]{% \begingroup \setkeys{janbertdims}{#1}% the current values \overset{\mathclap{\substack{\tikz\node[draw=\janbert@color, align=center, rounded corners]{#2}; \janbert@align \[0.1cm] \janbert@arrow }}}{#3} \endgroup } \makeatother

\begin{document} [ a_{n+2}=b_n a_n \underbox[align=2cm]{ $a_n=b_{n-2}a_{n-2}$}{=} b_n b_{n-2} a_{n-2}\underbox[align=0.6cm,arrow={\Bigg\downarrow}]{$a_{n-2}=b_{n-4}a_{n-4}$}{=} \dots \overbox[align=4.25cm]{this process concludes when \[0.1cm] $n-2k$ is $0$ ou $1$}{=} \begin{cases} \smash[t]{b_n b_{n-2}\dotsb b_{2} b_0 a_0 \overbox{$a_0=0$}{=}0} & \text{if $n=2k$} \ \smash[b]{b_n b_{n-2} \dotsb b_3b_1 a_1 \underbox{$a_1=1$ }{=} b_n b_{n-2} \dotsb b_3b_1} & \text{if $n=2k+1$} \end{cases} ] \end{document}

Mico
  • 506,678
  • Thanks!! Your answer was perfect. You are really good!! – Barrientos Sep 15 '20 at 00:47
  • I wanted to use the answer of the problem to improve the command \overbox and \underbox that I implemented. I see that this is not possible as I did because affect to part that are not include in the argumentos of the command. Anyway – Barrientos Sep 15 '20 at 00:54
  • @Barrientos - Glad you found my answer useful. :-) About modifying \overbox and \underbox: I'm not sure I understand what you're trying to achieve. Are you maybe trying to include \smash in one of the arguments of these commands? – Mico Sep 15 '20 at 04:34
  • Yes it is. I wanted to include in the definition of \overbox some structure that allows me to control this type of problem. Another typical problem, that \overbox has, is the following: when it is located in a splitting equation the box appear in between of the lines. Sometimes this is not the effect that one want to get. I use your answer \smash[t]{...} to control this. But I do not know if one could implement some structure inside of the definition of \overbox that could provide a priori this control. – Barrientos Sep 16 '20 at 23:48