上划线的颜色和链接

上划线的颜色和链接

是否可以创建一个\overline线条为彩色超链接的变体?

具体来说,我正在使用知识包,我想创建一个带有知识链接的上划线命令。对我来说,颜色不是很重要。

答案1

我认为我找到了一些更优雅的东西,但我可能对 TeX 了解不够多,无法意识到自己犯了什么错误。

这是一个最小的(展示一些可能的用例)工作示例:

\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}

其输出如下: 最小工作示例的输出。

答案2

你应该尝试这个:https://tex.stackexchange.com/a/656355/232319

如果要为上划线的文本加下标/权重,则需要在\text命令中写明。

例如

\usepackage{amsmath} % for text command

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

相关内容