hyperref icon indicating copy to clipboard operation
hyperref copied to clipboard

smaller size of links in subscripts and superscripts with latex&dvips

Open ghost opened this issue 2 years ago • 0 comments

Feeding

\documentclass{article}
\usepackage{amssymb}
\usepackage[hidelinks]{hyperref}
\newcommand{\nonnegativeNat}{\href{http://en.wikipedia.org/wiki/Natural_number}{\mathbb{N}}}
\begin{document}
\[\nonnegativeNat^{\nonnegativeNat^{\nonnegativeNat}}\]
\end{document}

to latex followed by dvips yields normal-size superscripts and supersuperscripts in DVI and Postscripts: grafik grafik This is bad. Following https://tex.stackexchange.com/questions/399705/gls-in-the-subscript-has-too-normal-size#comment994726_399705 , we insert \text{$…$} for the first-order and second-order scripts on the latex-dvips route and leave the command as it is for all the other cases:

\documentclass{article}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[hidelinks]{hyperref}
\ifTUTeX%%% xelatex and lualatex produce PDF only
  \newcommand{\nonnegativeNat}{\href{http://en.wikipedia.org/wiki/Natural_number}{\mathbb{N}}}
\else
  \ifpdf%%% for pdflatex
    \newcommand{\nonnegativeNat}{\href{http://en.wikipedia.org/wiki/Natural_number}{\mathbb{N}}}
  \else%%% for latex
    \newcommand{\nonnegativeNat}{%
      \mathchoice%
      {\href{http://en.wikipedia.org/wiki/Natural_number}{\mathbb{N}}}%
      {\href{http://en.wikipedia.org/wiki/Natural_number}{\mathbb{N}}}%
      {\text{$\href{http://en.wikipedia.org/wiki/Natural_number}{\mathbb{N}}$}}%
      {\text{$\href{http://en.wikipedia.org/wiki/Natural_number}{\mathbb{N}}$}}%
    }
  \fi
\fi
\begin{document}
\[\nonnegativeNat^{\nonnegativeNat^{\nonnegativeNat}}\]
\end{document}

This luckily yields smaller sizes in superscripts and supersuperscripts in DVI and Postscript: grafik grafik Is there any problem with this solution (except the blue color and the underlining, as this would be a different issue)? If so, what is it? If there's no problem, is {\text{$\href{http://en.wikipedia.org/wiki/Natural_number}{\mathbb{N}}$}} somehow simplifiable (I believe it does more than we need to)? For example,

\documentclass{article}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[hidelinks]{hyperref}
\ifTUTeX%%% xelatex and lualatex produce PDF only
  \newcommand{\nonnegativeNat}{\href{http://en.wikipedia.org/wiki/Natural_number}{\mathbb{N}}}
\else
  \ifpdf%%% for pdflatex
    \newcommand{\nonnegativeNat}{\href{http://en.wikipedia.org/wiki/Natural_number}{\mathbb{N}}}
  \else%%% for latex
    \newcommand{\nonnegativeNat}{%
      \mathchoice%
      {\href{http://en.wikipedia.org/wiki/Natural_number}{\displaystyle\mathbb{N}}}%
      {\href{http://en.wikipedia.org/wiki/Natural_number}{\textstyle\mathbb{N}}}%
      {\href{http://en.wikipedia.org/wiki/Natural_number}{\scriptstyle\mathbb{N}}}%
      {\href{http://en.wikipedia.org/wiki/Natural_number}{\scriptscriptstyle\mathbb{N}}}%
    }
  \fi
\fi
\begin{document}
\[\nonnegativeNat^{\nonnegativeNat^{\nonnegativeNat}}\]
\end{document}

seems to produce the same (visually correct) sizes in the output.

Or does hyperref have a command doing the whole thing for us already? We really don't wish to reinvent the wheel.

ghost avatar Sep 06 '23 02:09 ghost