1

So something weird is happening when I installed latex + textstudio on my new machine and tried to compile an old paper:

When I write something like In Sec. \ref{sec:Background}, for some reason the entire name of section, and the text "section." gets compiled, instead of just the number of the section.

This is what happens when it gets compiled: enter image description here

And this these are my codes:

\section{Introduction}
\label{sec:introduction}
\input{content/intro.tex}
\section{Background}
\label{sec:Background}
\input{content/background.tex}

And Using it as follows:

In Sec. \ref{sec:Background}

I am using the following documentclass:

\documentclass[twocolumn, switch]{article}

And the following general packages:

\RequirePackage[2020-02-02]{latexrelease}

%% General packages \usepackage[utf8]{inputenc} % allow utf-8 input \usepackage[T1]{fontenc} % use 8-bit T1 fonts \usepackage{xcolor} % colors for hyperlinks \usepackage[colorlinks = true, linkcolor = purple, urlcolor = blue, citecolor = cyan, anchorcolor = black]{hyperref} % Color links to references, figures, etc. \usepackage{booktabs} % professional-quality tables \usepackage{nicefrac} % compact symbols for 1/2, etc. \usepackage{microtype} % microtypography \usepackage{lineno} % Line numbers \usepackage{float} % Allows for figures within multicol %\usepackage{multicol} % Multiple columns (Method B) \usepackage{amsmath} \usepackage{bm}

I am using textstudio and tried using pdflatex and xelatex compilers, but no luck. Why is this happening? When I compiled this on my old computer, this didn't happen and only the number got compiled, like "Sec. 2".

This is happening for all my usages of \ref, for example references of tables, figures, etc.

Edit1:

I Just noticed this is happening because of this : \RequirePackage[2020-02-02]{latexrelease}, but if I remove it, another problem happens:

! Extra \endgroup error

So why is \RequirePackage[2020-02-02]{latexrelease} causing this problem and how can I fix it without removing this requirepackage?

  • Please post code itself, not screenshots of code. Do please share with us which document class you employ and which cross-referencing packages are loaded in the preamble of your document. In fact, please edit your posting to show the portions of the preamble code that are relevant for cross-referencing. For instance, do show the code section (if any) that changes the properties of the \ref macro. – Mico Dec 09 '22 at 06:43
  • Done, although I'm not sure which cross-referencing packages are loaded in the preamble of my document so I included all my packages, and I don't think there are any code section that changes the properties of '\ref', How can I search to check if there are such code sections? – OneAndOnly Dec 09 '22 at 06:54
  • @Mico Also note that I'm 100% sure its not a problem with the code itself, because this just compiled fine on my old computer, there has to be something with the configuration or something. – OneAndOnly Dec 09 '22 at 06:55
  • 1
    @Mico So I just noticed, if I remove \RequirePackage[2020-02-02]{latexrelease}, this problem gets fixed, but "Extra \endgroup error" happens, which the fix for that based on the following question is indeed this requirepackage... https://tex.stackexchange.com/questions/581907/extra-endgroup-error – OneAndOnly Dec 09 '22 at 07:06
  • @OneAndOnly I would try getting rid of all your loaded packages and then loading them one at a time to see which of these introduces incompatible TeX (if any). That would require you to create a proper MWE first though. – Raven Dec 09 '22 at 07:19
  • It looks like you've changed your posting quite a bit in the meantime. My main piece of advice: Don't load the latexrelease package unless you know exactly what you're doing. For instance, don't load the package with the option [2020-02-02]. My second piece of advice: Don't load the xwatermark package unless you know what you're doing. Number 3: the subfigure package is obsolete and deprecated -- for almost 20 years by now. Don't load this package. Instead, load either subfig or subcaption. – Mico Dec 09 '22 at 07:25
  • @Mico But if i remove latexrelease, two problems occur. One is this :https://tex.stackexchange.com/questions/581907/extra-endgroup-error and another one is this: https://tex.stackexchange.com/questions/666275/i-get-lines-on-the-4-edges-of-every-page-when-i-compile-a-template-how-do-i-rem , I can live with the first problem as paper does get compiled with it, but the second one causes so some weird 4 lines to appear in the edges of each page in my paper when I remove latexrelease!! – OneAndOnly Dec 09 '22 at 07:42
  • don't post disconnected fragments. it makes it hard for anyone to help. post a small self contained document that shows the problem. do not include any package not needed to show the problem in the example – David Carlisle Dec 09 '22 at 07:52

2 Answers2

5

\RequirePackage[2020-02-02]{latexrelease} allows you to roll LaTeX back to the state in 2020-02-02. But that doesn't mean that everything behave as it was in 2020 and also doesn't mean that all packages follow.

An example of something that is different are hooks: \AddToHook{begindocument} would error in a texlive 2019, but in rollback it is simply silently ignored.

For the reference commands that means, that their redefinition in nameref (and so also hyperref) which is done in such a hook fails.

You can reinstate the definitions like in the following, but be aware that this is only one example of such a failure. There are now an increasing number of packages using the new hooks, and all this packages can behave quite oddly in rollback. So it is much better to identify the package that is incompatible with a current LaTeX and to remove it from your document.

\RequirePackage[2020-02-02]{latexrelease}
\documentclass{article}
\usepackage{hyperref}

\makeatletter \DeclareRobustCommand\ref{% @ifstar@refstar\T@ref }% \DeclareRobustCommand\pageref{% @ifstar@pagerefstar\T@pageref }% \makeatother

\begin{document}

\section{Background} \label{sec:Background}

In Sec. \ref{sec:Background} \end{document}

Ulrike Fischer
  • 327,261
  • 1
    So how can I find which package is causing this problem when I use [2020-02-02]{latexrelease}? And when I find that package, how can I make it to work with "2020-02-02"? Maybe somehow force latex to use "2020-02-02" version of that package instead of the newest one? – OneAndOnly Dec 09 '22 at 12:10
1

Try :

\documentclass[twocolumn, switch]{article}
\usepackage[utf8]{inputenc} % allow utf-8 input
\usepackage[T1]{fontenc}    % use 8-bit T1 fonts
\usepackage{xcolor}     % colors for hyperlinks
\usepackage[colorlinks = true,
            linkcolor = purple,
            urlcolor  = blue,
            citecolor = cyan,
            anchorcolor = black]{hyperref}  % Color links to references, figures, etc.
\usepackage{booktabs}       % professional-quality tables
\usepackage{microtype}      % microtypography
\begin{document}
\section{Introduction}\label{sec:introduction}
In Section~\ref{sec:introduction}, everything is fine.
\end{document}

and see if you still have trouble. Here works like a charm:

enter image description here

Denis
  • 5,267
  • Correct, the problem is with \RequirePackage[2020-02-02]{latexrelease}, but is it the same for you? What happens when you add this requiredpackage? Is there anyway that I can keep this requirepackage? – OneAndOnly Dec 09 '22 at 08:04
  • 1
    @OneAndOnly if you roll back the latex format to 2020 you should obtain matching 2020 versions of all packages. There is absolutely no reason to expect any 2022 version of a package to work with such a format. – David Carlisle Dec 09 '22 at 09:15
  • I wanted to point out the source of the problem. With the addition of \RequirePackage[2020-02-02]{latexrelease} the problem is there. But as mentioned by David and Ulrike, this is not unexpected. – Denis Dec 09 '22 at 09:30