Math & Science ⇒ Brackets for equality
Brackets for equality
I haven't found any documentation on brackets with equality.
I'm attempting to define a function (the Collatz conjecture - see http://en.wikipedia.org/wiki/Collatz_conjecture)
I set up the equality
f(n) = {n/2 if n is even
{3n+1 if n is odd
I'd like to combine the brackets, just like in the link above. Is this possible?
I'm attempting to define a function (the Collatz conjecture - see http://en.wikipedia.org/wiki/Collatz_conjecture)
I set up the equality
f(n) = {n/2 if n is even
{3n+1 if n is odd
I'd like to combine the brackets, just like in the link above. Is this possible?
NEW: TikZ book now 40% off at Amazon.com for a short time.

Brackets for equality
You could use the cases environment of amsmath:
Code: Select all
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
f(n) =
\begin{cases}
n/2 &\text{if $n$ is even} \\
3n+1 &\text{if $n$ is odd}
\end{cases}
\]
\end{document}
Re: Brackets for equality
Thanks for your help. That's exactly what I wanted. However, I'd also like to put this into an equation, numbered for clarity. How would I do this?
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Brackets for equality
What about using the equation environment? Perhaps some basic reading would be good for you.generator wrote:[…] However, I'd also like to put this into an equation, numbered for clarity. How would I do this?
Best regards and welcome to the board
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Brackets for equality
I've been trying to read up on this. However, I don't know how to use the equation environment in conjunction with another begin/end clause. My TeX editor keeps telling me there are like 8-10 errors when I try this. How would I get around this?
Brackets for equality
Code: Select all
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
f(n) =
\begin{cases}
n/2 &\text{if $n$ is even} \\
3n+1 &\text{if $n$ is odd}
\end{cases}
\label{collatzfunction}
\end{equation}
As you can see in (\ref{collatzfunction}), blah blah blah.
\end{document}
Last edited by frabjous on Sat Apr 03, 2010 3:59 pm, edited 1 time in total.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Brackets for equality
I strongly recommend to do some basic reading [1]. If you are already struggling with these basic things, you will never put your work to paper.
[1] View topic: LaTeX Resources for Beginners
[1] View topic: LaTeX Resources for Beginners
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10