2

I was trying to do the following:

$$

\begin{cases}

a, & n=1\\

$\Phi^{-1}x(n-1)$, & x(n)=x(n-1)

$\Phi^{-1}\x(n-1)+c$, & x(n)=x(n-1)+1

\end{cases}

$$

But I keep getting errors. Is there an obvious syntax error that I'm not aware of?

ShreevatsaR
  • 45,428
  • 10
  • 117
  • 149
user33311
  • 181
  • 2
    Don't leave blank lines in displayed math; don't use $$...$$ in LaTeX documents. The following works: `\documentclass{article} \usepackage{amsmath}

    \begin{document}

    [ \begin{cases} a, &\qquad n=1.\Phi^{-1}x(n-1), &\qquad x(n)=x(n-1). \Phi^{-1}x(n-1)+c, &\qquad x(n)=x(n-1)+1. \end{cases} ]

    \end{document}`

    – Gonzalo Medina Jul 15 '13 at 00:10
  • Thank you. Is this a good rule of thumb in general? I happen to have a large portion of my document using $equations here$. I should really be using a 'begin equation' line instead shouldn't I? – user33311 Jul 15 '13 at 00:12
  • In line math is different. For in-line math you can continue using $...$. The recommendation I made is for displayed math. There are a couple of answers here addressing this; let me see if I can find them. – Gonzalo Medina Jul 15 '13 at 00:15
  • @Gonzalo's comment gets rid of the problem but he didn't state explicitly that cases has to be used within math mode, and therefore using $ within it will get an error unless it's explicitly within a \text{...} argument. (making the other points was definitely good advice though.) – barbara beeton Jul 15 '13 at 14:15
  • 1
    Welcome to TeX.SX! Please make your code compilable, starting with \documentclass{...} and ending with \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to help you. Help them help you: remove that one hurdle between you and a solution to your problem. – Martin Schröder Jul 15 '13 at 18:14

1 Answers1

1

When using the cases environment, you don't need to have inline math delimiters wrapped inside.

One can simply write,

\documentclass{article}
\usepackage{mathtools}
%-----The font code I use----------------
\usepackage[utf8]{inputenc}
\renewcommand{\rmdefault}{ppl}                 
\linespread{1.05}    
\usepackage[scaled]{helvet}
\usepackage{courier}                                                           
\usepackage{eulervm}   

\normalfont     
\usepackage[T1]{fontenc}                                                           
\usepackage{textcomp}
%------------------------------------
\begin{document}
\begin{displaymath}
    \begin{cases}
        a, & n=1\\
        \Phi^{-1}x(n-1), & x(n)=x(n-1)\\
        \Phi^{-1}x(n-1)+c, & x(n)=x(n-1)+1
    \end{cases}
\end{displaymath}
\end{document}

and if you would like to have the math inside the cases to be display style, you can change the environment to \begin{dcases}...\end{dcases}.

Also, you had \Phi^{-1}\x(n-1)+c which could be causing other errors unless you have defined \x somewhere.

Per Gonzalo Medina's comment, we need \usepackage{mathtools} to use the dcases environment and cases should be used in the displaymath environment or \[...\].

enter image description here

David Carlisle
  • 757,742
dustin
  • 18,617
  • 23
  • 99
  • 204
  • 1
    it's really quite subversive of you to use euler cursive for your math, but not show how you did it in your example code. if someone copies your code and runs it, s/he'll get the default computer modern, and be very confused, especially if s/he happens to be a newbie. – barbara beeton Aug 14 '13 at 20:14
  • @barbarabeeton don't you think subversive is a little over the top for not including font code? – dustin Aug 14 '13 at 20:18
  • possibly so. but how about "unkind"? (i meant "subversive" in the sense of dangling something attractive in front of a receptive observer, with the quite possible effect that the object will become desired. not the main dictionary definition, but "corrupting influence" is a derivable synonym,) – barbara beeton Aug 14 '13 at 20:54