am running into a rather awkward issue. I've decided to start using /label and /reference in order to better organize my notes but whenever I use /ref it gives me an undefined error, as follows:



The code (with the premable) is:

% chktex-file 36
% chktex-file 21
% chktex-file 8
% chktex-file 18
% chktex-file 11
% chktex-file 40
% chktex-file 3
% chktex-file 13
% chktex-file 25
% chktex-file 23
% chktex-file 29
% chktex-file 44
% chktex-file 12
% chktex-file 24
%chktex-file 9
% chktex-file 17
% chktex-file 1


% You can't have ^ outside math mode or compilation will fail.
\documentclass[10pt, welsh, english, a4paper]{report}
%\documentclass[10pt, welsh, english, a4paper]{report}

%Marginfigure stuff
\usepackage{polynom} %Polynomial long division typesetting, note that this does not support imaginary or complex roots with imaginary part not equal to 0
%Mathematical tools for fractions
% Basic Packages for Encoding (Input AND Output) and Langauge Support
%\usepackage[english]{babel} %Throws errors, just use babel by itself.
% Change Layout with a User-Friendly Interface
% Used for bolded letters, such as the set of all reals.
% Include Pictures with a User-Friendly Interface
\usepackage[export]{adjustbox} %Keep aspect ratio and resize
% Extended Math Support from the Famous 'American Mathematical Society'
% Physics package, mostly for the \abs command.
%Adjustable tables
\usepackage{animate} %To animate gifs, utilize imagemagick to convert the gif to several pngs by this command: (convert foo.gif foo.png), if the results are suboptimal try: (convert foo.gif -coalesce foo.png), you may probably get foo-0.png, foo-1.png... then use this code to animate them:     \animategraphics[width=0.25\textwidth,autoplay,loop,nomouse,controls]{12}{./Animated/animate_}{0}{99}
%Other optimizations
%Necessary for table of contents
\usepackage[svgnames]{xcolor} % New for changing color of every paragraph randomly

\renewcommand{\cftchapleader}{\color{red}     \cftdotfill{\cftsecdotsep}}
\renewcommand{\cftsecleader}{\color{blue}     \cftdotfill{\cftsecdotsep}}
\renewcommand{\cftsubsecleader}{\color{black} \cftdotfill{\cftsecdotsep}}
\renewcommand{\cftsubsubsecleader}{\color{DarkGreen} \cftdotfill{\cftsecdotsep}}

    colorlinks=true, %set true if you want colored links
    linktoc=all,     %set to all if you want both sections and subsections linked
    linkcolor=Indigo,  %choose some color if you want links to stand out



%Theorems, lemmas, corollaries enviorements

\renewcommand\qedsymbol{\(\blacksquare\)} %QED empty square to blacksquare
%Randomly color everything begin

%  \definecolor{randomcolor}{RGB}
%   {
%    \pdfuniformdeviate 256,
%    \pdfuniformdeviate 256,
%    \pdfuniformdeviate 256
%   }%
%  \color{randomcolor}%

%Randomly color everything end

%Randomly color section begin
%  \newkomafont{#1number}{}%
%  \expandafter\renewcommand\csname#1format\endcsname{%
%    {\usekomafont{secnum}\usekomafont{#1number}\csname the#1\endcsname\autodot}\enskip%
%  }%
%Randomly color section end

%Randomly color sections

%  \textcolor{LightSteelBlue}{\thesection}\autodot\enskip%
%  \textcolor{LightSteelBlue}{\thesubsection}\autodot\enskip%
%Randomly Color sections end

%New method

%Decoration of header and footer
%For fancyhead, /thepage prints the number of current page, /leftmark current chapter name, /rightmark current section name, /chaptername the name "chapter" in the current language. /thechapter current chapter number, /thesection current section number.
%\chapter{Using different page styles}
\fancyhead[LE,RO]{\emph{Written by Faycal Kilali}} %RIght corner of header text
\fancyhead[RE,LO]{\rightmark} %Left corner of header text
\fancyfoot[CE,CO]{\thepage} % Below footer text
%\fancyfoot[LE,RO]{\thepage} % Rights side below footer text

%%Decoration of header and footer
%\renewcommand{\subsubsectionmark}[1]{\markright{\thesubsubsection\ #1}} %Makes it possible for subsection and subsubsection to be part of /rightmark
%\fancyhead[LE,RO]{\emph{Written by Faycal Kilali}} %RIght corner of header text
%\fancyhead[RE,LO]{\rightmark} %Left corner of header text
%\fancyfoot[CE,CO]{\emph{Written by Faycal Kilali}} % Below footer text
%\fancyfoot[LE,RO]{\thepage} % Rights side below footer text


\definecolor{paleblue}{rgb}{0.69, 0.93, 0.93}
\definecolor{lightgray}{rgb}{0.83, 0.83, 0.83}
\definecolor{lightyellow}{rgb}{1.0, 1.0, 0.88}

\title{Compilation envirorement - for debugging and or writing LaTeX code to implement to other}
\author{Faycal Kilali\thanks{"It is not knowledge, but the act of learning, not possession but the act of getting there, which grants the greatest enjoyment." - Carl Friedrich Gauss}}

  \oldproof[\ttfamily \scshape \Large \color{red}{\textbf{Proof}}]%

%Below is if you dont' wanna re-define the proof environment. 
%  \proof[\ttfamily \scshape \large Exhibit (yes, ``#1'')]


    1 = potato \label{a}

 Lets go \ref{a} test


Any help would be appreciated.

EDIT (1): Am using Virtual Studio Code with latex-workshop, miktex, bibitex and pdflatex. I'd like to add that i'm u

  • Yes, over 10 times actually.
    – faycalki
    Commented Oct 27, 2020 at 14:27
  • I copied the code to overleaf.com (btw, this is always a good idea!) and the reference works. So, the problem should be connected to your setup. (FYI: I won’t comment on other problems with your code. It is obviously not a MWE.)
    – hh93
    Commented Oct 27, 2020 at 14:42
  • @hh93 damn, okay I'll restart my computer then I'll see if that fixes it, if it doesn't then it's probably an issue with VSC latex-workshop implementation or the premable that I setup. Did you copy over the premable too into overleaf? I'll try it as well.
    – faycalki
    Commented Oct 27, 2020 at 14:58

2 Answers 2


Using \label{a} in a gather* environment is useless anyway.

The label will be defined (and it's not possible to know why you don't obtain it), but \ref{a} will point to some random value, quite likely the number of the last section (whatever level it is). In the example code below it refers to 2, because of the second section.



\section{Test one}


\section{Test two}

1=Potato \label{a}



enter image description here

Of course, the reference will be to the equation number if you use gather, but gather* does not set a number.


I was able to resolve this issue by a certain tex stackexchange post that I simply am unable to find (i've tried like an hour but couldn't find it again), anyway the solution from that specific post was to change my latex-workshop recipe to the following:

"latex-workshop.latex.recipes": [
        "name": "luatex -> biber -> luatex*2",
        "tools": [
"latex-workshop.latex.tools": [{
        "name": "pdflatex",
        "command": "pdflatex",
        "args": [
        "name": "bibtex",
        "command": "bibtex",
        "args": [
        "name": "biber",
        "command": "biber",
        "args": [
        "name": "luatex",
        "command": "luatex",
        "args": [

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .