sagemathinc / cocalc

CoCalc: Collaborative Calculation in the Cloud
https://CoCalc.com
Other
1.16k stars 216 forks source link

latex: formatting latex files that use {pythontex} or {sagetex} breaks everything horribly, due to indentation #4215

Open williamstein opened 4 years ago

williamstein commented 4 years ago

Why -- formatting results in indentation of the code blocks, which is a syntax error in Python!

williamstein commented 4 years ago

Here is an example pythontex file:

\documentclass[11pt]{article}
\usepackage{pythontex}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{pyconsole}
x = 987.27
x = x**2
\end{pyconsole}

The variable is $x=\pycon{x}$
\end{document}
williamstein commented 2 months ago

Wow this is a huge bug and is still a problem today!

A possibly better fix would be to remove the python code, format, and put the code back.

Also https://github.com/siefkenj/unified-latex might do a better job (NOPE -- the demo there is way worse: https://siefkenj.github.io/latex-parser-playground/)