# Large multiline equation alignment

I have the following latex code:

\begin{equation*}
\begin{split}
Vect =& (\frac{1}{55},0,\frac{2}{113},-\frac{3}{46}-\frac{5i}{67},-\frac{1}{50},0,0,\frac{3}{107},-\frac{7}{41},\frac{1}{113}-\frac{4 i}{63}, \\
& -\frac{3}{89},-\frac{3}{289},-\frac{12}{275}+\frac{i}{7},-\frac{18}{137}-\frac{8 i}{143},-\frac{16}{108},\frac{1}{76}-\frac{i}{24},\\
&-\frac{3}{89},\frac{10}{101},\frac{3}{40},-\frac{16}{47},\frac{8}{91}+\frac{25i}{111},\frac{3}{40},\frac{15}{128},\frac{11}{131},\frac{16}{43},0,\\
&\frac{1}{51}-\frac{18i}{137},\frac{7}{20},0,\frac{7}{125},\frac{16}{43},\frac{10}{201},0,0,-\frac{1}{104},-\frac{7}{146}+\frac{7i}{187},\\
&-\frac{1}{81}+\frac{3 i}{62},0,0,-\frac{4}{105}+\frac{4i}{105},\frac{1}{32}+\frac{3 i}{34},0,0,\frac{1}{7},\frac{2}{7}+\frac{4 i}{35},\\
&0,\frac{5}{151}+\frac{6 i}{89},-\frac{1}{44},-\frac{3}{107},-\frac{2}{57}+\frac{10i}{151},-\frac{4}{87}+\frac{5 i}{108},\\
&\frac{21}{118}+\frac{16 i}{123},-\frac{1}{44},-\frac{3}{107},-\frac{3}{107},-\frac{7}{86}+\frac{17i}{145},\frac{1}{44},0,\frac{1}{44},\\
&-\frac{3}{107},-\frac{3}{62}-\frac{15 i}{187},\frac{1}{114},\frac{1}{8826},-\frac{1}{24}+\frac{3 i}{59})
\end{split}
\end{equation*}


If you compile it like that it looks like a mess. Is there any way to write this nicely, say 6-7 elements of the vector on one line, but that the entire vector is perfectly aligned on both sides (like text alignment in Word) ?

A bit tricky, but resorting to inline math seems worth the pain.

\documentclass{article}
\usepackage{amsmath}
\usepackage{lipsum} % just for the example

\begin{document}

\lipsum*[2]
\begin{equation*}
\mathrm{Vect} = \biggl(
\begin{minipage}[t]{.85\displaywidth}
% make locally the comma to allow line breaks
\mathchardef\comma=\mathcode,
\begingroup\lccode~=,\lowercase{\endgroup\def~}{\comma\penalty 0 }
\mathcode,=\string"8000
% change the automatic spacing parameters, don't allow breaks at + and -
\thinmuskip=12mu plus 6mu minus 3mu \medmuskip=4mu \binoppenalty=10000
% give more room to lines
$\displaystyle \frac{1}{55}, 0, \frac{2}{113}, -\frac{3}{46}-\frac{5i}{67}, -\frac{1}{50}, 0, 0, \frac{3}{107}, -\frac{7}{41}, \frac{1}{113}-\frac{4i}{63}, -\frac{3}{89}, -\frac{3}{289}, -\frac{12}{275}+\frac{i}{7}, -\frac{18}{137}-\frac{8i}{143}, -\frac{16}{108}, \frac{1}{76}-\frac{i}{24}, -\frac{3}{89}, \frac{10}{101}, \frac{3}{40}, -\frac{16}{47}, \frac{8}{91}+\frac{25i}{111}, \frac{3}{40}, \frac{15}{128}, \frac{11}{131}, \frac{16}{43}, 0, \frac{1}{51}-\frac{18i}{137}, \frac{7}{20}, 0, \frac{7}{125}, \frac{16}{43}, \frac{10}{201}, 0, 0, -\frac{1}{104}, -\frac{7}{146}+\frac{7i}{187}, -\frac{1}{81}+\frac{3 i}{62}, 0, 0, -\frac{4}{105}+\frac{4i}{105}, \frac{1}{32}+\frac{3 i}{34}, 0, 0, \frac{1}{7}, \frac{2}{7}+\frac{4 i}{35}, 0, \frac{5}{151}+\frac{6 i}{89}, -\frac{1}{44}, -\frac{3}{107}, -\frac{2}{57}+\frac{10i}{151}, -\frac{4}{87}+\frac{5 i}{108}, \frac{21}{118}+\frac{16 i}{123}, -\frac{1}{44}, -\frac{3}{107}, -\frac{3}{107}, -\frac{7}{86}+\frac{17i}{145}, \frac{1}{44}, 0, \frac{1}{44}, -\frac{3}{107}, -\frac{3}{62}-\frac{15 i}{187}, \frac{1}{114}, \frac{1}{8826}, -\frac{1}{24}+\frac{3 i}{59}\biggr)$
\end{minipage}
\end{equation*}
\lipsum[3]

\end{document}


In some cases this can't work, because some package might already have redefined the comma. You can do a branching to check this. For instance, with your preamble you can do like this (and it will work independently of having loaded breqn or not).

\documentclass[%
reprint,
%frontmatterverbose,
%preprint,
%showpacs,preprintnumbers,
%nofootinbib,
%nobibnotes,
%bibnotes,
amsmath,amssymb,
aps,
%pra,
%prb,
%rmp,
%prstab,
%prstper,
%floatfix,
]{revtex4-1}

\usepackage{graphicx}% Include figure files
\usepackage{dcolumn}% Align table columns on decimal point
\usepackage{bm}% bold math
\usepackage[utf8]{inputenc}
\usepackage{default}
\usepackage{siunitx}
\usepackage{braket}
\usepackage{breqn}
\usepackage{amsmath}
\usepackage{caption}
\usepackage{wrapfig}
\usepackage{subcaption}
\usepackage{xcolor}
%\usepackage{mhchem}
\usepackage{bbold}
\usepackage{mathtools}
\usepackage{tikz}
\usepackage{float}
\usetikzlibrary{arrows}

\usepackage{lipsum} % just for the example

\begin{document}

\lipsum*[2]
\begin{equation*}
\mathrm{Vect} = \biggl(
\begin{minipage}[t]{.8\displaywidth}
% make locally the comma to allow line breaks
\ifnum\mathcode,=\string"8000
\begingroup\lccode~=,
\lowercase{\endgroup\expandafter\def\expandafter~\expandafter{~\penalty 0 }}%
\else
\mathchardef\comma=\mathcode,
\begingroup\lccode~=,\lowercase{\endgroup\def~}{\comma\penalty 0 }
\mathcode,=\string"8000
\fi
% change the automatic spacing parameters, don't allow breaks at + and -
\thinmuskip=12mu plus 6mu minus 3mu \medmuskip=4mu \binoppenalty=10000
% give more room to lines
$\displaystyle \frac{1}{55}, 0, \frac{2}{113}, -\frac{3}{46}-\frac{5i}{67}, -\frac{1}{50}, 0, 0, \frac{3}{107}, -\frac{7}{41}, \frac{1}{113}-\frac{4i}{63}, -\frac{3}{89}, -\frac{3}{289}, -\frac{12}{275}+\frac{i}{7}, -\frac{18}{137}-\frac{8i}{143}, -\frac{16}{108}, \frac{1}{76}-\frac{i}{24}, -\frac{3}{89}, \frac{10}{101}, \frac{3}{40}, -\frac{16}{47}, \frac{8}{91}+\frac{25i}{111}, \frac{3}{40}, \frac{15}{128}, \frac{11}{131}, \frac{16}{43}, 0, \frac{1}{51}-\frac{18i}{137}, \frac{7}{20}, 0, \frac{7}{125}, \frac{16}{43}, \frac{10}{201}, 0, 0, -\frac{1}{104}, -\frac{7}{146}+\frac{7i}{187}, -\frac{1}{81}+\frac{3 i}{62}, 0, 0, -\frac{4}{105}+\frac{4i}{105}, \frac{1}{32}+\frac{3 i}{34}, 0, 0, \frac{1}{7}, \frac{2}{7}+\frac{4 i}{35}, 0, \frac{5}{151}+\frac{6 i}{89}, -\frac{1}{44}, -\frac{3}{107}, -\frac{2}{57}+\frac{10i}{151}, -\frac{4}{87}+\frac{5 i}{108}, \frac{21}{118}+\frac{16 i}{123}, -\frac{1}{44}, -\frac{3}{107}, -\frac{3}{107}, -\frac{7}{86}+\frac{17i}{145}, \frac{1}{44}, 0, \frac{1}{44}, -\frac{3}{107}, -\frac{3}{62}-\frac{15 i}{187}, \frac{1}{114}, \frac{1}{8826}, -\frac{1}{24}+\frac{3 i}{59}\biggr)$

• @Qubix Do you really need breqn? – egreg Apr 27 '16 at 14:15