Math & ScienceCases and Braces

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
ejohns85
Posts: 2
Joined: Sun Feb 10, 2013 4:17 am

Cases and Braces

Post by ejohns85 »

Hello,

I want to write an equation with two cases, to represent something like "x = 1 if y > 0, otherwise x = -1". I know that this can be done using the cases environment:

Code: Select all

\begin{cases}
1, & \text{if } y > 0 \\
0, & \text{otherwise}
\end{cases}
This works fine. However, what I actually want to do is say something like "x is approximately equal to 1 if y > 0, otherwise x = -1". So, instead of the single equals sign on the left of the brace, I would actually like two symbols on the right of the brace - the top one for "approximately equals", and the bottom one for "equals". I would then write the relevant text to the right of each symbols.

Effectively, this is the same as simply removing the original equals from the brace, and just writing in the "approximately equals" and "equals" symbols on the relevant lines. Does anybody know if this is possible?

Thanks!

Recommended reading 2024:

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

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Cases and Braces

Post by localghost »

I'm afraid I can't follow you. Any reasons against this?

Code: Select all

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{mathtools}

\begin{document}
  \begin{equation}
    x
    \begin{cases}
      \approx 1, & \text{if } y > 0 \\
      =0, & \text{otherwise}
    \end{cases}
  \end{equation}
\end{document}

Best regards and welcome to the board
Thorsten
ejohns85
Posts: 2
Joined: Sun Feb 10, 2013 4:17 am

Re: Cases and Braces

Post by ejohns85 »

Hi,

Yes, that is exactly what I was looking for actually - thanks! For some reason, I thought that the cases environment, by default, automatically puts an equals to the left of the brace. Obviously that is not the case though!

Thank you again,

Ed.
Post Reply