3

I was trying to write an optimization problem in which "subject to" part is a vector statement. however it doesn't look good. enter image description here

     \[ \begin{array}{clcll}
     \textrm{min} & \|k_i\|^2 &\equiv &\textrm{min} & \|k_i\|^2\\
     \text{s.t. } & \begin{array}{c}
     k_i'w_1=0 \\
     \vdots\\
     k_i'w_i=1\\
     \vdots\\
     k_i'w_n=0
     \end{array}
     & &\text{s.t. } &\left[\begin{array}{c}\textendash w_1\textendash \\
     \vdots\\
     \textendash w_i\textendash \\
     \vdots\\
     \textendash w_n\textendash \end{array}\right]
     \left[\begin{array}{c}| \\
     k_i\\
     |\end{array}\right]=
     \left[\begin{array}{c} 0 \\
     \vdots\\
     1\\
     \vdots\\
     0 \end{array}\right]=e_i
     \end{array}\] 

Is there any way to force the vectors to be more compacted? (to occupy less space)

SMA.D
  • 219

3 Answers3

6

try this. i've suppressed some of the vertical space around the \vdots and used the matrix environments from amsmath to close those up a bit.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\xvdots}{\vphantom{{\sum^0}^0}\smash{\vdots}}

\begin{document}
\begin{alignat*}{2}
&\textrm{min} \quad \|k_i\|^2 &\ &\equiv \textrm{min} \quad \|k_i\|^2\\[2pt]
&\text{s.t.}\quad \ \,
 \begin{matrix}
   k_i'w_1=0 \\
   \xvdots\\
   k_i'w_i=1\\
   \xvdots\\
   k_i'w_n=0
 \end{matrix}
 &\ & \phantom{{}\equiv{}} \text{s.t.} \quad
  \begin{bmatrix}
   \text{--} w_1\text{--} \\
   \xvdots\\
   \text{--} w_i\text{--} \\
   \xvdots\\
   \text{--} w_n\text{--}
  \end{bmatrix}
  \begin{bmatrix}
   | \\
   k_i \\
   |
  \end{bmatrix}
  =
  \begin{bmatrix}
   0 \\
   \xvdots\\
   1 \\
   \xvdots\\
   0
  \end{bmatrix}
  = e_i
\end{alignat*}
\end{document}

output of example code

  • Thank you, that's pretty nice. Is it possible to reduce the horizontal space between two matrices that are being multiplied. i.e. \text{--} w_1\text{--} \\ \xvdots\\ \text{--} w_i\text{--} \\ \xvdots\\ \text{--} w_n\text{--} and | \\ k_i \\ |? – SMA.D Jan 08 '16 at 21:35
  • sure it's possible. there's a line between the first two bmatrix components. just remove that. (i'll edit in a modified version, with this change.) – barbara beeton Jan 08 '16 at 21:39
  • if they're still not close enough, inserting a small backspace -- \! -- between them should fix that. – barbara beeton Jan 08 '16 at 21:44
  • I looked below, but you were above, +1 anyway:-) – David Carlisle Jan 08 '16 at 21:51
1

Here is another option showing how you can manipulate the row spacing using portions of \normalbaselineskip:

enter image description here

\documentclass{article}
\usepackage{mathtools,array}
\begin{document}
\[
  \setlength{\arraycolsep}{0pt}
  \begin{array}[t]{l}
    \min \|k_i\|^2 \\[.5\normalbaselineskip]
    \text{s.t. }
    \begin{array}{r>{{}}l}
      k_i'w_1 &= 0 \\[-.4\normalbaselineskip]
      & \vdotswithin{=} \\[-.1\normalbaselineskip]
      k_i'w_i &= 1 \\[-.4\normalbaselineskip]
      & \vdotswithin{=} \\[-.1\normalbaselineskip]
      k_i'w_n &= 0
    \end{array}
  \end{array}
  \quad \equiv \quad
  \begin{array}[t]{l}
    \min \|k_i\|^2 \\[.5\normalbaselineskip]
    \text{s.t. }
    \left[\begin{array}{c}
      \text{-- } w_1 \text{ --} \\[-.4\normalbaselineskip]
      \vdots \\[-.1\normalbaselineskip]
      \text{-- } w_i \text{ --} \\[-.4\normalbaselineskip]
      \vdots \\[-.1\normalbaselineskip]
      \text{-- } w_n \text{ --}
    \end{array}\right]
    \left[\begin{array}{c}
      | \\ k_i \\ |
    \end{array}\right]
    =
    \left[\begin{array}{c}
      0 \\[-.4\normalbaselineskip]
      \vdots \\[-.1\normalbaselineskip]
      1 \\[-.4\normalbaselineskip]
      \vdots \\[-.1\normalbaselineskip]
      0
    \end{array}\right]
    = e_i
  \end{array}
\] 

\end{document}
Werner
  • 603,163
0

Not totally happy with it but you could start tinkering from here:

enter image description here

\documentclass{article}
\usepackage{mathtools}
\begin{document}
 \[   
\min
_{\mathrlap{\substack{ 
     \text{s.t.}\\
     k_i'w_1=0 \\
     \vdots\\
     k_i'w_i=1\\
     \vdots\\
     k_i'w_n=0}}}
  \|k_i\|^2
\quad\equiv\quad
\min 
_{\mkern-18mu\mathrlap{\substack{
     \text{s.t.}\\
   \left[\begin{smallmatrix}\text{--} w_1\text{--} \\
     \vdots\\
     \text{--} w_i\text{--} \\
     \vdots\\
     \text{--} w_n\text{--} \end{smallmatrix}\right]
     \left[\begin{smallmatrix}| \\
     k_i\\
     |\end{smallmatrix}\right]=
     \left[\begin{smallmatrix} 0 \\
     \vdots\\
     1\\
     \vdots\\
     0 \end{smallmatrix}\right]=e_i}}}
\|k_i\|^2
\] 

\end{document}
David Carlisle
  • 757,742