0

I'm a total noob with LaTeX and I keep getting an error on the last line of this code:

\begin{align*}
        14038 \pmod{1529} = 277 & \mbox{as 14038 = 1529\cdot 9 + 277}\\
        & 1529 \pmod{277} = 144 & \mbox{as 1529 = 277\cdot 5 + 144} \\
        & 277 \pmod{144} = 133 & \mbox{as 277 = 144\cdot 1 + 133} \\
        & 144 \pmod{133} = 11 & \mbox{as 144 = 133\cdot 11 + 1} \\
        & 133 \pmod{11} = 1 & \mbox{as 133 = 11\cdot 12 + 1} \\
        & 11 \pmod{1} = 0 & \mbox{as 11 = 1\cdot 11 + 0}
\end{align*}

I get an error saying "Missing $ inserted. Extra }, or missing $. Missing } inserted". I checked through it, and I'm pretty sure I don't have any stray curly brackets or $ symbols. I've used align before in the PDF multiple times before, formatted in the same way, and it's been fine with that. I don't know what's wrong here.

EDIT - ANSWERED Thanks for your answers! I'm really unfamiliar with overleaf so it probably would've taken me ages on my own to find out that mbox was text-formatting. Thank you for being patient with me :)

  • Hello Dave! Tom from Overleaf Support Team here. I don't know what could cause this. But if your project lives in Overleaf, you can reach me on Overleaf support email address and we can see what's going on there. Then if it's something worth sharing with others, I will make an answer here. – yo' Nov 27 '19 at 11:12
1

This will work:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
  14038 \pmod{1529} = 277 & \mbox{as }14038 = 1529\cdot 9 + 277\\
  & 1529 \pmod{277} = 144 & \mbox{as }1529 = 277\cdot 5 + 144 \\
  & 277 \pmod{144} = 133 & \mbox{as }277 = 144\cdot 1 + 133 \\
  & 144 \pmod{133} = 11 & \mbox{as }144 = 133\cdot 11 + 1 \\
  & 133 \pmod{11} = 1 & \mbox{as }133 = 11\cdot 12 + 1 \\
  & 11 \pmod{1} = 0 & \mbox{as }11 = 1\cdot 11 + 0
\end{align*}
\end{document}

Your error consisted in putting expressions such as 14038 = 1529\cdot 9 + 277 within a \mbox. Besides, I suggest that you use \text instead.

  • 1
    Your code, as well as that of the OP, is missing an & symbol before 14038. – Mico Nov 27 '19 at 11:05
  • @Mico But that shouldn't make either of the codes fail, right? :) – yo' Nov 27 '19 at 11:10
  • @yo' - The code compiles, but the first row's position is messed up completely... – Mico Nov 27 '19 at 11:19
1

In addition to including only "as" in the argument of either \mbox or \text and supplying a missing & symbol immediately before 14038, do consider switching to an alignat* environment and aligning the material on the = symbols.

enter image description here

\documentclass{article}
\usepackage{amsmath} % for 'alignat*' env. and '\text' macro
\begin{document}
\begin{alignat*}{3}
  14038 \pmod{1529} &= 277&\quad\text{as }14038 &= 1529\cdot 9 + 277\\
  1529 \pmod{277} &= 144  &     \text{as }1529 &= 277\cdot 5 + 144 \\
  277 \pmod{144} &= 133   &     \text{as }277 &= 144\cdot 1 + 133 \\
  144 \pmod{133} &= 11    &     \text{as }144 &= 133\cdot 11 + 1 \\
  133 \pmod{11} &= 1      &     \text{as }133 &= 11\cdot 12 + 1 \\
  11 \pmod{1} &= 0        &     \text{as }11 &= 1\cdot 11 + 0
\end{alignat*}
\end{document}
0

With \mbox you go from math to text where math operator \cdot doesn't work. Consequently you receive error. You can solve your problem on two ways:

instead of \mbox{as 14038 = 1529\cdot 9 + 277} write

  • `\mbox{ as $14038 = 1529\cdot 9 + 277$}˙, or
  • \text{ as } 14038 = 1529\cdot 9 + 277}

where \text{...} is defined in the amsmath package.

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.