Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This code is causing LaTeX to throw an error: Missing } inserted. It appears to be because I put a & inside a \frac command (on line 4). I feel as though it should be possible to accomplish my goal.

\begin{align*}
A & + B \\
\frac{A}{C} & + \frac{B}{C} \\
\frac{A & + B}{C}
\end{align*}

Has anyone been frustrated by this before? How did you get around it?

share|improve this question
2  
You can't put alignment points within the \frac. –  Peter Grill Jan 16 '12 at 19:22
1  
align work like an array environment. So the separation with & is used to separate cells. In this case it isn't possible to because the cell isn't a closed object. –  Marco Daniel Jan 16 '12 at 19:26
add comment

2 Answers

The & in the align environment are used to specify alignment points. These can not be within a \frac. So, depending on if you want to align on the right hand side of the expression, or on the + sign, you would use the code below to produce:

enter image description here enter image description here enter image description here

The second situation is a bit trickier. The way I solved it was to use \makebox to reserve a space equal to the largest text that goes in there and use the [c] option to center the text. However, if you want all three + to be aligned, then note that the spacing on either side of the = is not identical.

In this particular situation, you could choose to not align the + sign of the first expression, and then the spacing for all three = would be correct (as in the third image above). So it is a trade off between aligning the three +, or getting the correct spacing on either side of the equal.

\documentclass{article}
\usepackage{amsmath}
\usepackage{calc}

\begin{document}
If you want the right side aligned:
\begin{align*}
              A &+ B \\
    \frac{A}{C} &+ \frac{B}{C} \\
\frac{A + B}{C} &+
\end{align*}
%
\newcommand*{\LargeFrac}{\frac{A}{C} + \frac{B}{C}}%
\newcommand*{\Center}[1]{\makebox[\widthof{$\LargeFrac$}][c]{$\displaystyle #1$}}%
%
\noindent
If you want the plus sign aligned:
\begin{align*}
\Center{A + B} & = x\\
\Center{\frac{A}{C} + \frac{B}{C}} & = x \\
\Center{\frac{A + B}{C}} & = x 
\end{align*}
%
If you want correct spacing around the equal:
\begin{align*}
A + B & = x\\
\Center{\frac{A}{C} + \frac{B}{C}} & = x \\
\Center{\frac{A + B}{C}} & = x 
\end{align*}
\end{document}
share|improve this answer
add comment

Maybe you can use a derivation of `array:

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\begin{document}
\begin{align*}
\begin{array}{@{}r@{\mathrel{+}}l@{}}
              A & B \\
    \frac{A}{C} & \frac{B}{C} \\
          \scriptstyle A  & \scriptstyle B \\[-2.5pt]\cline{1-2}
             \multicolumn{2}{c}{\scriptstyle C}
\end{array}
\end{align*}
\end{document}

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.