General\acro - Hyper reference undefined - but not everywhere

LaTeX specific issues not fitting into one of the other forums of this category.
TomWrite
Posts: 8
Joined: Sun Oct 17, 2021 7:49 pm

\acro - Hyper reference undefined - but not everywhere

Post by TomWrite »

Hello everyone,

I am facing a strange issue I am struggling with.

I am using \acro to define my acronyms. For about 90% it works. The list of acronyms is included and each acronym is a clickable link. However, for three (see below) this only throws an undefined error. Any idea what could be the problem?
I already deleted and rewrote the lines, I check spelling etc., nothing seems to solve it...

Anyone any idea?

Thanks
Tom

Code: Select all

\usepackage{hyperref} % Clickable links
\usepackage[printonlyused]{acronym} %Abbreviations

\hypersetup{final}

\begin{document}
\begin{acronym}
%those work
\acro{DSG}{Datenschutzgesetz}
\acro{VDSG}{Verordnung zum Bundesgesetz über den Datenschutz}

% those throw an error about hyperlink not defined
\acro{revDSG}{revisioniertes Datenschutzgesetz}
\acro{ISG}{Informationssicherheitsgesetz}
\acro{BÜPF}{Bundesgesetz betreffend die Überwachung des Post- und Fernmeldeverkehrs}
\end{acronym}

Rechtlich 
    \begin{itemize}[leftmargin=*]
        \item \ac{revDSG}
        \item \ac{ISG}
        \item \ac{DSG}
        \item \ac{VDSG}
        \item \ac{BÜPF}
    \end{itemize} 

\end{document}
Last edited by cgnieder on Fri Jan 14, 2022 8:14 pm, edited 1 time in total.
Reason: changed inline code markup to block

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

\acro - Hyper reference undefined - but not everywhere

Post by rais »

Well, after expanding your code to a Infominimal working example, I got only 1[1] warning:

Code: Select all

pdfTeX warning (dest): name{B\\unhbox\040\\voidb@x\040\\bgroup\040\\let\040\\
unhbox\040\\voidb@x\040\\setbox\040\\@tempboxa\040\\hbox\040{U\\global\040\\mat
hchardef\040\\accent@spacefactor\040\\spacefactor\040}\\let\040\\begingroup\040
\\let\040\\typeout\040\\protect\040\\begingroup\040\\def\040\\MessageBreak\040{
\012\(Font\)\040\040\040\040\040\040\040\040\040\040\040\040\040\040}\\let\040\
\protect\040\\immediate\\write\040\\m@ne\040{LaTeX\040Font\040Info:\040\040\040
\040\040on\040input\040line\04026.}\\endgroup\040\\endgroup\040\\relax\040\\let
\040\\ignorespaces\040\\relax\040\\accent\040127\040U\\egroup\040\\spacefactor\
040\\accent@spacefactor\040PF} has been referenced but does not exist, replaced
 by a fixed one
, not 3 errors.

acronym's \acro command creates some macros from its first argument. Though the package's way isn't as strict as, say, \newcommand, extended[2] characters---such as umlauts--- in the name for the macro(s) to be created present a problem.
For cases like this, \acro accepts an optional argument that can be used to put `not-usable-characters-within-a-macro' into the short form. Then the first argument doesn't need this troublesome character (or more of them), anymore:

Code: Select all

\documentclass{article}%<-- no class, no LaTeX
\usepackage{hyperref} % Clickable links
\usepackage[printonlyused]{acronym} %Abbreviations

%\hypersetup{final}%<-- isn't that default?

\begin{document}
\begin{acronym}
%those work
\acro{DSG}{Datenschutzgesetz}
\acro{VDSG}{Verordnung zum Bundesgesetz über den Datenschutz}

% those throw an error about hyperlink not defined
\acro{revDSG}{revisioniertes Datenschutzgesetz}
\acro{ISG}{Informationssicherheitsgesetz}
\acro{BUePF}[BÜPF]{Bundesgesetz betreffend die Überwachung des Post- und Fernmeldeverkehrs}%<--
\end{acronym}

Rechtlich
\begin{itemize}%[leftmargin=*]%<-- the standard itemize env has no such option
\item \ac{revDSG}
\item \ac{ISG}
\item \ac{DSG}
\item \ac{VDSG}
\item \ac{BUePF}
\end{itemize}

\end{document}
[1] ignoring over-/underfull stuff here
[2] for lack of a better word...think of it as ``character not to be used within a \csname...\endcsname'' construct

KR
Rainer
TomWrite
Posts: 8
Joined: Sun Oct 17, 2021 7:49 pm

\acro - Hyper reference undefined - but not everywhere

Post by TomWrite »

Thanks Rainer, sorry about the missing code parts. Still not used to latex and all the stuff needed.

Main thing for me is not really an error during compile. This works quite fine. It try to attach a screenshot that shows the problem.

The compiled list of acronyms exists of clickable links. However for the three acros I listed this doesnt work.
Yet for all of them the code is the same.

So it is less an error but rather a problem with the compiled pdf, giving me different results for the same acro\ code.
Attachments
Screenshot 2022-01-15 at 08.37.54.png
Screenshot 2022-01-15 at 08.37.54.png (63.08 KiB) Viewed 20656 times
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

\acro - Hyper reference undefined - but not everywhere

Post by cgnieder »

site moderator & package author
User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

\acro - Hyper reference undefined - but not everywhere

Post by Ijon Tichy »

rais has explained why this is and shown what to do. Have you tested his changes to your code?

BTW: You can avoid the problem using LuaLaTeX instead of PDFLaTeX, because LuaLaTeX is UTF8 native.

Code: Select all

%!TeX LuaLaTeX
\documentclass{article}% ADDED to make a MWE
\usepackage{enumitem}% ADDED to make a MWE
\usepackage{hyperref} % Clickable links
\usepackage[printonlyused]{acronym} %Abbreviations

\hypersetup{final}

\begin{document}
\begin{acronym}
%those work
\acro{DSG}{Datenschutzgesetz}
\acro{VDSG}{Verordnung zum Bundesgesetz über den Datenschutz}

% those throw an error about hyperlink not defined
\acro{revDSG}{revisioniertes Datenschutzgesetz}
\acro{ISG}{Informationssicherheitsgesetz}
\acro{BÜPF}{Bundesgesetz betreffend die Überwachung des Post- und Fernmeldeverkehrs}
\end{acronym}

Rechtlich 
    \begin{itemize}[leftmargin=*]
        \item \ac{revDSG}
        \item \ac{ISG}
        \item \ac{DSG}
        \item \ac{VDSG}
        \item \ac{BÜPF}
    \end{itemize} 

\end{document}
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
TomWrite
Posts: 8
Joined: Sun Oct 17, 2021 7:49 pm

\acro - Hyper reference undefined - but not everywhere

Post by TomWrite »

Thx Ijon, TBH I have no idea what exactly rais was talking about. I see the point with the german umlaut.

But, those two dont have an umlaut and they dont work either:
\acro{revDSG}{revisioniertes Datenschutzgesetz}
\acro{ISG}{Informationssicherheitsgesetz}


and even when I use \acro{BUePF}[BÜPF]{Bundesgesetz betreffend die Überwachung des Post- und Fernmeldeverkehrs}%<-- it doesnt work.

The hyperref link isnt created in the list of acronyms. However, something I might wrote not clear enough, the acronyms do work in the text. It is that the list of acronyms isnt build correctly.

What is it that I am missing?

Summary, 4 acronyms, none with an umlaut. 2 work and create a clickable hyperref link in the list of acronyms, 2 with exact same code dont. (see screenshot former post)
%those work
\acro{DSG}{Datenschutzgesetz}
\acro{VDSG}{Verordnung zum Bundesgesetz über den Datenschutz}
% those dont work.
\acro{revDSG}{revisioniertes Datenschutzgesetz}
\acro{ISG}{Informationssicherheitsgesetz}


PS: LuaLaTex doesnt change the behaviour
User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

\acro - Hyper reference undefined - but not everywhere

Post by Ijon Tichy »

In rais' code in in my code all these entries do work. You can test it, using the Run latex here button below the code.

So if these entries do not work in your document, there must be something, you've not yet told us. Please show us a Infominimal working example that really can be used to reproduce the problem. We cannot help, if you keep something relevant from us.

BTW: Please use the code button/tag for code blocks. The LaTeX button/tag is for inline code only. And please always try to show a complete minimal working example, not only a code snippet to illustrate your problem.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
TomWrite
Posts: 8
Joined: Sun Oct 17, 2021 7:49 pm

\acro - Hyper reference undefined - but not everywhere

Post by TomWrite »

Thank you for the hints. I will try to reproduce and check what might be the issue. I will keep the code / Latex remarks in mind.

PS: The code snippets above (even though that they are code snippets) are directly copied from my document.
Some lines work, some don't. And there is nothing in between the acronym definitions.
TomWrite
Posts: 8
Joined: Sun Oct 17, 2021 7:49 pm

\acro - Hyper reference undefined - but not everywhere

Post by TomWrite »

So it still doesn't work properly. Hyperref links in the list of acronyms are randomly broken. The hyerrefs in the text, when used like \ac{} are working.

Code: Select all

% this is part of the Springer Nature package I am using. But as I dont have the cls file here I disabled it
%\documentclass[sn-standardnature]{sn-jnl}% Standard Nature Portfolio Reference Style
\documentclass{article}

\usepackage{hyperref} % Clickable links
\usepackage[printonlyused]{acronym} %Abbreviations
\usepackage{graphicx}
\usepackage{array}
\usepackage{pdfpages}
\usepackage[ngerman]{babel}
\usepackage{tabularx}
\usepackage{enumitem}
\usepackage{multirow}
\usepackage{float}
\usepackage[default,oldstyle,scale=0.9]{opensans}
\usepackage{fancyhdr}

\hypersetup{final}

\raggedbottom

\begin{document}
    
\pagestyle{plain}
\title[Datenschutzmanagement für kritische Infrastruktur]{Erstellung eines Datenschuztmanagementsystem }

\maketitle

\newpage
\tableofcontents
\newpage

%%=======================%%
%% Abkürzungsverzeichnis %%
%%=======================%%
\section*{Abkürzungsverzeichnis}

\begin{acronym}

% Those are not compiled as hyperref links
% They remain normal text, without a hyperref. (as screenshot in the initial message)
\acro{ISG}[ISG]{Informationssicherheitsgesetz}
\acro{revDSG}{revisioniertes Datenschutzgesetz}
\acro{BÜPF}{Bundesgesetz betreffend die Überwachung des Post- und Fernmeldeverkehrs}
\acro{EDÖB}{Eidgenössischer Datenschutz- und Öffentlichkeitsbeauftragter}

% Those are totally fine
\acro{DSG}{Datenschutzgesetz}
\acro{VDSG}{Verordnung zum Bundesgesetz über den Datenschutz}
\acro{StromVV}{Stromversorgungsverordnung}
\acro{StromVG}{Stromversorgungsgesetz}

\end{acronym}

\listoffigures

\listoftables

\newpage

This is an example list. The list compiles fine, all of the acronyms are listed as hyperrefs and linked back to the list of acronyms from above. 
 \begin{itemize}[leftmargin=*]
        \item \ac{revDSG}
        \item \ac{ISG}
        \item \ac{BÜPF}
        \item \ac{StromVV}
        \item \ac{StromVG}
        \item \ac{DSG}, \ac{VDSG}
    \end{itemize}   

\end{document}
The error message I receive is:
sn-article.tex, line 135
Hyper reference `ISG' on page 5 undefined on input line 135.
You have referenced something which has not yet been labelled. If you have labelled it already, make sure that what is written inside \ref{...} is the same as what is written inside \label{...}.
PS: I know this stuff runs here. But the same exact code in my project creates the problem. Probably no solution to it.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10322
Joined: Mon Mar 10, 2008 9:44 pm

\acro - Hyper reference undefined - but not everywhere

Post by Stefan Kottwitz »

Hi Tom,

perhaps post your .log file here as attachment, of a LaTeX compiler run where the links are broken. We might notice something, possibly.

Stefan
LaTeX.org admin
Post Reply