Inline LaTeX errors

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?

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.

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?

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.

Here is the content of the cell, as text:

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

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.

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 as how you can toggle that on. Most text editors for coding allow that sort of setting.

Did you find this site ‘View non-printable unicode characters’ at SoSci Survey 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 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. And as you’ve seen you can paste things in a text

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.

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 (by drag-and-drop - a bit unintuitive, assuming you have a GitHub account) and sharing the gist?

1 Like

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?

1 Like

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

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.

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…

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.

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).

1 Like

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:

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


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.

So it is a Chrome problem then?

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

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.

1 Like

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