4

Hey there I have a problem with the cases enviroment inside an equation i'm getting the error missing $ inserted but i don't know why. I already searched and found that there are now blank lines inside a equation allowed but i'm not sure where they should be in my case. Here is my code.

\documentclass[11pt,a4paper,oneside]{amsbook}
%Sprache
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
%Zeichensatz
\usepackage[utf8]{inputenc}
%PDF Integrierung
\usepackage{pdflscape}
\usepackage{rotating}
\usepackage{pdfpages}
\renewcommand{\familydefault}{\sfdefault}
%Formatierung
\usepackage[left=2.5cm,right=2.5cm,top=2cm,bottom=2cm]{geometry}
\usepackage[onehalfspacing]{setspace}
%Schriftart
\usepackage{helvet}
%Mathepackages
\usepackage{amsfonts,amstext,amsmath,amssymb,mathrsfs}
%Algorithmen
\usepackage{algorithm,algorithmic,program}
%diverses
\usepackage{enumerate}
%Theoreme und Gleichungen
\numberwithin{equation}{section}
\newtheorem{prop}{Satz}
\newtheorem{lemma}{Lemma}
\floatname{algorithm}{Algorithmus}
%Titelseite festlegen
\author{name\\
}
\title{Bachelorarbeit}
%Beginn der Seminarbeit
\begin{document}
\newtheorem{lemma}{Lemma}
\begin{lemma}
Die Supremumsnorm den k-ten Potenz von M ist gegeben durch
\begin{equation*}
\|M^k\| = \begin{cases}
\binom{N-1}{k} &  | \beta | = 1,\\
\frac{1}{(k-1)!} \frac{d^{k-1}}{dz^{k-1}} \frac{z^{N-1}-1}{z-1} z =|\beta| & 7 | \beta | \neq 1
\end{cases}
\end{equation*}
\end{lemma}
\end{document}

I would be very glad if you could help me, i have another equation where it works just fine.
Naro

Naro
  • 71
  • Welcome, adding a document structure around your code snippet (\documentclass etc.) i don't see any problem. It works just fine. – Johannes_B Aug 14 '16 at 08:38
  • Thats really strange if i do that i get the same error. I'm using TexMaker if thats any help – Naro Aug 14 '16 at 08:49
  • Please show the log file of that really small example. – Johannes_B Aug 14 '16 at 08:50
  • I hope that helps http://textuploader.com/58lna Thank you – Naro Aug 14 '16 at 08:59
  • I've added my header. Sorry if it takes a bit long I'm new to this – Naro Aug 14 '16 at 09:04
  • There is some problem with the pipes | (see a bunch of answers below...) – Matsmath Aug 14 '16 at 09:19
  • you say in your question "there are now blank lines ..."; i read this as "no blank lines", but it is possible that there are blank lines that aren't shown in the example. that would certainly result in the error you see. if you do really have any blank lines within the scope of math, remove them. – barbara beeton Aug 14 '16 at 14:01

3 Answers3

5

The program package defines | as an active character for its usage in the program environment and this causes the problem you have. However, the package provides an adjustment in case you want to use | in math mode.

\documentclass[11pt,a4paper,oneside]{amsbook}

\usepackage{program}

\normalbaroutside % <----- ADDED

\begin{document}

\begin{equation*}
\|M^k\| = \begin{cases}
\binom{N-1}{k} &  | \beta | = 1,\\
\frac{1}{(k-1)!} \frac{d^{k-1}}{dz^{k-1}} \frac{z^{N-1}-1}{z-1} z =|\beta| & | \beta | \neq 1
\end{cases}
\end{equation*}

\end{document}

However, it would be much better with

\lVert M^k\rVert

and

\lvert\beta\rvert

avoiding the unadorned | that is overloaded.


A good alternative to using \lVert\rVert and \lvert\rvert is with mathtools that also provides a dcases environment. Here's an example with both input and output. Note that in your text you don't have k and M in math mode, which is wrong.

\documentclass[11pt,a4paper,oneside]{amsbook}
\usepackage{mathtools}
\usepackage{program}

\normalbaroutside % it should be standard

\DeclarePairedDelimiter{\norm}{\lVert}{\rVert}
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}

\begin{document}

Die Supremumsnorm den $k$-ten Potenz von $M$ ist gegeben durch
\begin{equation*}
\norm{M^k} = \begin{dcases}
\binom{N-1}{k} &  \abs{\beta} = 1,\\
\frac{1}{(k-1)!} \frac{d^{k-1}}{dz^{k-1}} \frac{z^{N-1}-1}{z-1} z =\abs{\beta} &
   \abs{\beta} \neq 1
\end{dcases}
\end{equation*}

\end{document}

enter image description here

egreg
  • 1,121,712
3

Package program is destroying your parade. | isn't so good to use anyway, substitute it with proper macros from package physics (alternativesavailable).

naroCases

\documentclass{amsbook}
\usepackage{program}
\usepackage{physics}
\begin{document}
\newtheorem{lemma}{Lemma}
\begin{lemma}
    Die Supremumsnorm den k-ten Potenz von M ist gegeben durch
    \begin{equation*}
        \norm{M^k} = \begin{cases}
            \binom{N-1}{k} &  \abs{\beta} = 1,\\
            \frac{1}{(k-1)!} \frac{d^{k-1}}{dz^{k-1}} \frac{z^{N-1}-1}{z-1} z =\abs{\beta} & 7 \abs{\beta} \neq 1
        \end{cases}
    \end{equation*}
\end{lemma}
\end{document}
Johannes_B
  • 24,235
  • 10
  • 93
  • 248
  • Alright thank you! That helps i'm using program for some pseudocode so i will look for an alternative. If I remove it, it works i will see if i can find another package for my pseudo code. – Naro Aug 14 '16 at 09:15
  • @Naro The code works fine with pacage program. Test it. But you have to look for an alternative for producing absolutes and norms. Thankfully, package physics gives you handy commands. And the result is scalable. Compare the norm M^k in my anser with the screenshot of the other. – Johannes_B Aug 14 '16 at 09:17
  • Well, program and physics are aimed to very different targets. I'd not recommend physics, though, for a math document. – egreg Aug 14 '16 at 09:26
  • @egreg physics is the one i like most. skmath provides similar macros if i recall correctly. Edit: Checked, exactly the same macro names for this case. – Johannes_B Aug 14 '16 at 09:27
  • @Johannes_B I find physics trying to do too much; and skmath is not as bad as commath, but… – egreg Aug 14 '16 at 09:30
  • @egreg I guess we agree with the fact, that lvert and friends are better than using a pipe symbol. Both mentioned packages use that internally. :-) – Johannes_B Aug 14 '16 at 09:31
  • Thank you for your help ! Now everything works just fine. – Naro Aug 14 '16 at 09:34
0

It compiles to

enter image description here

when wrapped as follows:

\documentclass{article}

\usepackage{amsmath}
\usepackage{amsthm}

\begin{document}

\newtheorem{lemma}{Lemma}
\begin{lemma}
Die Supremumsnorm den k-ten Potenz von M ist gegeben durch
\begin{equation*}
\|M^k\| =
\begin{cases}
  \binom{N-1}{k} &  | \beta | = 1,\\
  \frac{1}{(k-1)!} \frac{d^{k-1}}{dz^{k-1}} \frac{z^{N-1}-1}{z-1} z =|\beta| & 7 | \beta | \neq 1
\end{cases}
\end{equation*}
\end{lemma}

\end{document}

To generate the image I used http://sciencesoft.at/latex/?lang=en