符号对齐表 - 可用但有错误

符号对齐表 - 可用但有错误

使用下面的代码,我得到了四 (4) 个错误和 1 个坏框。但是,输出是 PDF 中我需要的方式。知道我为什么会得到这些错误吗?如果知道,我该如何修复它。

错误Missing $插入到此代码中:

$y_{f}$ & $=$ & \left\{\begin{array}{rl}    1, &\mbox{ if Supplier located at site $f$ is open} \\0, &\mbox{ otherwise} \end{array} \right.\

\usepackage{mathtools}  
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tabulary}
\usepackage{booktabs}

\begin{table}[htbp]\caption{Table of Notation My Research}
\vspace{-1.5em}
\begin{center}
     \begin{tabular}{r c p{10cm} }
\toprule
$R_{i}$ & $\triangleq$ & Revenue at store $i$\\
$i$ & $\triangleq$ & index value for store locations\\
${T}_{c}$ & $\triangleq$ & A very long description of this specific variable and is needed in the research and looks good when wrapped and aligned to the left.\\
$TC$ & $\triangleq$ & Total overall cost(\$)\\  
\multicolumn{3}{c}{}\\
\multicolumn{3}{c}{\underline{Decision Variables}}\\
$y_{f}$ & $=$ & \left\{\begin{array}{rl}    1, &\mbox{ if Supplier located at site $f$ is open} \\
0, &\mbox{ otherwise} \end{array} \right.\\
\bottomrule
    \end{tabular}
\end{center}
    \label{tab:TableOfNotationForMyResearch}
\end{table}

答案1

如果您尝试编译此 MWE,您应该注意到您没有更多bad box。在我的解决方案中,我没有采用mbox来编写文本,而在第二个示例中,而是使用array我使用的环境cases(这可以让您看到差异)。

\documentclass[a4paper,11pt]{article}
\usepackage{mathtools}  
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tabulary}
\usepackage{booktabs}

\begin{document}
\begin{table}[htbp]\caption{Table of Notation My Research}
\begin{center}% used the environment to augment the vertical space
% between the caption and the table
\begin{tabular}{r c p{10cm} }
\toprule
$R_{i}$ & $\triangleq$ & Revenue at store $i$\\
$i$ & $\triangleq$ & index value for store locations\\
${T}_{c}$ & $\triangleq$ & A very long description of this specific variable and is needed in the research and looks good when wrapped and aligned to the left.\\
$TC$ & $\triangleq$ & Total overall cost(\$)\\  
\multicolumn{3}{c}{}\\
\multicolumn{3}{c}{\underline{Decision Variables}}\\
\multicolumn{3}{c}{}\\
$y_f$ & $=$ & \(\left\{\begin{array}{rl}
1,  & \text{if Supplier located at site $f$ is open} \\
0,  & \text{otherwise} \end{array} \right.\)\\
\bottomrule
\end{tabular}
\end{center}
\label{tab:TableOfNotationForMyResearch}
\end{table}
\end{document}

结果是:

在此处输入图片描述

如果您希望标题更靠近表格,请使用:

\documentclass[a4paper,11pt]{article}
\usepackage{mathtools}  
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tabulary}
\usepackage{booktabs}

\begin{document}
\begin{table}[htbp]\caption{Table of Notation My Research}
\centering % to have the caption near the table
\begin{tabular}{r c p{10cm} }
\toprule
$R_{i}$ & $\triangleq$ & Revenue at store $i$\\
$i$ & $\triangleq$ & index value for store locations\\
${T}_{c}$ & $\triangleq$ & A very long description of this specific variable and is needed in the research and looks good when wrapped and aligned to the left.\\
$TC$ & $\triangleq$ & Total overall cost(\$)\\  
\multicolumn{3}{c}{}\\
\multicolumn{3}{c}{\underline{Decision Variables}}\\
\multicolumn{3}{c}{}\\
$y_f$ & $=$ & \(\begin{cases}
1,  & \text{if Supplier located at site $f$ is open} \\
0,  & \text{otherwise} \end{cases}\)\\
\bottomrule
\end{tabular}
\label{tab:TableOfNotationForMyResearch}
\end{table}
\end{document}

结果是:

在此处输入图片描述

答案2

错误消息告诉您,您正在数学环境之外使用数学构造。 在您的例子中,它是用或\left\{ ... \right.包装它,错误应该会消失:$...$\(...\)

$y_{f}$ & $=$ & $\left\{
  \begin{array}{rl}    
     1, &\mbox{ if Supplier located at site $f$ is open} \\
     0, &\mbox{ otherwise} 
  \end{array} \right.$\

相关内容