Is it possible to create a variant of \overline where the line is a colored hyperlink?

In particular, I am writing a document using the knowledge package and I would like create an overline command with a knowledge link on it. Color is not very important in my case.

2 Answers 2


I think I found something more elegant, but I may not know enough TeX to realize what mistakes I am doing.

Here is a minimal (showcasing a few possible usecases) working example:

\documentclass{tufte-book} %For some reason, article does not work
\usepackage[xcolor,hyperref,notion,quotation]{knowledge} %Knowledge package for my use, but you can probably add color and hyperlinks to the rule in other ways

\hypersetup{pdfborder=1 1 1,urlbordercolor=red} %To highlight the link box

\knowledge{notion} %(knowledge package) Add a new notion to link
    |   closed

%%%%%%% Meat of the solution %%%%%%%%%

%I create variables for storing a box (some fixed piece of math), its height and its width

\newcommand{\closure}[1]{ %New command with 1 argument
    \savebox{\closebox}{$ #1 $} %Save the content of the argument inside the box
    \settoheight{\closeheight}{\usebox{\closebox}} %Retrieve the height of the box
    \settowidth{\closewidth}{\usebox{\closebox}} %Retrieve the width of the box
    \ooalign{ %Some environment that lets me put two things at the same position.
        \raisebox{\closeheight+0.1em} %Raise just above the box
                {\kl[closed]{\rule{\closewidth}{0.5pt}}% Draw a rule with a knowledge (or other) link
            }\cr%Reset position
        \usebox{\closebox}%Put the content of the box.
%Minimal example with exponents and zsubscripts to make sure it works.
This is a ""closed"" document.


\[\sum_{x \in \closure{(A\cup B)}} f_{\closure{x}}\]

\hypersetup{pdfborder=0 0 0,urlbordercolor=red} %Stop highlighting link box
Here is the same thing without link boxes.


\[\sum_{x \in \closure{(A\cup B)}} f_{\closure{x}}\]


And its output: Output of minimal working example.


you should try this: https://tex.stackexchange.com/a/656355/232319

If you want to subscript/power the overlined text, it is necessary to write it in \text command.


\usepackage{amsmath} % for text command


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .