TransWikia.com

Align a box in the formula

TeX - LaTeX Asked by Barrientos on September 18, 2020

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}{defjanbert@align{hspace{#1}}}
 define@key{janbertdims}{arrow}{defjanbert@arrow{#1}}
 define@key{janbertdims}{color}{defjanbert@color{#1}}
 setkeys{janbertdims}{
   align=0cm,        
   arrow=biggdownarrow,
   color=orange,
  }
  newcommandunderbox[3][]{%
    begingroup
      setkeys{janbertdims}{#1}% the current values
      underset{mathclap{substack{janbert@arrow [0.1cm] 
      tikznode[draw=janbert@color, align=center, rounded corners]{#2}; janbert@align }}}{#3} 
    endgroup
  }
  newcommandoverbox[3][]{%
   begingroup
     setkeys{janbertdims}{#1}% the current values
     overset{mathclap{substack{tikznode[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={Biggdownarrow}]{$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}

One Answer

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}{defjanbert@align{hspace{#1}}}
 define@key{janbertdims}{arrow}{defjanbert@arrow{#1}}
 define@key{janbertdims}{color}{defjanbert@color{#1}}
 setkeys{janbertdims}{
   align=0cm,        
   arrow=biggdownarrow,
   color=orange,
  }
  newcommandunderbox[3][]{%
    begingroup
      setkeys{janbertdims}{#1}% the current values
      underset{mathclap{substack{janbert@arrow [0.1cm] 
      tikznode[draw=janbert@color, align=center, rounded corners]{#2}; janbert@align }}}{#3} 
    endgroup
  }
  newcommandoverbox[3][]{%
   begingroup
     setkeys{janbertdims}{#1}% the current values
     overset{mathclap{substack{tikznode[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={Biggdownarrow}]{$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}

Answered by Mico on September 18, 2020

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