0

I keep on getting Error ! Missing { inserted.<to be read again>\mathchoice} and Error ! Missing } inseted.<inserted text>} } errors on the same line in, as far as I can see perfectly fine 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}

This happens several times in several of my \formdim calls, but all my braces are closed, everything looks fine. This is simply annoying to deal with at the moment, as the document still compiles and renders fine.

There is a lot more content, but that has no affect on this issue. Given its relation to a course, I really cannot share it.

This is adapted from a general template I use for all my assignments and papers.

  • 2
    Would you mind posting a full compilable code? – Bernard Jan 20 '18 at 1:45
  • note this is unrelated to texmaker, which is just the editor that you used to write the file. – David Carlisle Jan 20 '18 at 2:09
  • Why do you define a \ddfrac command which does exactly what \dfrac in amsmath does? – Bernard Jan 20 '18 at 2:22
  • I loved the title of this question! (;-) – GuM Jan 20 '18 at 8:29
5

you are missing {} around your superscript. A^\cancel{2} is A^{\cancel}{2} and leaves cancel in the superscript with no argument.

This gives the error

\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}

this does not

\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}
  • Yea, that was the issue, I thought that ^\cancel{x} would group the \cancel, in essentially the same way as ^\infty does, not that \infty has a parameter... Also, I never noticed I had my document set to 16pt, doing nothing – Drew Jan 20 '18 at 2:09
  • @Drew you should always use braces, even for single tokens, try \newcommand\ten{10} $ A^\ten+A^{\ten}$ and see... – David Carlisle Jan 20 '18 at 2:11
0

your problem is solved with suggestion of David Carlisle to replace withA^{\cancel{2}}, so some off-topic comments ...

  • instead to define \ddfrac i would rather use dfrac from amsmath package
  • use genfrac for redefining of frac so, that is possible render thicker fraction line
  • redefine \formdim for nicer looking of dimensions derivations

\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}

enter image description here

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.