# Inline LaTeX errors

**URL:** <https://discourse.jupyter.org/t/inline-latex-errors/22471>\
**Category:** JupyterLab\
**Created:** [November 18, 2023, 12:16am UTC](https://discourse.jupyter.org/t/inline-latex-errors/22471 "2023-11-18T00:16:52Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cane](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@Cane](https://discourse.jupyter.org/u/Cane)\
**Post date:** [November 18, 2023, 12:16am UTC](https://discourse.jupyter.org/t/inline-latex-errors/22471/1 "2023-11-18T00:16:52Z")

</div>

Hello, I just started using JupyterLab and I wanted to add som formating to my markdown. But when I add LaTeX code, it starts doing weird stuff, like changing a right parenthesis “)” to a big “D”. Adding/removing and/or moving period- and comma signs (other characters to, but not as often)…

I didn’t use anything advanced, just $\quad$ for indentation and a backslash for new line.

It doesn’t make this things while I am editing the cell, only after I run it. And when that have happened, it doesn’t help to remove the LaTex code and running the cell again, because the problem remains. One time it even made a part of the text bold, after removing the LaTeX code (previously there was no bold text in the cell).

It did successfully add this piece of code, without error’s in its own cell:  
$p\_sgV - p\_agV - F\_D = p\_sVa.$

Anyone know what is going on?

---

<div class="post-metadata">

**Author:** ![Cane](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@Cane](https://discourse.jupyter.org/u/Cane)\
**Post date:** [November 18, 2023, 9:53am UTC](https://discourse.jupyter.org/t/inline-latex-errors/22471/2 "2023-11-18T09:53:25Z")

</div>

Perhaps I should add some more information. I am using the latest version of JupyterLab desktop, with the latest version of Anaconda, on Windows 10.

---

<div class="post-metadata">

**Author:** ![krassowski](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/krassowski/32/1685_2.png) [@krassowski](https://discourse.jupyter.org/u/krassowski)\
**Post date:** [November 18, 2023, 7:42pm UTC](https://discourse.jupyter.org/t/inline-latex-errors/22471/3 "2023-11-18T19:42:03Z")

</div>

Can you provide a specific example, with the contents of a cell that we could paste for reproduction and a screenshot of the problematic rendering?

---

<div class="post-metadata">

**Author:** ![Cane](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@Cane](https://discourse.jupyter.org/u/Cane)\
**Post date:** [November 19, 2023, 12:48am UTC](https://discourse.jupyter.org/t/inline-latex-errors/22471/4 "2023-11-19T00:48:11Z")

</div>

It is unfortunately not consistent. But here is one example. It is written in swedish, but that shouldn’t matter, because we use the same letters as in english (exept we have 3 additional ones (å, ä, ö) and they are not causing a problem in this example).

The lower part is the same cell, after I double clicked on it, to show what I typed.

 ![Latex error](https://canada1.discourse-cdn.com/flex031/uploads/jupyter/original/2X/8/83548cb1ce4d4802f4bb0e5f7a3af7595c0d3951.png)

---

<div class="post-metadata">

**Author:** ![Cane](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@Cane](https://discourse.jupyter.org/u/Cane)\
**Post date:** [November 19, 2023, 12:53am UTC](https://discourse.jupyter.org/t/inline-latex-errors/22471/5 "2023-11-19T00:53:08Z")

</div>

Here is the content of the cell, as text:

```auto
$\quad$ Runt slutet av 1500-talet genomförde Galileo Galilei (1564-1642), en italiensk astronom och matematiker, långa studier av projektilers rörelse. Som en del av dessa studier, enligt den populära historien, tappade han föremål av olika vikt och storlekar från toppen av det lutande tornet i Pisa och observerade deras falltider.\
$\quad$ Galileo drog slutsatsen att ett fallande föremåls hastighet endast beror på fallavståndet, inte på dess storlek eller vikt. Han satte till vila, eller trodde att han gjorde det, den dåvarande uppfattningen att ju större och tyngre ett föremål är, desto snabbare faller det. Han hade delvis rätt, delvis fel.\
$\quad$ Samma år som Galileo dog föddes Isaac Newton (1643-1727). De berömda rörelselagarna för detta engelska geni rensade bort det mesta av förvirringen angående Galileos resultat. Hans andra lag var särskilt hjälpsam. Denna lag säger att summan av alla krafter som verkar på ett föremål är lika med föremålets massa gånger dess acceleration.\
$\quad$ För ett föremål som faller genom luften ger detta förhållande

```

---

<div class="post-metadata">

**Author:** ![Cane](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@Cane](https://discourse.jupyter.org/u/Cane)\
**Post date:** [November 19, 2023, 3:54am UTC](https://discourse.jupyter.org/t/inline-latex-errors/22471/6 "2023-11-19T03:54:18Z")

</div>

Well, that was weird… I have tried to copy and past the code from this site and it always seem’s to turn out as expected. I then took the same text, from my original Notepad document (where I made my notes) and pasted it in the cell, below the one from this site (in the same Notebook) and I get the same error as I described and that is clearly seen in the picture.

Copying from this site and then pasting into a new Notepad document, and saving and then copying from the document and pasting to JupyterLab, does not produce the problem.

This is strange, because I have used Notepad as my exclusive note taking program for decades and there have never been a case, where any type of extra information (formating or otherweise) have been saved to or transfered from such a document. It should be plain text.

Is there some type of program or site, where you could paste the problematic code and see what type of extra information is being included?

Besides that. Like I said before, the errors only appear after introducing LaTeX, it doesn’t show up when I only use Markdown.

---

<div class="post-metadata">

**Author:** ![fomightez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fomightez/32/495_2.png) [@fomightez](https://discourse.jupyter.org/u/fomightez)\
**Post date:** [November 19, 2023, 11:11pm UTC](https://discourse.jupyter.org/t/inline-latex-errors/22471/7 "2023-11-19T23:11:56Z")

</div>

> [@Cane](#):
>
> my original Notepad document

Do you mean Microsoft Notepad?  
Anything made by Microsoft, except Visual Studio Code (VSCode), is traditionally notorious for adding things in. When learning to code usually it will be emphasized to use code writing software, i.e., a proper text editor, specifically for this reason.

And if you mean Notepad++, see [here](https://stackoverflow.com/a/47273567/8508004) as how you can toggle that on. Most text editors for coding allow that sort of setting.

> [@Cane](#):
>
> Is there some type of program or site, where you could paste the problematic code and see what type of extra information is being included?

Did you find this site [‘View non-printable unicode characters’ at SoSci Survey](https://www.soscisurvey.de/tools/view-chars.php) and try that?

And have your tried to use a text editor? JupyterLab should let you open a text document and paste in stuff to check that way as it has its own text editor.  
You can otherwise install and use a dedicated one, such as Sublime Text, Atom, or Notepad++. Visual Studio Code (VSCode) is actually now very popular and ruins the older adage of ‘Avoid anything with Microsoft in the name’ that is commonly repeated over and over to those learning to code. It however is more than just a text editor and is more of a full Interactive Development Environment (IDE).

Other online options, perhaps…  
You can maybe use your text that causes issues now to screen online ones that are out there. [StackEdit](https://stackedit.io/) handles markdown so it may be more than you need. And of course there’s Jupyter accessible online, such as you can get from pressing the blue-green text that says ‘JupyterLab’ to the right of where it says ‘Open demo in a new tab’ at the top center of the page at [the JupyterLite site](https://jupyterlite.readthedocs.io/en/stable/). And as you’ve seen you can paste things in a text

---

<div class="post-metadata">

**Author:** ![Cane](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@Cane](https://discourse.jupyter.org/u/Cane)\
**Post date:** [November 20, 2023, 8:16am UTC](https://discourse.jupyter.org/t/inline-latex-errors/22471/8 "2023-11-20T08:16:07Z")

</div>

You are missing the point.I am not talking about code. Do you see any code in my example (everything you see is markdown cells)? There will be Python code, but I intended to type it directly in other cells (code cells) in JupyteLab, that’s kind of the point of Jupyter Notebooks, to be able to mix code and text that explains the code (not the same thing as when you put comments in your code).

When it comes to editors, I have used all the well known ones, during my 25+ years of coding. But like I said, that have nothing to do with my notes. They are not code, only my explanation of the code.

And no. I have never seen Microsoft Notepad add anything to the text (We are not talking about Microsofts WordPad or Word (Part of Microsoft Office) They would have added information about the font, font size, if it is bold, italic etc. but Notepad doesn’t have that capability.). I have used it to remove information about styling, thousends of times (from copied text, from documents and websites) and it have never added anything of it’s own, only removed and made it plain text.

And the site didn’t show anything, just as it shouldn’t (the only thing it did was to change to a “formatting marks” view and I have already tried that in LibreOffice with the same piece of text). But thanks anyway.

---

<div class="post-metadata">

**Author:** ![krassowski](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/krassowski/32/1685_2.png) [@krassowski](https://discourse.jupyter.org/u/krassowski)\
**Post date:** [November 20, 2023, 10:40am UTC](https://discourse.jupyter.org/t/inline-latex-errors/22471/9 "2023-11-20T10:40:01Z")

</div>

Could it be some encoding issue during pasting from a specific Windows app? Could you try uploading a minimal notebook with the problematic markdown cell on [https://gist.github.com/](https://gist.github.com/) (by drag-and-drop - a bit unintuitive, assuming you have a GitHub account) and sharing the gist?

---

<div class="post-metadata">

**Author:** ![krassowski](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/krassowski/32/1685_2.png) [@krassowski](https://discourse.jupyter.org/u/krassowski)\
**Post date:** [November 20, 2023, 10:41am UTC](https://discourse.jupyter.org/t/inline-latex-errors/22471/10 "2023-11-20T10:41:35Z")

</div>

Or could it be down to an issue with line endings encoding? Does the issue happen when more often depending on the number of lines (and e.g. does not happen at all when there is a single line?). Also, What exact jupyterlab version are you running?

---

<div class="post-metadata">

**Author:** ![Cane](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@Cane](https://discourse.jupyter.org/u/Cane)\
**Post date:** [November 20, 2023, 10:55am UTC](https://discourse.jupyter.org/t/inline-latex-errors/22471/11 "2023-11-20T10:55:32Z")

</div>

I am not publishing on github or any other place.  
Here is a Google Drive link:

> **[latex error.ipynb](https://drive.google.com/file/d/1URakyy03ixzlWxlOfuKwIObr6bcsD_mG/view?usp=sharing)**
>
> Google Drive file.

As you can see in the example, the first line works, but the subsequent ones does not. That’s why it seems like a bug in JupyterLab/Anaconda. I don’t know why I decided to check the output of the paste from Notepad. I have never seen a problem with it before and I can’t find a fault now either…

I downloaded JupyterLab Desktop Version 4.0.7-1 and then updated to 4.0.8.But I see now that, 4.0.8 doesn’t start when I click the exe file in Windows. Anaconda shows 4.0.8 though.

Edit.  
More mysterious things happening. I did just open JupyterLab to see, what version it was and it rapported 4.0.7-1. Then oppened Anaconda Navigator, and it showed 4.0.8.  
I opened JupyterLab again after typing my reply, and now it shows 4.0.8…

---

<div class="post-metadata">

**Author:** ![Cane](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@Cane](https://discourse.jupyter.org/u/Cane)\
**Post date:** [November 20, 2023, 11:19am UTC](https://discourse.jupyter.org/t/inline-latex-errors/22471/12 "2023-11-20T11:19:16Z")

</div>

Like I said before, the errors doesn’t show up the same every time. Downloading my own file, I can see that it somehow makes it look like I typed “acceleratio\n.” And i pasted (the original text have the backslash after the period sign) and double checked before uploading it. It seems like JupyterLab is changing the text when I Run the cell.

Edit.  
Appearantly it also change the text when saving… Because I made another copy, got it to stick and then saved it. Before upploading it, I decided to open it again and this file, now all of a sudden, shows “acceleratio\n.” (With double backslashes. This site can’t show it, so I have to type it out or take screenshots). Even though it had the backslash in the right place (still with error in the output, as discussed).

---

<div class="post-metadata">

**Author:** ![krassowski](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/krassowski/32/1685_2.png) [@krassowski](https://discourse.jupyter.org/u/krassowski)\
**Post date:** [November 20, 2023, 12:31pm UTC](https://discourse.jupyter.org/t/inline-latex-errors/22471/13 "2023-11-20T12:31:00Z")

</div>

This is the issue with new line endings. I see Windows “\r\n” in the file you shared. And it seems that it is already tracked here:

- [Windows / Chrome: markdown code blocks get corrupted after pasting Windows line endings · Issue #14752 · jupyterlab/jupyterlab · GitHub](https://github.com/jupyterlab/jupyterlab/issues/14752)

You could try the latest 4.0.9 version which bumped ydoc but my guess is it will not help in itself.

---

<div class="post-metadata">

**Author:** ![Cane](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@Cane](https://discourse.jupyter.org/u/Cane)\
**Post date:** [November 21, 2023, 1:59pm UTC](https://discourse.jupyter.org/t/inline-latex-errors/22471/14 "2023-11-21T13:59:30Z")

</div>

So it is a Chrome problem then? Because like bh1428 said, it seems to work in FireFox. That’s a pitty because not only am I on my way to phasing out FireFox for Vivaldi (it’s Chromium-based), I prefer to use a standalone program (the Desktop version in this case), instead of runing applications in the browser.

---

<div class="post-metadata">

**Author:** ![krassowski](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/krassowski/32/1685_2.png) [@krassowski](https://discourse.jupyter.org/u/krassowski)\
**Post date:** [November 21, 2023, 3:03pm UTC](https://discourse.jupyter.org/t/inline-latex-errors/22471/15 "2023-11-21T15:03:21Z")

</div>

> So it is a Chrome problem then?

So there is a difference between Chrome and Firefox in handline new lines on copy/paste. See:

- [1376516: CR (carriage return) added before LF (line feed) in copied text](https://bugs.chromium.org/p/chromium/issues/detail?id=1376516)
- [1589098 - Carriage return replaced with newline in paste dataTransfer content outside headless mode](https://bugzilla.mozilla.org/show_bug.cgi?id=1589098)

It apepars that Chromium maintainers are not interested in changing the behaviour and instead recommend working it around, which is what we as JupyterLab community will need to do. I am happy to help with a review of a pull request if anyone is interested in working on this.

---

<div class="post-metadata">

**Author:** ![Cane](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@Cane](https://discourse.jupyter.org/u/Cane)\
**Post date:** [November 21, 2023, 3:14pm UTC](https://discourse.jupyter.org/t/inline-latex-errors/22471/16 "2023-11-21T15:14:01Z")

</div>

I don’t have the posibility to work on it. But I will certainly test new versions, if somone else tries to fix it.

---

<div class="post-metadata">

**Author:** ![Andrew\_Swann](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/andrew_swann/32/9157_2.png) [@Andrew\_Swann](https://discourse.jupyter.org/u/Andrew_Swann)\
**Post date:** [February 10, 2024, 3:10pm UTC](https://discourse.jupyter.org/t/inline-latex-errors/22471/17 "2024-02-10T15:10:40Z")

</div>

Note that markdown is not LaTeX. The rules for input are to found at [https://spec.commonmark.org/](https://spec.commonmark.org/)  
Though this often extend with mathjax support inside $…$ and […].

In particular, paragraphs in the input should just be separated by blank lines.

```auto
Runt slutet av 1500-talet genomförde Galileo Galilei (1564-1642), en italiensk astronom och matematiker, långa studier av projektilers rörelse. Som en del av dessa studier, enligt den populära historien, tappade han föremål av olika vikt och storlekar från toppen av det lutande tornet i Pisa och observerade deras falltider.

Galileo drog slutsatsen att ett fallande föremåls hastighet endast beror på fallavståndet, inte på dess storlek eller vikt. Han satte till vila, eller trodde att han gjorde det, den dåvarande uppfattningen att ju större och tyngre ett föremål är, desto snabbare faller det. Han hade delvis rätt, delvis fel.

```

Paragraph indenting should be controlled by your style sheet, rather than manual addition of spacing.
