2

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

1

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
\newsavebox{\closebox}
\newlength{\closeheight}
\newlength{\closewidth}

\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.
\begin{document}
This is a ""closed"" document.

$\closure{2^3+_{X_{d_e}}5}$

\[\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.

$\closure{2^3+_{X_{d_e}}5}$

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


\end{document}

And its output: Output of minimal working example.

0

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.

e.g.

\usepackage{amsmath} % for text command

\[
  L_{\text{\Overline{f}}}
\]

You must log in to answer this question.

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