錯誤錯誤,缺失{,缺失}

錯誤錯誤,缺失{,缺失}

我不断在同一行中遇到Error ! Missing { inserted.<to be read again>\mathchoice}错误Error ! Missing } inseted.<inserted text>} },但据我所见,LaTeX 是完全没问题的。

\documentclass[16pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
%\usepackage{datetime}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{subcaption}

%\usepackage{xcolor}

%\definecolor{grey}{RGB}{150,150,150}
%\definecolor{lightblue}{RGB}{41,232,209}
%\definecolor{lightgreen}{RGB}{70,209,60}

% for doing actual math
%\usepackage{fp}

% for vertcal dashed lines in array {c:c}
\usepackage{arydshln}

% for drawing trees
%\usepackage{forest}
%\usepackage{tikz}
%\usetikzlibrary{positioning, arrows, arrows.meta, shapes.geometric, shapes.multipart, shadows}

% code highlighting
% \usepackage{minted}

% adjustwidth, indent entire paragraph
%\usepackage{changepage}

% math, cancel / crossout
\usepackage[makeroom]{cancel}

% custom fonts
%\usepackage{fontspec}
\usepackage{graphicx}

% spacing
\usepackage[singlespacing]{setspace}

% print margins
\usepackage[margin=1in]{geometry}

% title
\title{PHYS 202 - Introductory Physics III \\ \large Assignment 1\vspace{-3ex}}

% author
\author{Drew Sommer\vspace{-3ex}}

% date
%\newdate{date}{11}{12}{2017}
%\newdateformat{specialdate}{\twodigit{\THEDAY}\;\;\monthname[\THEMONTH],\;\;\THEYEAR}
%\date{\normalsize\specialdate\displaydate{\today}}

% Bibliography
%\usepackage[babel]{csquotes}
%\usepackage[backend=biber, style=apa]{biblatex} %style=ieee
%\addbibresource{citations.bib}

% paragraph indent (first line)
\setlength{\parindent}{3em}
% paragraph spacing
\setlength{\parskip}{1.5em}

\newcommand{\ceil}[1]
{
    \left\lceil {#1} \right\rceil
}
\newcommand{\floor}[1]
{
    \left\lfloor {#1} \right\rfloor
}
\newcommand{\round}[1]
{
    \left\lceil {#1} \right\floor
}

\newcommand\ddfrac[2]{\frac{\displaystyle #1}{\displaystyle #2}}

\newcommand{\formdim}[2]
{
    \begin{array}{l:c}
        & \text{\footnotesize Dimensional Analysis} \\ \\
        \begin{aligned}
            #1
        \end{aligned} &
        \begin{array}{c}
            #2
        \end{array}
    \end{array}
}

\begin{document}
\maketitle

\[
\formdim{
    I &= \ddfrac{\mathcal{E}}{R_1} \\
        &= \ddfrac{-0.247}{0.28} \\
        &= -0.8821428571\; A
}{
    \ddfrac{\mathcal{E}}{R_1} = \ddfrac{V}{\Omega} \\ \\
    \ddfrac{\ddfrac{kg \cdot m^1}{A \cdot s^3}}{\ddfrac{kg \cdot m^2}{s^3 \cdot A^2}} \\ \\
    \ddfrac{kg \cdot m^2 \cdot s^3 \cdot A^2}{A \cdot s^3 \cdot kg \cdot m^2} \\ \\
    \ddfrac{\cancel{kg} \cdot \cancel{m^1} \cdot \cancel{s^3} \cdot A^\cancel{2}}{\cancel{A} \cdot \cancel{s^3} \cdot \cancel{kg} \cdot \cancel{m^2}} = A \\ \\
    A
} % <------- Here is the pointing of the error
\]
\end{document}

在我的几次\formdim调用中都出现了这种情况,但我的所有括号都是闭合的,一切看起来都很好。目前这实在是太烦人了,因为文档仍然可以编译和渲染。

内容还有很多,但对这个问题没有影响。鉴于它与课程有关,我真的不能分享它。

这是根据我用于所有作业和论文的通用模板改编的。

答案1

{}您的上标周围缺少内容。A^\cancel{2}A^{\cancel}{2}并且取消上标,没有任何参数。

这给出了错误

\documentclass[12pt]{article}% no 16pt option
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

% for vertcal dashed lines in array {c:c}
\usepackage{arydshln}



\usepackage[makeroom]{cancel}

% custom fonts
%\usepackage{fontspec}
\usepackage{graphicx}

% spacing
\usepackage[singlespacing]{setspace}

% print margins
\usepackage[margin=1in]{geometry}

% title
\title{PHYS 202 - Introductory Physics III \\ \large Assignment 1\vspace{-3ex}}

% author
\author{Drew Sommer\vspace{-3ex}}

% date
\setlength{\parindent}{3em}
% paragraph spacing
\setlength{\parskip}{1.5em}

\newcommand{\ceil}[1]
{
    \left\lceil {#1} \right\rceil
}
\newcommand{\floor}[1]
{
    \left\lfloor {#1} \right\rfloor
}
\newcommand{\round}[1]
{
    \left\lceil {#1} \right\floor
}

\newcommand\ddfrac[2]{\frac{\displaystyle #1}{\displaystyle #2}}

\newcommand{\formdim}[2]
{
    \begin{array}{l:c}
        & \text{\footnotesize Dimensional Analysis} \\ \\
        {\begin{aligned}
            #1
        \end{aligned}} &
        {\begin{array}{c}
            #2
        \end{array}}
    \end{array}
}

\begin{document}
\maketitle

\[
\formdim{
    I &= \ddfrac{\mathcal{E}}{R_1} \\
        &= \ddfrac{-0.247}{0.28} \\
        &= -0.8821428571\; A
}{
     \frac{A^\cancel{2}}{\cancel{A} \cdot \cancel{s^3} \cdot \cancel{kg} \cdot \cancel{m^2}} = A \\ 
    A
} % <------- Here is the pointing of the error
\]
\end{document}

这并不

\documentclass[12pt]{article}% no 16pt option
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

% for vertcal dashed lines in array {c:c}
\usepackage{arydshln}



\usepackage[makeroom]{cancel}

% custom fonts
%\usepackage{fontspec}
\usepackage{graphicx}

% spacing
\usepackage[singlespacing]{setspace}

% print margins
\usepackage[margin=1in]{geometry}

% title
\title{PHYS 202 - Introductory Physics III \\ \large Assignment 1\vspace{-3ex}}

% author
\author{Drew Sommer\vspace{-3ex}}

% date
\setlength{\parindent}{3em}
% paragraph spacing
\setlength{\parskip}{1.5em}

\newcommand{\ceil}[1]
{
    \left\lceil {#1} \right\rceil
}
\newcommand{\floor}[1]
{
    \left\lfloor {#1} \right\rfloor
}
\newcommand{\round}[1]
{
    \left\lceil {#1} \right\floor
}

\newcommand\ddfrac[2]{\frac{\displaystyle #1}{\displaystyle #2}}

\newcommand{\formdim}[2]
{
    \begin{array}{l:c}
        & \text{\footnotesize Dimensional Analysis} \\ \\
        {\begin{aligned}
            #1
        \end{aligned}} &
        {\begin{array}{c}
            #2
        \end{array}}
    \end{array}
}

\begin{document}
\maketitle

\[
\formdim{
    I &= \ddfrac{\mathcal{E}}{R_1} \\
        &= \ddfrac{-0.247}{0.28} \\
        &= -0.8821428571\; A
}{
     \frac{A^{\cancel{2}}}{\cancel{A} \cdot \cancel{s^3} \cdot \cancel{kg} \cdot \cancel{m^2}} = A \\ 
    A
} % <------- Here is the pointing of the error
\]
\end{document}

答案2

您的问题已通过以下建议得到解决大卫·卡莱尔 替换为A^{\cancel{2}},因此有些离题的评论......

  • \ddfrac我宁愿使用包dfrac中的定义amsmath
  • 用于genfrac重新定义frac,这样就可以渲染更粗的分数线
  • 重新定义\formdim维度推导以便看起来更美观

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
%\usepackage{amsfonts} % called by amssymb
\usepackage{amssymb}
% for vertical dashed lines in array {c:c}

% custom fonts
%\usepackage{fontspec}
\usepackage{graphicx}
% spacing
\usepackage[singlespacing]{setspace}
% print margins
\usepackage[margin=1in]{geometry}

\usepackage{arydshln}
% math, cancel / crossout
\usepackage[makeroom]{cancel}

% title
\title{PHYS 202 - Introductory Physics III \\ \large Assignment 1\vspace{-3ex}}
% author
\author{Drew Sommer\vspace{-3ex}}
\setlength{\parindent}{3em}
% paragraph spacing
\setlength{\parskip}{1.5em}

\newcommand{\ceil}[1]
{
    \left\lceil {#1} \right\rceil
}
\newcommand{\floor}[1]
{
    \left\lfloor {#1} \right\rfloor
}
\newcommand{\round}[1]
{
    \left\lceil {#1} \right\floor
}

\newcommand{\formdim}[2]
{
    \begin{array}{l:c}
                & \text{\footnotesize Dimensional Analysis} \\[2ex]
\begin{aligned}
    #1
\end{aligned}   &   \begin{aligned} % <-- changed
                        #2
                    \end{aligned}
    \end{array}
}
\renewcommand{\frac}[3][]{\genfrac{}{}{#1}{}{#2}{#3}}% <--- added

\begin{document}
\maketitle
\[
\formdim{
    I & = \dfrac{\mathcal{E}}{R_1} \\
      & = \dfrac{-0.247}{0.28}     \\
      & = -0.8821428571\; A
}{
    \dfrac{\mathcal{E}}{R_1}
      & = \dfrac{V}{\Omega}
        = \frac[1pt]{\dfrac{kg \cdot m}{A \cdot s^3}}
                    {\dfrac{kg \cdot m^2}{s^3 \cdot A^2}}                            \\[1ex]
      & = \dfrac{kg \cdot m^2 \cdot s^3 \cdot A^2}{A \cdot s^3 \cdot kg \cdot m^2}   \\
      & = \dfrac{\cancel{kg} \cdot \cancel{m^1} \cdot \cancel{s^3} \cdot A^{\cancel{2}}}
                {\cancel{A}  \cdot \cancel{s^3} \cdot \cancel{kg}  \cdot \cancel{m^2}} = A
}
\]
\end{document}

在此处输入图片描述

相关内容