[Tex/LaTex] Compiler Error with pgfplots package

errorsoverleafpgfplotssharelatex

my code suddenly stopped compiling and getting this errors:

File ended while scanning definition of \pgfplots@show@ref@Gain.

} l.89 \begin{document}
I suspect you have forgotten a }', causing me to read past where you wanted me to stop. I'll try to recover; but if the
error is serious, you'd better type E' orX' now and fix your file.
thesis.tex, line 89

Illegal parameter number in definition of \pgfplots@show@ref@Gain.

1 l.89 \begin{document}
You meant to type ## instead of #, right? Or maybe a } was forgotten somewhere earlier, and things are all screwed up?
I'm going to assume that you meant ##. thesis.tex

File ended while scanning definition of \pgfplots@show@ref@Gain.

} <*> thesis.tex
I suspect you have forgotten a }', causing me to read past where you wanted me to stop. I'll try to recover; but if the
error is serious, you'd better type E' orX' now and fix your file.

! Emergency stop. <*> thesis.tex

*** (job aborted, no legal \end found)

To be sure, I also tried to compile a backup file that I compiled with no errors two days ago and it, now, gives me the same errors. I am currently using overleaf. Am I the only one getting this error? Is it possible that there is some problem with overleaf loading the pgfplots packages? Or am I missing something? The whole code is more than 2000 lines, should I attach that as well?

\documentclass[12pt, oldfontcommands]{memoir}
\usepackage[table]{xcolor}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{microtype}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{indentfirst}
\usepackage[english]{babel}
\usepackage{fancyhdr}
\usepackage{amssymb}
\usepackage[export]{adjustbox}
\usepackage[sorting=none]{biblatex}
\usepackage{csquotes}
\newcommand{\parallelsum}{\mathbin{\!/\mkern-5mu/\!}}
\usepackage{pgfplots}
\pgfplotsset{width=8cm,compat=1.9} 
\usepackage{longtable}
\usepackage[acronym]{glossaries}
\usepgfplotslibrary{statistics}
\usepackage{rotating}
\usepackage{tikz}

\newacronym{OTA}{OTA}{Operational Transconductance Amplifier}
\newacronym{PWM}{PWM}{Pulse Width Modulation}
\newacronym{SDM}{SDM}{Sigma Delta Modulation}
\newacronym{CMRR}{CMRR}{Common Mode Rejection Ratio}
\newacronym{PSRR}{PSRR}{Power Supply Rejection Ratio}
\newacronym{LPWM}{LPWM}{Linear Pulse Width Modulation}
\newacronym{SR}{SR}{Slew Rate}
\newacronym{THD}{THD}{Total Harmonic Distortion}
\newacronym{IA}{IA}{Instrumentation Amplifier}
\newacronym{CFIA}{CFIA}{Current Feedback Instrumentation Amplifier}
\newacronym{GBW}{GBW}{Gain BandWidth}
\newacronym{FVF}{FVF}{Flipped Voltage Follower}
\newacronym{CMFB}{CMFB}{Common-Mode Feedback}

\makeglossaries

\addbibresource{ref.bib}


\usepackage{float}
\usepackage{amsmath}
\usepackage{mathtools}

\definecolor{light-gray}{gray}{0.85}
\usepackage[
breaklinks=true,colorlinks=true,
linkcolor=black,urlcolor=black,citecolor=black,% PRINT
bookmarks=true,bookmarksopenlevel=2]{hyperref}

\usepackage{geometry}
\geometry{total={210mm,297mm},
left=20mm,right=20mm,
bindingoffset=10mm, top=25mm,bottom=25mm}

\OnehalfSpacing


\setsecheadstyle{\Large\bfseries\rmfamily\raggedright}
\setsubsecheadstyle{\large\bfseries\rmfamily\raggedright}
\setsubsubsecheadstyle{\bfseries\rmfamily\raggedright}



\pagestyle{plain}
\makepagestyle{plain}
\makeevenfoot{plain}{\thepage}{}{}
\makeoddfoot{plain}{}{}{\thepage}
\makeevenhead{plain}{}{}{}
\makeoddhead{plain}{}{}{}


\maxsecnumdepth{subsection} 
\maxtocdepth{subsection} 

\begin{document}

The errors are at the same line of \begin{document} and they refer to "\pgfplots@show@ref@Gain." and to a "##" that is a character never used in the code. I also tried to remove all pgfplots or related packages and I still get the same error.

Best Answer

The problem was indeed not in the code. There was a problem with the cached files of previous compilations. The support from Overleaf has been fast in answering and solving the problem. Thanks for the answers.