# How can I split and align this series of equations?

I know this is an issue that comes up frequently, but I keep running into issues using all the suggested examples (breqn, amsmath; split, align, etc).

Here's what I have:

\documentclass[11pt]{article}
\usepackage[margin=1in,paperwidth=8.5in,paperheight=11in]{geometry}
\usepackage[shortlabels]{enumitem}
\usepackage{amsmath}
\usepackage{xfrac}
\usepackage{breqn}

\begin{document}

% << Other stuff that compiled fine. >>

\begin{enumerate}[(a)]

\item What is the global CPI for each implementation?

We can use this equation to find the overall CPI for each implementation:

\begin{equation}
\begin{align*}
CPI_{total} & = \frac{\sum (IIC) (CCI)}{IC} \\

CPI_{P1,total} &=
\frac{(1 \times 10^5~class~instructions \cdot 1~\sfrac{cycle}{instruction}) \\+
(2 \times 10^5~class~instructions \cdot 2~\sfrac{cycles}{instruction}) \\+
(5 \times 10^5~class~instructions \cdot 3~\sfrac{cycles}{instruction}) \\+
(2 \times 10^5~class~instructions \cdot 3~\sfrac{cycles}{instruction})}
{1 \times 10^6~instructions} \\

& = 2.6~\sfrac{average~cycles}{instruction} \\

CPI_{P2,total} & =
\frac{(1 \times 10^5~class~instructions \cdot 2~\sfrac{cycles}{instruction}) \\+
(2 \times 10^5~class~instructions \cdot 2~\sfrac{cycles}{instruction}) \\+
(5 \times 10^5~class~instructions \cdot 2~\sfrac{cycles}{instruction}) \\+
(2 \times 10^5~class~instructions \cdot 2~\sfrac{cycles}{instruction})}
{1 \times 10^6~instructions}

& = 2.0~\sfrac{average~cycles}{instruction} \\
\end{align*}
\end{equation}

% << More list items >>

\end{enumerate}
\end{document}


The code does fall within an enumerated list, but commenting out the list doesn't seem to affect it. The code also compiles OK when the attempts at splitting are removed and I just align them with eqnarray.

I'm getting a Paragraph ended before \align was complete error.

EDIT: question formatting.

EDIT2: Progress!

OK, so I figured out how to use splitfrac after some searching-- \frac{ \splitfrac{<numsplit1>}{<numsplit2>} } {<denom>} -- using the code here:

\begin{eqnarray*}
CPI_{total} &=& \frac{\sum (IIC) (CCI)}{IC} \\
&=& \frac{\splitfrac{(1 \times 10^5~instructions \cdot 1~\sfrac{cycle}{instruction})+(2 \times 10^5~instructions \cdot 2~\sfrac{cycles}{instruction})}{+(5 \times 10^5~instructions \cdot 3~\sfrac{cycles}{instruction})+(2 \times 10^5~instructions \cdot 3~\sfrac{cycles}{instruction})}}{1 \times 10^6~instructions} \\
\end{eqnarray*}


This compiles OK, but it gives me this extraneous and distracting 1 in the numerator, seen below: Any idea what's happening here?

• Welcome to the site. One source of error is the empty lines within align*, that is not allowed. Feb 17, 2014 at 1:45
• @Torbjørn T. Thank you. Now I'm getting the following: ! Package amsmath Error: Erroneous nesting of equation structures; Feb 17, 2014 at 1:46
• There are some mistakes: you cannot nest align inside equation; you cannot leave blank lines inside a displayed math environment such as align; you cannot use line change commands (\\ ) inside the arguments of \frac. Feb 17, 2014 at 1:53
• Never mind. Can't delete, only edit. Feb 17, 2014 at 1:54
• OK, so I got rid of equation and eliminated the extra line breaks. Without breaking the equation in any way, it goes right off the page shortly after the first addend in the frac. How can one split a numerator to fit on one page? Feb 17, 2014 at 2:00

You can use an array to stack content in a large numerator: \documentclass[11pt]{article}

\usepackage[margin=1in,paperwidth=8.5in,paperheight=11in]{geometry}
\usepackage[shortlabels]{enumitem}
\usepackage{amsmath,xfrac,breqn}

\newcommand{\CI}{\text{class instructions}}
\newcommand{\CS}{\sfrac{\text{cycle}}{\text{instruction}}}
\newcommand{\CPI}{\text{CPI}}

\begin{document}

% << Other stuff that compiled fine. >>

\begin{enumerate}[(a)]

\item What is the global CPI for each implementation?

We can use this equation to find the overall CPI for each implementation:

\begin{align*}
\CPI_{\text{total}} & = \frac{\sum (IIC) (CCI)}{IC} \\
\CPI_{P1,\text{total}} &=
\frac{\begin{array}{@{}r@{}}
(1 \times 10^5\ \CI \cdot 1\ \CS) \\ {}+
(2 \times 10^5\ \CI \cdot 2\ \CS) \\ {}+
(5 \times 10^5\ \CI \cdot 3\ \CS) \\ {}+
(2 \times 10^5\ \CI \cdot 3\ \CS)
\end{array}}
{1 \times 10^6\ \text{instructions}} \\
& = 2.6\ \sfrac{\text{average cycles}}{\text{instruction}} \\
\CPI_{P2,\text{total}} & =
\frac{\begin{array}{@{}r@{}}
(1 \times 10^5\ \CI \cdot 2\ \CS) \\ {}+
(2 \times 10^5\ \CI \cdot 2\ \CS) \\ {}+
(5 \times 10^5\ \CI \cdot 2\ \CS) \\ {}+
(2 \times 10^5\ \CI \cdot 2\ \CS)
\end{array}}
{1 \times 10^6\ \text{instructions}} \\
& = 2.0\ \sfrac{\text{average cycles}}{\text{instruction}} \\
\end{align*}

% << More list items >>

\end{enumerate}
\end{document}


Some guidelines:

• Use \text{<stuff>} to set <stuff> as text;
• Define macros for stuff that you use frequently/often - it promotes consistency;
• Consider using an abbreviated "unit" for "class instructions" (perhaps \text{ci}) and "cycle/instruction" (perhaps \text{cpi}) to avoid the visible duplicate (and clutter) of the information.
• i think i'd add just a bit of space between the separate equations; as it stands, the top line of the fractions tends to "attach itself" to the previous line. Feb 17, 2014 at 14:32