Page LayoutDisable Hyperlinks to Footnotes in custom Class

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
User avatar
psicofrenia
Posts: 2
Joined: Mon Apr 01, 2013 9:28 am

Disable Hyperlinks to Footnotes in custom Class

Post by psicofrenia »

Hey,

I'm new to LaTeX and and trying to add hyperlinks to my ToC using the hyperref package. I noticed that the footnotes became linked, what is normal then I tried to disable it using hyperfootnotes=false but it has no effect.

I created a class file to hold all my definitions. I'm not sure if this is happening because of that. Does anybody have an idea why hyperfootnotes is not working? Please check the class code below.

Code: Select all

% Class definition
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{manuscript}[2013/03/23 Creative writing manuscripts class]
%
%String comparation
\usepackage{etoolbox}
%
% Use conditionals
\usepackage{ifthen}
%
% Parent class: book
\LoadClass[a4paper,12pt,oneside]{book}

% Necessary packages
%
% Sets the document to be UTF8 and allows specials chars (accents) to be used
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
%
% Allows links inside document (only to toc)
\usepackage[linktocpage=true,hyperfootnotes=false]{hyperref}
%
% Change line size of TOC
\usepackage{tocloft}
\setlength\cftparskip{-2pt}
\setlength\cftbeforesecskip{1pt}
\setlength\cftaftertoctitleskip{2pt}
%
% Loads hyphenization and typographic rules for Portuguese
\usepackage[portuges]{babel}
%
% Better quality fonts for PS generation
\usepackage{ae,aecompl}
%
% Sets the document to use Latin Modern fonts
\usepackage{lmodern}
%
% Allows the document to use colors
\usepackage{color}

% Specific class settings
%
%Sets single line spacing
\usepackage[singlespacing]{setspace}
%\usepackage[onehalfspacing]{setspace}
%
% Disables paragraph identation
\setlength{\parindent}{0cm}
%
%
% Adds 0.5cm space after paragraph
\setlength{\parskip}{0.5cm}
%
% Sets the page to have only the page number
\pagestyle{plain}

% Generates a *dialogue* excert of text
%
% Parameters
% First: The aligment of the hyphen in lowercase (r, hyphen at the right side; b, hyphen at both sides; anything else left)
% The text to be changed into a dialog
\newcommand{\dialog}[2][l]{
	\ifthenelse{\equal{#1}{r}}{\textit{#2} -- }{
		\ifthenelse{\equal{#1}{b}}{ -- \textit{#2} -- }{ -- \textit{#2} }
}

% Generates a *thinking* excert of text
%
% Parameters
% First: The aligment of the hyphen in lowercase (r, hyphen at the right side; b, hyphen at both sides; anything else no hyphen)
% The text to be changed into a think
\newcommand{\think}[2][l]{
	\ifthenelse{\equal{#1}{r}}{``\textit{#2}'' -- }{
		\ifthenelse{\equal{#1}{b}}{ -- ``\textit{#2}'' -- }{``\textit{#2}'' }
}

% Formats a quotation
%
\newcommand{\quotes}[1]{``\textit{#1}''}
Btw, maybe I'm not doing it right using my custom code inside a class file but, like I said, I'm new to LaTeX and still experimenting. Any tips will be nice ;-)

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Disable Hyperlinks to Footnotes in custom Class

Post by cgnieder »

Hi psicofrenia,

Welcome to the LaTeX community!

As expected I don't get hyperlinks to footnotes if I copy the code you posted into a file named manuscript.cls and run the following example:

Code: Select all

\documentclass{manuscript}
\usepackage[hyperfootnotes=false]{hyperref}
\begin{document}
Text\footnote{text}
\end{document}
Maybe you can post a Infominimal working example that shows your issue?

BTW: I had to add missing closing braces to your definitions of \dialog and \think.

A tip: as they are your commands like \dialog may insert unwanted spaces with their current definition. As you probably know LaTeX treats end of lines as spaces. The following definition has three ends of lines:

Code: Select all

\newcommand{\dialog}[2][l]{
  \ifthenelse{\equal{#1}{r}}{\textit{#2} -- }{
    \ifthenelse{\equal{#1}{b}}{ -- \textit{#2} -- }{ -- \textit{#2} }
}}
Better would be to hide the ends of lines with %:

Code: Select all

\newcommand{\dialog}[2][l]{%
  \ifthenelse{\equal{#1}{r}}{\textit{#2} -- }{%
    \ifthenelse{\equal{#1}{b}}{ -- \textit{#2} -- }{ -- \textit{#2} }%
}}
Another tip: you don't need ifthen if you're already loading etoolbox for this definition:

Code: Select all

\newcommand{\dialog}[2][l]{%
  \ifstrequal{#1}{r}
    {\textit{#2} -- }
    {%
      \ifstrequal{#1}{b}
        { -- \textit{#2} -- }
        { -- \textit{#2} }%
}}
Regards
site moderator & package author
User avatar
psicofrenia
Posts: 2
Joined: Mon Apr 01, 2013 9:28 am

Re: Disable Hyperlinks to Footnotes in custom Class

Post by psicofrenia »

Thanks for you reply and your welcome, cgnieder.

I looked again and now the footnote problem is fixed.

I'm considering old build files somehow not updated since I used Latexilla and compile directly from its build button. One thing that I noticed is that sometimes warnings and errors abort the build but, since the result file is always shown if it's present, I end up with some old not updated version.

In fact, as you suggested, I fixed the closing braces and changed to ifstrequal, cleaned the temp build files and it's working really smooth.

And I have to thank you also because... Well, I know this is a noob commentary but I never realized why people used the % at the end of the lines. Now I know ;-)
Post Reply