I am having a frustrating recurring issue with the frontend (Mathematica 12.1.1 for Mac OS X x86 (64-bit) (June 19, 2020)).
I will have a notebook which works just fine, all lines evaluate. Next, I will close the notebook for the day, come back the next day, open the notebook and the code within a Module
will be misaligned such that it does not run (see attached image).
I will fix the alignment issue, the code will run, then I will close the notebook come back and the same thing has happened.
Thus, every time I open the notebook I have to realign the code. This only seems to happen to code within a Module
.
I am not an expert with Mathematica, but have used it for a few years now. I can't see what I am doing incorrectly as the code runs perfectly (repeatedly) once the notebook is opened and the alignment issue fixed. I can work on the code and it continue to work. The error then reappears when closing and reopening the notebook.
I read that 12.1.1 had some front end issues. Indeed, I was having some of these as well e.g. code randomly formatting as a Wolfram Alpha query.
I am running the latest version, freshly reinstalled today.
Am I missing something obvious?
*** EDITS ***
Sorry about the spelling, despite being 41 I have difficulties in that area which I cannot overcome.
I avoided posting code as the whole notebook is very complex. Here is the module code:
(* Module for plotting for the PSE *)
minXpse = 51.9;
maxXpse = 58.1;
theRangePSE = maxXpse - minXpse;
plotPseData[predPSE0_, combPSE0_, xPSE0_, polyPSE0_, polyDelta0_,
visionPSE0_, hapticPSE0_, rsqPSE0_] := Module[
{predPSE = predPSE0, combPSE = combPSE0, xPSE = xPSE0,
polyPSE = polyPSE0, polyDelta = polyDelta0,
visionPSE = visionPSE0, hapticPSE = hapticPSE0,
rsqPSE = rsqPSE0},
(* Plot the data *)
dataPlot =
ListPlot[Transpose[{predPSE, combPSE}], AspectRatio -> 1,
Frame -> True,
FrameLabel -> {"Predicted PSE" <> xLabelTag,
"Observed PSE" <> yLabelTag},
FrameStyle -> Directive[Black, 19, Thickness[0.002]],
ImageSize -> Large, BaseStyle -> {FontSize -> 22},
PlotRange -> {{minXpse, maxXpse}, {minXpse, maxXpse}},
Method -> {"AxesInFront" -> False},
PlotLabel -> Style[theTitle, Black, 24], PlotStyle -> Blue,
PlotMarkers -> {Automatic, Scaled[0.02]}];
(* Plot the fit *)
fitPlot =
ListLinePlot[Transpose[{xPSE, polyPSE}], PlotStyle -> Blue];
(* Plot the error bounds *)
boundsPlot =
ListLinePlot[{Transpose[{xPSE, polyPSE + polyDelta}],
Transpose[{xPSE, polyPSE - polyDelta}]},
PlotStyle -> {{Blue, Dashed}, {Blue, Dashed}},
Filling -> {1 -> {2}}];
(* Plot the PSE lines *)
visionPSEline =
Graphics[{Dashed, Thick, Green,
Line[{{visionPSE, minXpse}, {visionPSE, maxXpse}}]}];
hapticPSEline =
Graphics[{Dashed, Thick, Red,
Line[{{hapticPSE, minXpse}, {hapticPSE, maxXpse}}]}];
(* Plot the unity line *)
unityLine =
Graphics[{Thick, Gray,
Line[{{minXpse, minXpse}, {maxXpse, maxXpse}}]}];
(* Report the R^2 *)
rsqText =
Graphics[
Text[Style[
ToString[Superscript["R", "2"], FormatType -> StandardForm] <>
" = " <> ToString[Part[rsqPSE, 1]],
18], {minXpse + theRangePSE/2, 57.5}, {0, 0}]];
(* Show *)
Show[dataPlot, unityLine, visionPSEline, hapticPSEline, dataPlot,
fitPlot, boundsPlot, rsqText]
];
It's not feasible to post the whole code without a bunch of work. The code reads in a bunch of data files (100's).
( *
when they should be(*
but it's hard to tell from the picture. $\endgroup$f[y_] := Module[{x = y}, ( * something *) x += 3; ( * another thing*) x *= 7 ];
It is fixed by using(*
without a space. $\endgroup$StyleBox
, I suppose. Hard for me to guess what it is or how to fix it without having the cell expression. You could post it on pastebin.com and link it here. $\endgroup$