[Tex/LaTex] Wrap equation to new line, in array environment

arraysequationswrap

Is it possible to wrap an equation to a new line (such as in How to wrap a long equation in latex but within an array environment? I have a column vector of regressors that I want to show over two rows. My code without wrapping looks like this

\begin{equation}
  \label{eq:designmat}
  X_i=\left[\begin{array}{ccccccccc}1&\textrm{CitySize}_i&
      \textrm{NoMotorways}_i&\textrm{ElevatedMotorways}_i&
      \textrm{SpeedLimit}_i&\textrm{Policing}_i&\textrm{TrafficLights}_i&
      \textrm{TransitLanesTrue}_i&\textrm{Aggression}_i\end{array}\right]^T
\end{equation}

I'd like it to look something like:

X = [var1 var2 var3 var4
        ... var5 var6 var7 var8]^T

Best Answer

You could use the multline environment of the amsmath package. The example below uses a simple interword space to separate the variables; depending on your needs and preferences you may want to increase the separation a bit.

enter image description here

\documentclass{article}
\usepackage{amsmath} % Required for multline environment
\newcommand\V[1]{\textup{#1}} % Variable names in upright roman
\begin{document}
\begin{multline}
  \label{eq:designmat}
X_i=\bigl[\,1\  
  \V{CitySize}_i \ 
  \V{NoMotorways}_i \ 
  \V{ElevatedMotorways}_i \ 
  \V{SpeedLimit}_i \\
  \V{Policing}_i \ 
  \V{TrafficLights}_i \  
  \V{TransitLanesTrue}_i \  
  \V{Aggression}_i \,
\bigr]^T
\end{multline}

\hrule  % just to show width of text block
\end{document}
Related Question