Math & ScienceWriting a cased Equation

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
ostadomid
Posts: 2
Joined: Fri Nov 15, 2013 6:44 am

Writing a cased Equation

Post by ostadomid »

Hi,

I am writing a paper and have been stuck on a certain cased equation within it for a few hours. Here's what I'm trying to write.
hue-calc.gif
hue-calc.gif (3.9 KiB) Viewed 4884 times
Disregard that "mod6" and all the "primes" and stuff. Here's what I've written.

Code: Select all

\begin{equation}
  H=
  \begin{cases}
    60^\circ\times\frac{G-B}{\Delta} & \quad \text{if $Max(R,G,B)=R$} \\
    60^\circ\times\frac{B-R}{\Delta}+ 2 & \quad \text{if $Max(R,G,B)=G$} \\
    60^\circ\times\frac{R-G}{\Delta}+ 4 & \quad \text{if $Max(R,G,B)=B$}
  \end{cases}
\end{equation}
I'm getting the error where the \quad and \text enters. When I remove all the cases and just write the equations alone, they work fine. Can someone please help me fix this. Thanks in advance.
Last edited by localghost on Fri Nov 15, 2013 10:04 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Writing a cased Equation

Post by Johannes_B »

Did you load amsmath?

Code: Select all

\documentclass[12pt]{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
  H=
  \begin{cases}
    60^\circ\times\frac{G-B}{\Delta} & \quad \text{if}   \quad \text{Max}(R,G,B)=R \\
    60^\circ\times\frac{B-R}{\Delta}+ 2 & \quad \text{if}\quad Max(R,G,B)=G \\
    60^\circ\times\frac{R-G}{\Delta}+ 4 & \quad \text{if}\quad Max(R,G,B)=B
  \end{cases}
\end{equation}
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
ostadomid
Posts: 2
Joined: Fri Nov 15, 2013 6:44 am

Re: Writing a cased Equation

Post by ostadomid »

Thanks alot Johannes. A total lifesaver. This was my first real LaTeX project and although I read alot about this I couldnt fix it myself. Thats why I asked for help here. In any case thanks for your help
Post Reply