1

I would like the norm-symbol \left\| \right\|_p to be linked to its definition, but I don't want its interior (x for example) to be linked. (And of course I want them to adjust their size automatically - that's why I use \left and \right)

Something like \hyperref[def:norm1]{\left\| {\suspendHyperref #1} \continueHyperref \right\|_1 } would be great! (firefox' build in pdf-reader hilights links on mouseover - so it would be awesome if the right side of the norm symbol \right_p also highlights, when I move the mouse over the left side of the norm symbol \left\| in firefox, but this is not my number 1 priority)

At least something like \hyperref[def:norm2]{\left\| } #1 \hyperref[def:norm2]{\right\|_2 } would be quite good, but this doesn't work because \left and \right form a group (like described in this post)

The following MWE produces a result that looks like I want it to look, but doesn't link correctly. Especially in eq. (1) the inner l_2-norm in the nested norms isn't linked correctly (because everything inside the outer l_1-norm is linked to the l_1-norm).

\documentclass[a4paper,11pt]{report}
\usepackage[colorlinks=true]{hyperref}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{definition}[theorem]{Definition}

\newcommand{\normOne}[1]{\hyperref[def:norm1]{\left\| {\normalcolor #1} \right\|_1 }}
\newcommand{\normTwo}[1]{\hyperref[def:norm2]{\left\| {\normalcolor #1} \right\|_2 }}

\begin{document}

\begin{definition}[$\ell_1-Norm$]\label{def:norm1}
\[ \normOne{x} := \sum_{i=1}^{n} \left| x_i \right|  \]
\end{definition}
\begin{definition}[$\ell_2-Norm$]\label{def:norm2}
\[ \normTwo{x} := \left( \sum_{i=1}^{n} \left| x_i \right|^2 \right)^{\frac{1}{2}} \]
\end{definition}

many pages later...

\begin{equation}
\normOne{ \left( \normTwo{y} - 3 \right) \hat{A}x}
\end{equation}

\end{document}

enter image description here

Maybe the idea of one of the answers to this question can be adopted to my problem, but unfortunately I don't understand all of these solutions well enough to know how to adopt them properly.

1

The essential part of my solution:

\newcommand{\BracKern}{\kern-\nulldelimiterspace}%https://tex.stackexchange.com/a/54035/128042

\newcommand{\linkedBrac}[5][]{% #2,#4 = left/right bracket type; #5 = label of link-target; optional argument #1: one can insert something like \color{green} here 
        \mathopen{\hyperref[#5]{#1\left#2\vphantom{#3}\BracKern\right.}}% left bracket
        #3%  content
        \mathclose{\hyperref[#5]{#1\left.\BracKern\vphantom{#3}\right#4}}% right bracket
}

\newcommand{\normTwo}[1]{\linkedBrac{\|}{#1}{\|_2}{def:norm2}}
\newcommand{\floor}[1]{\linkedBrac[\color{green}]{\lfloor}{#1}{\rfloor}{eq:floor}}
\newcommand{\abs}[1]{\linkedBrac[\normalcolor]{|}{#1}{|}{def:absolutValue}}

A working example of my code:

\documentclass[a4paper,11pt]{report}
\usepackage{amsmath}
\usepackage[colorlinks=true,linkcolor=blue]{hyperref}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{definition}[theorem]{Definition}

\newcommand{\BracKern}{\kern-\nulldelimiterspace}%https://tex.stackexchange.com/a/54035/128042

\newcommand{\linkedBrac}[5][]{% #2,#4 = left/right bracket type; #5 = label of link-target; optional argument #1: one can insert something like \color{green} here 
        \mathopen{\hyperref[#5]{#1\left#2\vphantom{#3}\BracKern\right.}}% left bracket
        #3%  content
        \mathclose{\hyperref[#5]{#1\left.\BracKern\vphantom{#3}\right#4}}% right bracket
}%https://tex.stackexchange.com/questions/360507/hyperref-delimiters-brackets-norms-parenthesis-using-left-and-right-suspe

\newcommand{\normOne}[1]{\linkedBrac{\|}{#1}{\|_1}{def:norm1}}
\newcommand{\normTwo}[1]{\linkedBrac{\|}{#1}{\|_2}{def:norm2}}
\newcommand{\floor}[1]{\linkedBrac[\color{green}]{\lfloor}{#1}{\rfloor}{eq:floor}}
\newcommand{\ceil}[1]{\linkedBrac[\color{red}]{\lceil}{#1}{\rceil}{eq:ceil}}
\newcommand{\Sawtooth}[1]{\linkedBrac[\color{yellow}]{\{}{#1}{\}}{eq:Sawtooth}}
\newcommand{\abs}[1]{\linkedBrac[\normalcolor]{|}{#1}{|}{def:absolutValue}}

\begin{document}
\begin{definition}[absolut value]\label{def:absolutValue}
$ \abs{x}=\max (x,-x) $
\end{definition}
\begin{definition}[$\ell_1-Norm$]\label{def:norm1}
\[ \normOne{x} := \sum_{i=1}^{n} \abs{x_i} \]
\end{definition}
\begin{definition}[$\ell_2-Norm$]\label{def:norm2}
\[ \normTwo{x} := \left( \sum_{i=1}^{n} \abs{x_i}^2 \right)^{\frac{1}{2}} \]
\end{definition}
\begin{definition}[floor,ceil,Sawtooth function]
\begin{align}
\floor{x} := \max\lbrace z\in Z | z\leq x \rbrace \label{eq:floor}\\
\ceil{x} :=\min\left\lbrace z\in Z \middle| z\geq x \right\rbrace \label{eq:ceil}\\
\Sawtooth{x} := x - \floor{x} \label{eq:Sawtooth}
\end{align}
\end{definition}

many pages later...

\begin{align}
\normOne{ \floor{ \normTwo{y} - 3 } \hat{A}x}\\
\normOne{ \ceil{ \normTwo{y} - 3 } \hat{A}x}\\
\Sawtooth{\normOne{ \left( \normTwo{y} - 3 \right) \hat{A}x}}
\end{align}
\end{document}

This code producing following result: enter image description here here is a link to the pdf: http://docdro.id/HZMP7Uy This looks exactly the way I wanted it to look and all links link to the correct position :)

Thanks for this comment by Gustavo Mezzetti that led me in right direction. My solution is based on this post by Peter Grill and this post by egreg

I can think of only one thing that could be improved: When I open move the mouse over a bracket in firefox-build-in-pdf-reader only one bracket gets highlighted. I think it would be absolutely beautiful if moving the mouse over one bracket would result in highlighting both brackets, but I am not sure if this is possible. (If someone can solve this, I will unaccept my solution and accept the more capable solution of course.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.