TransWikia.com

How to center the middle term with two inequalities in LaTeX?

TeX - LaTeX Asked by thandar_patrick on March 28, 2021

Can someone please help me with centering the middle term here?

begin{align*}
    Big|f(x)-T^{(3)}(x,0)Big| &leq frac{|f^{(4)}(xi)}{4!} x^4 &&leq frac{x^4}{4!} 
    x-frac{x^3}{3!}-frac{x^4}{4!} &leq sin x &&leq x-frac{x^3}{3!}+frac{x^4}{4!} 
    -frac{x^3}{3!}-frac{x^4}{4!} &leq sin x - x &&leq -frac{x^3}{3!}+frac{x^4}{4!} 
    -frac{1}{3!}-frac{x}{4!} &leq frac{sin x - x}{x^3} &&leq -frac{1}{3!}+frac{x}{4!} 
end{align*}

Thanks so much in advance!

One Answer

You can do it with an array.

I show two realizations, in the second one the top row is globally centered with respect to the derivations below. Take your pick, I'd prefer the latter.

documentclass{article}
usepackage{amsmath,array}

begin{document}

begin{equation*}
setlength{arraycolsep}{0pt}
renewcommand{arraystretch}{2.4}
begin{array}{
  >{displaystyle}r 
  >{{}}c<{{}}
  >{displaystyle}c
  >{{}}c<{{}}
  >{displaystyle}l
}
bigl|f(x)-T^{(3)}(x,0)bigr|   &leq& frac{|f^{(4)}(xi)|}{4!}x^4 &leq& frac{x^4}{4!} 
x-frac{x^3}{3!}-frac{x^4}{4!} &leq& sin x                       &leq& x-frac{x^3}{3!}+frac{x^4}{4!} 
-frac{x^3}{3!}-frac{x^4}{4!}  &leq& sin x - x                   &leq& -frac{x^3}{3!}+frac{x^4}{4!} 
-frac{1}{3!}-frac{x}{4!}      &leq& frac{sin x - x}{x^3}       &leq& -frac{1}{3!}+frac{x}{4!} 
end{array}
end{equation*}

begin{gather*}
  bigl|f(x)-T^{(3)}(x,0)bigr|leq frac{|f^{(4)}(xi)|}{4!}x^4 leq frac{x^4}{4!}

setlength{arraycolsep}{0pt}
renewcommand{arraystretch}{2.4}
begin{array}{
  >{displaystyle}r 
  >{{}}c<{{}}
  >{displaystyle}c
  >{{}}c<{{}}
  >{displaystyle}l
}
x-frac{x^3}{3!}-frac{x^4}{4!} &leq& sin x                 &leq& x-frac{x^3}{3!}+frac{x^4}{4!} 
-frac{x^3}{3!}-frac{x^4}{4!}  &leq& sin x - x             &leq& -frac{x^3}{3!}+frac{x^4}{4!} 
-frac{1}{3!}-frac{x}{4!}      &leq& frac{sin x - x}{x^3} &leq& -frac{1}{3!}+frac{x}{4!} 
end{array}
end{gather*}

end{document}

With >{displaystyle}r we specify a right aligned column with math set in displaystyle; similarly for c and l.

With >{{}}c<{{}} we set a centered column where the entry is surrounded by {}...{}, so as to trigger the automatic spacing around a relation symbol.

The intercolumn space is set to zero, so just those automatically inserted spaces will govern the table. The parameter arraystretch is set to a rather large value in order to accommodate the fractions.

enter image description here

Correct answer by egreg on March 28, 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