2

I have the following code:

    \documentclass[a4paper,12pt,twoside,openright]{book}
    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
    \usepackage[italian,english]{babel}
    \usepackage[lighttt]{lmodern}
    \usepackage[a4paper,top=2.50cm,bottom=2.50cm,left=2.50cm,right=2.50cm]{geometry}
\usepackage{amsmath,amssymb,commath}
\usepackage{siunitx}
\usepackage{physics}
\usepackage[pdftex]{color}
\usepackage{xcolor}
\usepackage[sorting=none]{biblatex}
\usepackage[hyperfootnotes=false]{hyperref}

%hypersetup
\hypersetup{
        unicode=false,          % non-Latin characters in Acrobat’s bookmarks
        pdftoolbar=true,        % show Acrobat’s toolbar?
        pdfmenubar=true,        % show Acrobat’s menu?
        pdffitwindow=false,     % window fit to page when opened
        pdfstartview={FitH},    % fits the width of the page to the window
        pdftitle={Renormalization in quantum mechanics: two-dimensional delta-interaction as a case study},    % title
        pdfauthor={Me},     % author
        pdfsubject={Physics},   % subject of the document
        pdfcreator={Me},   % creator of the document
        pdfproducer={Me}, % producer of the document
        pdfkeywords={theorethical physics, quantum mechanics, renormalization, regularization, effective field theory}, % list of keywords
        pdfnewwindow=true,      % links in new PDF window
        colorlinks=true,       % false: boxed links; true: colored links
        linktoc=page,
        linkcolor=blue,         % color of internal link
        citecolor=green,        % color of links to bibliography
        filecolor=magenta,      % color of file links
        urlcolor=red            % color of external links
    }


\begin{document}

\tableofcontents

\section{Section 1} Here there's an equation \begin{equation}\label{eq1} \boldsymbol{F} = m\boldsymbol{a} \end{equation}

\section{Meaning of \eqref{eq1}} Bla bla...

\end{document}

What I'm trying to do is to remove the equation link only in the TOC. Someone can help me?

mcp
  • 91
  • 6
  • What about \section[Meaning of (1)]{Meaning of \eqref{eq1}} (if you don't use it for headers too)? – koleygr Jul 06 '20 at 15:33
  • It works unless i change the equation numeration, so i was searching for an authomtic solution – mcp Jul 06 '20 at 15:37
  • \makeatletter \section[Meaning of (\protect\ref*{eq1})]{Meaning of \eqref{eq1}} \makeatother – koleygr Jul 06 '20 at 16:33

2 Answers2

0

Here is an answer according to my comment and to an old answer of redefining the section command here

\documentclass[a4paper,12pt,twoside,openright]{book}
    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
    \usepackage[italian,english]{babel}
    \usepackage[lighttt]{lmodern}
    \usepackage[a4paper,top=2.50cm,bottom=2.50cm,left=2.50cm,right=2.50cm]{geometry}
\usepackage{amsmath,amssymb,commath}
\usepackage{siunitx}
\usepackage{physics}
\usepackage[pdftex]{color}
\usepackage{xcolor}
\usepackage[sorting=none]{biblatex}
\usepackage[hyperfootnotes=false]{hyperref}

%hypersetup
\hypersetup{
        unicode=false,          % non-Latin characters in Acrobat’s bookmarks
        pdftoolbar=true,        % show Acrobat’s toolbar?
        pdfmenubar=true,        % show Acrobat’s menu?
        pdffitwindow=false,     % window fit to page when opened
        pdfstartview={FitH},    % fits the width of the page to the window
        pdftitle={Renormalization in quantum mechanics: two-dimensional delta-interaction as a case study},    % title
        pdfauthor={Matteo Tagliazucchi},     % author
        pdfsubject={Physics},   % subject of the document
        pdfcreator={Matteo Tagliazucchi},   % creator of the document
        pdfproducer={Matteo Tagliazucchi}, % producer of the document
        pdfkeywords={theorethical physics, quantum mechanics, renormalization, regularization, effective field theory}, % list of keywords
        pdfnewwindow=true,      % links in new PDF window
        colorlinks=true,       % false: boxed links; true: colored links
        linktoc=page,
        linkcolor=blue,         % color of internal link
        citecolor=green,        % color of links to bibliography
        filecolor=magenta,      % color of file links
        urlcolor=red            % color of external links
    }


\let\oldsection\section \makeatletter \def\msection{% @ifstar{@Starred}{@nonStarred}% } \def@Starred{% @ifnextchar[% {\GenericWarning{}{Warning: A starred section can not have optional parameters. I am going to ignore them!}@StarredWith}% {@StarredWithout}% }
\def@StarredWith[#1]#2{% \oldsection{#2}% } \def@StarredWithout#1{ \oldsection{#1}% } \def@nonStarred{% @ifnextchar[% {@nonStarredWith}% {@nonStarredWithout}% } \def@nonStarredWith[#1]#2{% \newcommand\myeqref[1]{(\ref*{##1})} \oldsection[#1]{#2}% } \def@nonStarredWithout#1{% \oldsection{#1}% } \makeatother

\begin{document}

\tableofcontents

\section{Section 1} Here there's an equation \begin{equation}\label{eq1} \boldsymbol{F} = m\boldsymbol{a} \end{equation}

\msection[Meaning of \myeqref{eq1}]{Meaning of \eqref{eq1}}

Bla bla...

\end{document}

koleygr
  • 20,105
0

I suggest using the hook \pdfstringdefdisablecommands of the hyperref-package for cranking out the case of LaTeX being in the situation of producing a PDF string for a bookmark or the like which will be evaluated/processed by the pdf-viewing program at the time of displaying the .pdf-file. This way you can get rid of hyperref's "Token not allowed in PDF string..."-warnings.

Besides this the definition/status of the token \protect can be checked for guessing whether LaTeX is about to produce normal text or LaTeX is about to process tokens that form a moving argument which will be written to external-file, e.g., the .toc-file underlying the table of contents.

\documentclass[a4paper,12pt,twoside,openright]{book}
    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
    \usepackage[italian,english]{babel}
    \usepackage[lighttt]{lmodern}
    \usepackage[a4paper,top=2.50cm,bottom=2.50cm,left=2.50cm,right=2.50cm]{geometry}
\usepackage{amsmath,amssymb,commath}
\usepackage{siunitx}
\usepackage{physics}
\usepackage[pdftex]{color}
\usepackage{xcolor}
\usepackage[sorting=none]{biblatex}
\usepackage[hyperfootnotes=false]{hyperref}

%hypersetup
\hypersetup{
    unicode=false,          % non-Latin characters in Acrobat’s bookmarks
    pdftoolbar=true,        % show Acrobat’s toolbar?
    pdfmenubar=true,        % show Acrobat’s menu?
    pdffitwindow=false,     % window fit to page when opened
    pdfstartview={FitH},    % fits the width of the page to the window
    pdftitle={Renormalization in quantum mechanics: two-dimensional delta-interaction as a case study},    % title
    pdfauthor={Me},     % author
    pdfsubject={Physics},   % subject of the document
    pdfcreator={Me},   % creator of the document
    pdfproducer={Me}, % producer of the document
    pdfkeywords={theorethical physics, quantum mechanics, renormalization, regularization, effective field theory}, % list of keywords
    pdfnewwindow=true,      % links in new PDF window
    colorlinks=true,       % false: boxed links; true: colored links
    linktoc=page,
    linkcolor=blue,         % color of internal link
    citecolor=green,        % color of links to bibliography
    filecolor=magenta,      % color of file links
    urlcolor=red            % color of external links
}

\makeatletter @ifpackageloaded{hyperref}{% \newcommand\nolinkeqref[1]{% \textup{\tagform@{\ref{#1}}}% }% \pdfstringdefDisableCommands{% \def\nolinkeqref#1{(\ref{#1})}% \def\eqref#1{(\ref*{#1})}% }% }{% @ifdefinable\nolinkeqref{% \let\nolinkeqref=\eqref }% }% \makeatother

\begin{document}

\tableofcontents

\section{Section 1} Here there's an equation \begin{equation}\label{eq1} \boldsymbol{F} = m\boldsymbol{a} \end{equation}

\section{Meaning of \ifx\protect\relax\eqref{eq1}\else\nolinkeqref{eq1}\fi} Bla bla...

\end{document}

!!! Attention/Possible pitfalls when having referencing-commands within the arguments of sectioning commands: !!!

  1. In the question the desired behavior in case of using section-headings also for writing page-headers is not specified.

    Names of referencing labels require special attention in case the documentclass in use produces page headers in uppercase letters (via \MakeUppercase) or the like for section-headings which contain referencing-commands: When creating the page-header, the letters forming the names of referencing-labels might get uppercased too, at a time when the referencing-command in question is not carried out yet which might lead to an attempt of referencing EQ1 instead of eq1 either (in case EQ1 not being defined) yielding undefined reference or (in case EQ1 being defined also) yielding reference to the wrong referencing-label within page-headers of pages that belong to the section with the section-heading "Meaning of \eqref{eq1}".

    The textcase package might be of interest.

  2. The behavior of the \nameref-command needs to be checked for the situation of referring to a section via \mameref whose name itself contains a referencing-command.

  3. 1 and 2 need to be taken into account simultaneously in case a section-heading contains \nameref-reference to an other section-heading...

Ulrich Diez
  • 28,770