方程式 > 案例环境中缺少 $ 错误

方程式 > 案例环境中缺少 $ 错误

我在环境中丢失了 $ equation,但仅在环境中时才出现这种情况cases。在下面的两个示例中,只有实现环境的方程式cases给我带来了麻烦:

\documentclass[11pt,fleqn]{book} % Default font size and left-justified equations
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\usepackage{pgfplotstable}
\usepgfplotslibrary{polar}
\usepgflibrary{shapes.geometric}
\usetikzlibrary{calc}
\usepackage{tikz}
\usepackage{booktabs}
\usepackage{fancyhdr}
\usepackage{array}
\usepackage{colortbl}
\usepackage[top=3cm,bottom=3cm,left=3.2cm,right=3.2cm,headsep=10pt,letterpaper]{geometry} % Page margins
\usepackage{xcolor} % Required for specifying colors by name
\definecolor{ocre}{RGB}{52,177,201} % Define the orange color used for highlighting throughout the book
% Font Settings
\usepackage{avant} % Use the Avantgarde font for headings
\usepackage{times} % Use the Times font for headings
\usepackage{mathptmx} % Use the Adobe Times Roman as the default text font together with math symbols from the Symbol, Chancery and Computer Modern fonts
\usepackage{microtype} % Slightly tweak font spacing for aesthetics
\usepackage[utf8]{inputenc} % Required for including letters with accents
\usepackage[T1]{fontenc} % Use 8-bit encoding that has 256 glyphs
\usepackage{amsthm}
%\usepackage{amsmath}
\usepackage{mathtools}
\DeclarePairedDelimiter\Floor\lfloor\rfloor
\DeclarePairedDelimiter\Ceil\lceil\rceil
% Bibliography
\usepackage[style=alphabetic,sorting=nyt,sortcites=true,autopunct=true,babel=hyphen,hyperref=true,abbreviate=false,backref=true,backend=biber]{biblatex}
\addbibresource{bibliography.bib} % BibTeX bibliography file
%\defbibheading{bibempty}{}

%\input{structure} % Insert the commands.tex file which contains the majority of the structure behind the template

%----------------------------------------------------------------------------------------
%   Definitions of new commands
%----------------------------------------------------------------------------------------
\def\R{\mathbb{R}}
\newcommand{\cvx}{convex}
% glossary
\begin{document}
\begin{equation}\label{Rate of exchange for Giver: ROEG}
ROE (\frac{\epsilon}{n},\iota ,b) = (1-\frac{\epsilon}{n})*\iota ^n b
\end{equation}
This is the giver's model. It will be extended to include situations where a person gives more than 
\[(1-\frac{\epsilon}{n})\].



\begin{equation}\label{Rate of exchange for Reciever: ROER}
ROE (\frac{\epsilon}{n},\iota) = 
  \begin{cases}
(1-\frac{\epsilon}{n})*\iota^n & \text{if\frac{\epsilon}{n}>1} \\
(\frac{\epsilon}{n}-1)*\iota^n & \text{if\frac{\epsilon}{n}<1} \\
  \end{cases}

\end{equation}
\end{document}

答案1

一些评论和建议。正如@Bernard 和@TorbjørnT. 已经指出的那样,你必须

  • \end{cases}删除和之间的空行\end{equation},然后
  • 更改\text{if\frac{\epsilon}{n}>1}\text{if }\frac{\epsilon}{n}>1,第二个 也同样如此case

此外,您还应该考虑用 替换所有三个实例*\cdot*完全省略),使用直立罗马字母排版变量名称,以及——这是可选的——用 替换所有情况\frac{\epsilon}{n}\epsilon/n即使用内联分数表示法。

顺便说一句,由于您还加载了,因此无需加载times包(反正已经过时了)mathptmx。哦,不要单独加载colortblxcolor包;而是运行\usepackage[table]{xcolor}

在此处输入图片描述

\documentclass[11pt,fleqn]{book}
\usepackage[vmargin=3cm,hmargin=3.2cm,headsep=10pt,letterpaper]{geometry} % Page margins
%%%\usepackage{colortbl}
%%%\usepackage{xcolor} % Required for specifying colors by name
\usepackage[table]{xcolor}
\definecolor{ocre}{RGB}{52,177,201} % Define the orange color used for highlighting throughout the book

% Font Settings
\usepackage{avant} % Use the Avantgarde font for headings
%%%%\usepackage{times} % Use the Times font for headings
\usepackage{mathptmx} % Use the Adobe Times Roman as the default text font together with math symbols from the Symbol, Chancery and Computer Modern fonts
\usepackage{microtype} % Slightly tweak font spacing for aesthetics

\usepackage[utf8]{inputenc} % Required for including letters with accents
\usepackage[T1]{fontenc} % Use 8-bit encoding that has 256 glyphs

\usepackage{amsthm}
%\usepackage{amsmath} % is loaded automatically by 'mathtools'
\usepackage{mathtools}
\DeclarePairedDelimiter\Floor\lfloor\rfloor
\DeclarePairedDelimiter\Ceil\lceil\rceil


% New user commands
\def\R{\mathbb{R}}
\newcommand{\cvx}{convex}
\newcommand\vn[1]{\mathrm{#1}}

% glossary

\begin{document}
\begin{equation}\label{Rate of exchange for Giver: ROEG}
   \vn{ROE}(\epsilon/n,\iota,b) = (1-\epsilon/n)\cdot\iota^n b
\end{equation}
This is the giver's model. It will be extended to include situations 
where a person gives more than $1-\epsilon/n$.
\begin{equation}\label{Rate of exchange for Receiver: ROER}
   \vn{ROE} (\epsilon/n,\iota) = 
   \begin{cases}
      (1-\epsilon/n)\cdot\iota^n & \text{if }\epsilon/n>1 \\
      (\epsilon/n-1)\cdot\iota^n & \text{if }\epsilon/n<1
   \end{cases}
\end{equation}
\end{document}

相关内容