Math & ScienceSerious Multiline Equation Issues

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
Ehresmann
Posts: 3
Joined: Mon Oct 26, 2009 5:57 pm

Serious Multiline Equation Issues

Post by Ehresmann »

For some reason, I cannot get the /begin{cases} command to compile my sequence with cases correctly. I have looked on many different resources and have tried many different "minor tweakings", but my brace will not extend to both lines. It just remains center on the first line. Here is one of the things I have tried:

Code: Select all

$f_n(x) = \begin{cases} n & \mbox{ if } x \geq \\ 3n+1 & \mbox{ if } x<n \end{cases}$

Recommended reading 2024:

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

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

Stefan Kottwitz
Site Admin
Posts: 10344
Joined: Mon Mar 10, 2008 9:44 pm

Serious Multiline Equation Issues

Post by Stefan Kottwitz »

Hi Ehresmann,

welcome to the board!
You have to load the amsmath package:

Code: Select all

\usepackage{amsmath}
The standard LaTeX macro \cases has a different syntax.

Stefan
LaTeX.org admin
Ehresmann
Posts: 3
Joined: Mon Oct 26, 2009 5:57 pm

Re: Serious Multiline Equation Issues

Post by Ehresmann »

I have already loaded amsmath and amssymb in the document.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10344
Joined: Mon Mar 10, 2008 9:44 pm

Serious Multiline Equation Issues

Post by Stefan Kottwitz »

Just try this example:

Code: Select all

\documentclass[a4paper,10pt]{article}
\usepackage{amsmath}
\begin{document}
$f_n(x) = \begin{cases} n & \mbox{ if } x \geq \\ 3n+1 & \mbox{ if } x<n \end{cases}$
\end{document}
When I compile it the brace spans over two lines.

Stefan
LaTeX.org admin
Ehresmann
Posts: 3
Joined: Mon Oct 26, 2009 5:57 pm

Re: Serious Multiline Equation Issues

Post by Ehresmann »

The code from above works when I put it in its own separate document. In the document I am working on, it doesn't work. I did a little copying and pasting into a new doc, and now everything seems happy. So, moral of the story, it now works, but I have no idea why.

Thanks for the help!
User avatar
Stefan Kottwitz
Site Admin
Posts: 10344
Joined: Mon Mar 10, 2008 9:44 pm

Serious Multiline Equation Issues

Post by Stefan Kottwitz »

That's an example where just copying one line of code to the forum is simply not enough. The best way for getting help would be to create a minimal working example starting from the original code.

If you reduce a copy of your code to a minimal but complete example I'm sure we would find the cause of the problem. Perhaps keep it in mind if further problems would occur - nearly all problems can be solved if they could be tested & reproduced.

Stefan
LaTeX.org admin
Post Reply