I only installed LaTeX just over 3 weeks ago and I've written about 20 pages of Maths coursework. I have a bit of an issue with arrays – I am trying to use something like dcases
to show a piecewise function. My function involves fractions and they come out too small but I can't seem to follow other people's answers to this problem because I am not familiar with the packages etc. Please could you look at my document set-up, as below, and suggest what I'm doing wrong? When I use the amsmath
package, things disappear off the ends of pages and everything moves!
\documentclass[11pt]{article} % use "amsart" instead of "article" for AMSLaTeX format
%\usepackage{geometry} % See geometry.pdf to learn the layout options. There are lots.
%\geometry{a4paper} % ... or a4paper or a5paper or ...
%\geometry{landscape} % Activate for for rotated page geometry
%\usepackage[parfill]{parskip} % Activate to begin paragraphs with an empty line rather than an indent
%\usepackage{graphicx} % Use pdf, png, jpg, or eps with pdflatex; use eps in DVI mode
% TeX will automatically convert eps --> pdf in pdflatex
%\usepackage{mathtools}
\usepackage{amssymb}
%\usepackage[hmargin=2.5cm,vmargin=3cm,bindingoffset=3cm]{geometry}
\usepackage[margin=0.8in,include foot]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{Chloe Jones A2460906}
\chead{TMA MST326 03}
\rhead{\thepage}
\lfoot{}
\cfoot{}
\rfoot{}
\title{TMA MST326 03}
%\author{Chloe Jones A2460906}
%\date{March 2015} % Activate to display a given date or no date
\begin{document}
%\maketitle
H= \begin{array}{lr}
\\
0 & : \textrm{n even,}\ \ n\neq2\\
\\
\frac{5\pi + 2n\pi + 5\pi - 2n\pi }{ \pi ^2 \left({4 - n^2 }\right)} & : \textrm{n odd}
\end{array}
\right.
Best Answer
The
cases
environment, provided by theamsmath
package, is ready-made for your math expression. Note that thecases
environment renders each line in text-style math mode (aka inline math mode). If you don't need to conserve space, consider using adcases
environment instead: It displays the fractional term in display-style math mode and also increases the space between rows.Either way, the entire expression, starting with
H=
, has to be in math mode. This can be achieved by placing it in a\[ ... \]
group.Addendum -- As @daleif has observed in a comment, the
dcases*
environment may also be of interest. It differs from thedcases
environment in that the material after the&
character is automatically placed in text mode, obviating the need for the\text{...}
wrappers. Using adcases*
environment, one could write the solution as follows: