# What's wrong with my file? Equations aligning right, symbols not showing half way through

OK, this is my first attempt at writing my homework in LaTex, and it's frustrating as hell.

First, I defined unit vectors "uv" and bold vectors "bv" like so:

\newcommand{\bv}{\mathbf}
\newcommand{\uv}[1]{\mathbf{\hat{#1}}}


That seemed to work just fine when I tested it out. In fact, for the first part of my file (everything before the bold "answer"), the unit vectors show up fine.

Problems:

• The first equation block is aligned to the right.

• In the "Answer" section, unit vectors stop showing, and I just get a blank space instead.

• The alignment of the second equation box is also messed up. One part is all the way to the left, and the \bv{v} = 3 ( 3\uv{i} - \uv{j} + 2\uv{k} ) - 2 ( 2\uv{i} + \uv{j} - \uv{k} ) - 4 ( 3\uv{i} - \uv{j} + 2\uv{k} ) \\ part is missing altogether!

Here is the code:

\documentclass[letterpaper, 12pt, titlepage]{article}
\pagestyle{myheadings} \markright{Noam Gagliardi \hfill MATH2P03}
\usepackage{amsmath}

\newcommand{\bold}{\textbf}
\newcommand{\bv}{\mathbf}
\newcommand{\uv}[1]{\mathbf{\hat{#1}}}

\begin{document}

\title{MATH 2P03 \\ Homework #1}
\date{\today}
\author{Me \\ \texttt{student number}}
\maketitle

\bold{1.} Given
$\begin{split} & \bv{a} = 3\uv{i} - \uv{j} + 2\uv{k} \\ & \bv{b} = 2\uv{i} + \uv{j} - \uv{k} \\ \end{split}$

find $3\bv{a} - 2\bv{b} + 4\bv{a}$ in terms of $\bv{i}, \bv{j},$ and $\bv{k}$

\bold{Answer:} Let $\bv{v} = 3\bv{a} - 2\bv{b} + 4\bv{a}$. Then:

$\begin{split} & \bv{v} = 3 ( 3\uv{i} - \uv{j} + 2\uv{k} ) - 2 ( 2\uv{i} + \uv{j} - \uv{k} ) - 4 ( 3\uv{i} - \uv{j} + 2\uv{k} ) \\ & \quad = 9\uv{i} - 4\uv{i} - 12\uv{i} - 3\uv{j} - 2\uv{j} + 4\uv{j} + 6\uv{k} + 2\uv{k} - 8\uv{k} \\ & \quad = \uv{i} - \uv{j} + 16\uv{k} \\ \end{split}$

Therefore $\bv{v} = \langle 1, -1, 16 \rangle$

\end{document}

-

## 3 Answers

Not bad at all for a first effort at creating this type of LaTeX document! I think the main problem you were encountering was caused by the fact that you have blank lines in the split environment, which is not allowed in the amsmath package. Another issue is that the second line of the title should say Homework \# 1 instead of Homework #1 (the unescaped # character has a special function). Separately, I think you also meant for the \bv macro to accept an argument.

The code below fixes up a few more slight issues, including (i) adding a second \hfil command in the \markright command so that you get some separation between MATH 2P03 and the pagenumber and (ii) moving the position of the alignment character (&) in the split environments to get a more natural alignment of the equation parts. Happy TeXing!

\documentclass[letterpaper, 12pt, titlepage]{article}
\pagestyle{myheadings}
\markright{Noam Gagliardi \hfil MATH 2P03\hfil}
\usepackage{amsmath}

\newcommand{\bold}{\textbf}
\newcommand{\bv}[1]{\mathbf{#1}}
\newcommand{\uv}[1]{\mathbf{\hat{#1}}}

\begin{document}

\title{MATH 2P03 \\ Homework \#1}
\date{\today}
\author{Me \\ \texttt{student number}}
\maketitle

\begin{enumerate}
\item Given
$\begin{split} \bv{a} &= 3\uv{i} - \uv{j} + 2\uv{k} \quad\text{and}\\ \bv{b} &= 2\uv{i} + \uv{j} - \uv{k}\,, \\ \end{split}$
find $3\bv{a} - 2\bv{b} + 4\bv{a}$ in terms of
$\uv{i}$, $\uv{j}$, and $\uv{k}$.

\bold{Answer:}
Let $\bv{v} = 3\bv{a} - 2\bv{b} + 4\bv{a}$.
Then:
$\begin{split} \bv{v} &= 3 ( 3\uv{i} - \uv{j} + 2\uv{k} ) - 2 ( 2\uv{i} + \uv{j} - \uv{k} ) - 4 ( 3\uv{i} - \uv{j} + 2\uv{k} ) \\ &= 9\uv{i} - 4\uv{i} - 12\uv{i} - 3\uv{j} - 2\uv{j} + 4\uv{j} + 6\uv{k} + 2\uv{k} - 8\uv{k} \\ &= \uv{i} - \uv{j} + 16\uv{k} \\ \end{split}$
Therefore, $\bv{v} = \langle 1, -1, 16 \rangle$.
\end{enumerate}
\end{document}

-
OK, you've cleared some things up. And I wasn't aware of the "enumerate" thingy. Thanks. – iDontKnowBetter Sep 12 '11 at 22:32
You're welcome! :-) – Mico Sep 12 '11 at 22:46

You're doing some mistakes.

1. # is a special character; to get # in print, input it as \#
2. Never leave a blank line in a math environment.

Bad style: split is not the appropriate environment, it's better to use align*; never leave a blank line before or after a math environment, unless it's really at the start (not very common) or at the end (more common) of a (logical) paragraph. Never end a math environment with \\, which produces an empty line.

\documentclass[letterpaper, 12pt, titlepage]{article}
\pagestyle{myheadings} \markright{Noam Gagliardi \hfill MATH2P03}
\usepackage{amsmath}

\newcommand{\bold}{\textbf}
\newcommand{\bv}{\mathbf}
\newcommand{\uv}[1]{\mathbf{\hat{#1}}}

\begin{document}

\title{MATH 2P03 \\ Homework \#1}
\date{\today}
\author{Me \\ \texttt{student number}}
\maketitle

\bold{1.} Given
\begin{align*}
\bv{a} &= 3\uv{i} - \uv{j} + 2\uv{k} \\
\bv{b} &= 2\uv{i} + \uv{j} - \uv{k}
\end{align*}
find $3\bv{a} - 2\bv{b} + 4\bv{a}$ in terms of $\bv{i}$, $\bv{j}$, and $\bv{k}$.

\bold{Answer:} Let $\bv{v} = 3\bv{a} - 2\bv{b} + 4\bv{a}$. Then:
\begin{align*}
\bv{v} &= 3 ( 3\uv{i} - \uv{j} + 2\uv{k} ) - 2 ( 2\uv{i} + \uv{j} - \uv{k} )
- 4 ( 3\uv{i} - \uv{j} + 2\uv{k} ) \\
&= 9\uv{i} - 4\uv{i} - 12\uv{i} - 3\uv{j} - 2\uv{j} + 4\uv{j} + 6\uv{k} +
2\uv{k} - 8\uv{k} \\
&= \uv{i} - \uv{j} + 16\uv{k}
\end{align*}
Therefore $\bv{v} = \langle 1, -1, 16 \rangle$

\end{document}

-
OK, thanks. May I ask why the first & comes before the =3 and not before the \bv{v} which is at the beginning of the line? – iDontKnowBetter Sep 12 '11 at 22:18
In this way the = signs are aligned. The & marks the point of alignment which, quite often, is a relation symbol such as = or \le. – egreg Sep 12 '11 at 22:25
• Write # as \#, since # has a meaning in LaTeX
• Don't use empty lines in math environments, as they mean paragraph breaks
• Define your commands, which require arguments, with arguments, such as

\newcommand{\bold}[1]{\textbf{#1}}


or use \let for renaming such as

\let\bold\textbf

-