0

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:

https://i.imgur.com/Pnknuz4.png

https://i.imgur.com/gBYcSPS.png

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

\PassOptionsToPackage{english}{babel}

% You can't have ^ outside math mode or compilation will fail.
\documentclass[10pt, welsh, english, a4paper]{report}
%\documentclass[10pt, welsh, english, a4paper]{report}
\usepackage[margin=1in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{siunitx}
\usepackage{microtype}
\input{glyphtounicode}



%Marginfigure stuff
%\usepackage{marginnote}
%\usepackage{xparse}
%\usepackage{l3keys2e}
%\usepackage{changepage}
%\usepackage{sidenotes}
\usepackage{polynom} %Polynomial long division typesetting, note that this does not support imaginary or complex roots with imaginary part not equal to 0
%Indenting
\usepackage{indentfirst}
%Mathematical tools for fractions
%\usepackage{nicefrac}
\usepackage{mathtools}
% Basic Packages for Encoding (Input AND Output) and Langauge Support
%\usepackage[english]{babel} %Throws errors, just use babel by itself.
\usepackage{babel}
% Change Layout with a User-Friendly Interface
\usepackage{enumitem,url,fancyref}
%\usepackage{enumitem,geometry,url,fancyref}
% Used for bolded letters, such as the set of all reals.
\usepackage{amssymb}
% Include Pictures with a User-Friendly Interface
\usepackage{graphicx}
\usepackage{float}
\usepackage{subcaption}
\usepackage[export]{adjustbox} %Keep aspect ratio and resize
% Extended Math Support from the Famous 'American Mathematical Society'
\usepackage{amsmath}
% Physics package, mostly for the \abs command.
\usepackage{physics}
%Adjustable tables
\usepackage{tabularx}
%Additional
\usepackage{wrapfig}
\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}
\usepackage{csquotes}
   \MakeAutoQuote{‘}{’}
   \MakeAutoQuote*{“}{”}
   \usepackage[tt=lining]{cfr-lm}
%Other optimizations
\geometry{scale=.9}
\setlength{\columnseprule}{0.4pt}
\urlstyle{sf}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\renewcommand*\headrulewidth{0pt}
%Necessary for table of contents
\usepackage[svgnames]{xcolor} % New for changing color of every paragraph randomly
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage{tocloft}
\renewcommand{\cftchapfont}{\color{red}\large\bfseries}
\renewcommand{\cftsecfont}{\color{blue}}
\renewcommand{\cftsubsecfont}{\color{black}}
\renewcommand{\cftsubsubsecfont}{\color{DarkGreen}}

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

\renewcommand{\cftchappagefont}{\color{red}%\large\bfseries
}
\usepackage[colorlinks=true,linkcolor=Indigo,linktocpage]{hyperref}
\usepackage[colorlinks=true]{hyperref}
\hypersetup{
    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
    filecolor=black,
    urlcolor=black,
    citecolor=black
}

\renewcommand{\thesection}{\arabic{section}}
\setcounter{secnumdepth}{2}

\newcommand{\divides}{\mid}
\newcommand{\notdivides}{\nmid}
\newcommand{\vectors}{\overrightarrow}
%\newcommand{\inf}{\infty}
%\newcommand{\infinity}{\infty}


%Theorems, lemmas, corollaries enviorements
\usepackage{amsthm}

\renewcommand\qedsymbol{\(\blacksquare\)} %QED empty square to blacksquare
\newtheorem*{theorem*}{Theorem}
\newtheorem{theorem}{Theorem}
\newtheorem*{corollary*}{Corollary}
\newtheorem{corollary}{Corollary}[theorem]
\newtheorem*{lemma*}{Lemma}
\newtheorem{lemma}[theorem]{Lemma}
%Randomly color everything begin

%\usepackage{everyhook}
%
%\newcommand{\randomcolor}{%
%  \definecolor{randomcolor}{RGB}
%   {
%    \pdfuniformdeviate 256,
%    \pdfuniformdeviate 256,
%    \pdfuniformdeviate 256
%   }%
%  \color{randomcolor}%
%}
%
%\PushPostHook{thesection}{\randomcolor}

%Randomly color everything end

%Randomly color section begin
%\newkomafont{secnum}{\color{LightSteelBlue}}
%\usepackage{etoolbox}
%\renewcommand*\do[1]{%
%  \newkomafont{#1number}{}%
%  \expandafter\renewcommand\csname#1format\endcsname{%
%    {\usekomafont{secnum}\usekomafont{#1number}\csname the#1\endcsname\autodot}\enskip%
%  }%
%}
%\docsvlist{section,subsection,subsubsection,paragraph,subparagraph}
%Randomly color section end

%Randomly color sections

%\renewcommand*{\sectionformat}{%
%  \textcolor{LightSteelBlue}{\thesection}\autodot\enskip%
%}
%\renewcommand*{\subsectionformat}{%
%  \textcolor{LightSteelBlue}{\thesubsection}\autodot\enskip%
%}
%Randomly Color sections end


%\partformat
%\chapterformat
%\sectionformat
%\subsectionformat
%\subsubsectionformat
%\paragraphformat
%\subparagraphformat
%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}
\renewcommand{\sectionmark}[1]{\markright{#1}}
\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
\renewcommand{\headrulewidth}{2pt}
%\renewcommand{\footrulewidth}{1pt}



%%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
%\renewcommand{\headrulewidth}{2pt}
%\renewcommand{\footrulewidth}{1pt}

\usepackage{amsthm}

\usepackage{booktabs}
\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}
\definecolor{lightgray}{gray}{0.9}

\pdfgentounicode=1
\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}}
\date{\today}
\begin{document}
\begin{titlepage}
\maketitle
\end{titlepage}


\expandafter\let\expandafter\oldproof\csname\string\proof\endcsname
\let\oldendproof\endproof
\renewenvironment{proof}[1][\proofname]{%
  \oldproof[\ttfamily \scshape \Large \color{red}{\textbf{Proof}}]%
}{\oldendproof}


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

%TESTING%
\section{Test}

\begin{gather}
    1 = potato \label{a}
\end{gather}

  
 Lets go \ref{a} test


\end{document} 

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

3
  • 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

1

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.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\section{Test one}

Text

\section{Test two}

\begin{gather*}
1=Potato \label{a}
\end{gather*}

\ref{a}

\end{document}

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.

0

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": [
            "luatex",
            "biber",
            "luatex",
            "luatex"
        ]
    },      
],
"latex-workshop.latex.tools": [{
    {,
        "name": "pdflatex",
        "command": "pdflatex",
        "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOC%"
        ]
    },
    {
        "name": "bibtex",
        "command": "bibtex",
        "args": [
            "%DOCFILE%"
        ]
    },
    {
        "name": "biber",
        "command": "biber",
        "args": [
            "%DOCFILE%"
        ]
    },
    {
        "name": "luatex",
        "command": "luatex",
        "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOC%"
        ]
    },
},
]

You must log in to answer this question.

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