# Wrap equation to new line, in array environment

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

$$\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$$


I'd like it to look something like:

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


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.

\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}

• Use of \newcommand is very useful too. Is it easiest, in general, to use multiline when splitting large vectors or matrices? I was hoping there would be a way to wrap these without having to do it by hand.
– oLas
Jan 3, 2014 at 15:02
• @oLas - Notice that my answer pertains only to splitting a lengthy row vector; I didn's say anything about matrices... In my experience, it's usually best to select the line breaks using the eyeball method (aka the "Nike Strategy", viz., "Just Do It"). Choosing line breaks that are pleasing aesthetically as well as correct mathematically is both an art and a craft; fiddling with the settings of an algorithm that's supposed to select the line breaks tends to take up more time than is required for doing the job by hand.
– Mico
Jan 3, 2014 at 15:14
• @oLas - Thanks for he suggested edit. Do note that the name of the equation-related environment is multline, not multiline.
– Mico
Jan 8, 2014 at 3:20