Fail to convert to pdf


I have found a weird behavior of the conversation to pdf via Latex in Jupyter Notebook. I have my students sending me their hand in assignments as notebooks and for one of them I could not convert it to pdf. I got an error message that missing dollar-signs were inserted. This is weird because the code is correct with dollar-signs and renders fine in Markdown.

However, there is an extra space infront of the last dollar-sign and it seem like the converter replaces “space+dollar” with “backslash+dollar”. If I remove the blank space before the last dollar sign it will convert without an error.

Problem now is I got hundreds of these. I could do a search and replace but sometimes the extra space is motivated. Also, it is not consistent. Sometimes it fails, sometimes not. And sometimes it also fails if there is an extra space after the dollar-sign.

Any idea what’s going on and how to fix it?


BWT, I can’t submit any examples from the code because this forum randomly removes some the $ signs and \ signs in the code examples I paste (although not in this sentence).