TransWikia.com

Spacing in alignedat

TeX - LaTeX Asked by daesung kim on December 18, 2020

If I compare the two equations below, the space between the brace and the first line of the cases

(-f_{0}) is different. I know that if I put hspace{-0.1cm} before left{ of the

second equation, I can adjust the extra space, but is there any fundamental way to remove the space

made when I start alignedat with &?

Or, you may suggest a totally different method to type the equation that I want.

begin{equation*}
(G^{*} vec{x}^{*})(vec{w}^{*})=
left{
begin{alignedat}{3}
&-f_{0}^{*}(vec{x}_{0}^{*})&&-(f_{1}^{*} upsilon_{1}^{*})(vec{x}_{1}^{*})-cdots-(f_{m}^{*} upsilon_{m}^{*})(vec{x}_{m}^{*}) 
&&&text {if } vec{u}^{*} geq vec{0} text { and } vec{x}_{0}^{*}+cdots+vec{x}_{m}^{*}=vec{x}^{*}, 
&-infty &&text {otherwise}.
end{alignedat}right.
end{equation*}

enter image description here

begin{equation*}
(G^{*} vec{x}^{*})(vec{w}^{*})=
left{
begin{alignedat}{3}
-f_{0}^{*}(vec{x}_{0}^{*})&&-(f_{1}^{*} upsilon_{1}^{*})(vec{x}_{1}^{*})-cdots-(f_{m}^{*} upsilon_{m}^{*})(vec{x}_{m}^{*}) 
&&text {if } vec{u}^{*} geq vec{0} text { and } vec{x}_{0}^{*}+cdots+vec{x}_{m}^{*}=vec{x}^{*}, 
-infty &&text {otherwise}.
end{alignedat}right.
end{equation*}

enter image description here

2 Answers

Since you need to choose the alignment point anyway, I propose a different approach, where you state the desired width of the object (default 3em):

documentclass{article}
usepackage{amsmath}

renewcommand{vec}[1]{mathbf{#1}}

newcommand{splitcase}[2][3em]{%
  makebox[#1][l]{$displaystyle#2$} &
  settowidth{dimen0}{$displaystyle#2$}%
  addtolength{dimen0}{-1em}%
  hspace*{dimen0}%
  
}

begin{document}

begin{equation*}
(G^{*} vec{x}^{*})(vec{w}^{*})=
begin{cases}
splitcase{
  -f_{0}^{*}(vec{x}_{0}^{*})
  -(f_{1}^{*} upsilon_{1}^{*})(vec{x}_{1}^{*})
  -dots
  -(f_{m}^{*} upsilon_{m}^{*})(vec{x}_{m}^{*})
}
  &text{if $vec{u}^{*} geq vec{0}$ and
         $vec{x}_{0}^{*}+dots+vec{x}_{m}^{*}=vec{x}^{*}$},

-infty &text{otherwise}.
end{cases}
end{equation*}

begin{equation*}
(G^{*} vec{x}^{*})(vec{w}^{*})=
begin{cases}
splitcase[5em]{
  -f_{0}^{*}(vec{x}_{0}^{*})
  -(f_{1}^{*} upsilon_{1}^{*})(vec{x}_{1}^{*})
  -dots
  -(f_{m}^{*} upsilon_{m}^{*})(vec{x}_{m}^{*})
}
  &text{if $vec{u}^{*} geq vec{0}$ and
         $vec{x}_{0}^{*}+dots+vec{x}_{m}^{*}=vec{x}^{*}$},

-infty &text{otherwise}.
end{cases}
end{equation*}

end{document}

enter image description here

Correct answer by egreg on December 18, 2020

I wouldn't change much about the setup of the first equation except (a) make sure the - symbol at the start of the math rows is typeset as a unary symbol, (b) change begin{alignedat}{3} to begin{alignedat}{2}, and (c) leave a bit more whitespace between rows 2 and 3. Whether to use arrow accents or bold-facing a vector is largely a matter of taste; if you use the arrow method, be sure to leave a bit of space before the superscript * symbols.

The spacing around the curly brace is unchanged if one uses begin{cases} ... end{cases} instead of left{ ... right.

enter image description here

documentclass{article}
usepackage{amsmath} % for 'alignedat' env and 'text' macro
usepackage{bm} % for 'bm' macro
begin{document}

begin{align*}
(G^{*} vec{x}^{mkern1.5mu*})(vec{w}^{mkern1.5mu*})
&= left{
begin{alignedat}{2}
&{-}f_{0}^{*}(vec{x}_{0}^{mkern1.5mu*})
  &&-(f_{1}^{*} upsilon_{1}^{*})(vec{x}_{1}^{mkern1.5mu*})
    -dots-(f_{m}^{*} upsilon_{m}^{*})(vec{x}_{m}^{mkern1.5mu*}) 
  &&&text{if $vec{u}^{mkern1.5mu*} geq vec{0}$ and 
              $vec{x}_{0}^{mkern1.5mu*}+dots+vec{x}_{m}^{mkern1.5mu*}
                =vec{x}^{mkern1.5mu*}$}, [1ex]
&{-}infty 
  &&text{otherwise}.
end{alignedat}
right.  % end of first equation
(G^{*} bm{x}^{*})(bm{w}^{*})
&= left{
begin{alignedat}{2}
&{-}f_{0}^{*}(bm{x}_{0}^{*})
  &&-(f_{1}^{*} upsilon_{1}^{*})(bm{x}_{1}^{*})
    -dots-(f_{m}^{*} upsilon_{m}^{*})(bm{x}_{m}^{*}) 
  &&&text{if $bm{u}^{*} geq bm{0}$ and 
              $bm{x}_{0}^{*}+dots+bm{x}_{m}^{*}
                =bm{x}^{*}$}, [1ex]
&{-}infty 
  &&text{otherwise}.
end{alignedat}
right. % end of second equation
(G^{*} bm{x}^{*})(bm{w}^{*})
&= begin{cases}
begin{alignedat}{2}
&{-}f_{0}^{*}(bm{x}_{0}^{*})
  &&-(f_{1}^{*} upsilon_{1}^{*})(bm{x}_{1}^{*})
    -dots-(f_{m}^{*} upsilon_{m}^{*})(bm{x}_{m}^{*}) 
  &&&text{if $bm{u}^{*} geq bm{0}$ and 
              $bm{x}_{0}^{*}+dots+bm{x}_{m}^{*}
                =bm{x}^{*}$}, [1ex]
&{-}infty 
  &&text{otherwise}.
end{alignedat}
end{cases} 
end{align*}

end{document}

Answered by Mico on December 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