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

  • 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 8: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 8:49
  • Please show the log file of that really small example. – Johannes_B Aug 14 '16 at 8:50
  • I hope that helps textuploader.com/58lna Thank you – Naro Aug 14 '16 at 8:59
  • I've added my header. Sorry if it takes a bit long I'm new to this – Naro Aug 14 '16 at 9:04
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

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}
  • 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 9: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 9: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 9: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 9: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 9:30
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

  • 1
    The OP has already supplied a log showing that the error is produced, so this doesn't really answer the question. – David Carlisle Aug 14 '16 at 9:11
  • I must have written this at the same time that he edited. The other answers are more to the point. – Viktor Qvarfordt Aug 14 '16 at 9:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.