我正在尝试Segletes
适应修订的解决方案在下划线软件包列表 - 优点和缺点雇用alexwlchan
的在 LATEX 中为文本添加下划线的四种方法为了重新创造alexwlchan
'非常好的下划线' 宏还 行末换行。
我发现Segletes
宏的再现\xblackout
很好地创建了alexwlchan
版本的'非常好的下划线' 宏还在行末换行。很好。
我已经能够将Segletes
修改后的\xblackout
宏应用于几种不同的文本样式,但在将其应用于词汇表\gls
宏时遇到了麻烦,如\xblackout{\gls[hyper=true]{LED}}
。
我添加了一个 MWE,它基本上重复Segletes
了下划线软件包列表 - 优点和缺点添加了实现词汇表所需的代码。MWE 中的倒数第二行代码:\xblackout{\gls[hyper=true]{LED}}
是发生 LaTeX 错误的地方Missing \endcsname inserted.
。
注意:我基本上把所有Segletes
修订的解决方案在 MWE 中保持完整,以表明他的代码有效,除了为了我的词汇表的倒数第二行代码,其中唯一发生 LaTeX 错误。
任何帮助都将不胜感激。提前致谢。
% Adapted from Steven B. Segletes post on Aug 1, 2013 at 12:51:
% "List of Underlining Packages - Pros and Cons"
% at https://tex.stackexchange.com/questions/126291/list-of-underlining-packages-pros-and-cons
% Adapted from alexwlchan's "Four ways to underline text in LATEX"
% at https://alexwlchan.net/2017/10/latex-underlines/
\documentclass{article}
\usepackage[none]{hyphenat}
\usepackage{censor}
\usepackage{xcolor}
\usepackage{stackengine}
\usepackage{scalerel,lipsum}
% Added
\usepackage{ulem}
\usepackage{glossaries}
\makeglossaries
\censorruledepth=-.25ex
\censorruleheight=.1ex
\newlength\maxkern
\setlength{\maxkern}{.14ex}
\newlength\nextcharwidth
\makeatletter
\renewcommand\@cenword[1]{%
\setlength{\nextcharwidth}{\widthof{#1}}%
\censorrule{\nextcharwidth}%
\kern -\nextcharwidth%
\color{white}%
\kern -.5\maxkern #1\kern .5\maxkern%
\kern -\nextcharwidth%
\kern -\maxkern #1\kern \maxkern%
\kern -\nextcharwidth%
\kern .5\maxkern #1\kern -.5\maxkern%
\kern -\nextcharwidth%
\kern \maxkern #1\kern -\maxkern%
\kern -\nextcharwidth%
\color{black}%
#1}
\let\sv@cenword\@cenword
\newcommand\m@cenword[1]{\ThisStyle{%
\stackengine{\mcensorruledepth}{$\SavedStyle#1$}%
{\rule{\widthof{$\SavedStyle#1$}}{\the\censorruleheight}}{U}{c}{F}{T}{L}}}
\newcommand\mblackout[2][\dp\strutbox]{%
\let\@cenword\m@cenword%
\def\mcensorruledepth{#1}%
\blackout{#2}%
\let\@cenword\sv@cenword%
}
\newcommand\mcensor[2][\dp\strutbox]{%
\let\@cenword\m@cenword%
\def\mcensorruledepth{#1}%
\censor{#2}%
\let\@cenword\sv@cenword%
}
\makeatother
% Added
\newglossaryentry{LED}
{
name={LED},
description={light emitting diode},
first={\glsentrydesc{LED} (\glsentrytext{LED})},
plural={LEDs},
descriptionplural={light emitting diodes},
firstplural={\glsentrydescplural{LED} (\glsentryplural{LED})}
}
\begin{document}
\blackout{This is a great test today}
{\raggedright\xblackout{This is a great test today}}
% Modified
\[ \mblackout{y = A x^2} + Bx + \mblackout{C} \]
% \[ \mblackout{y = A x^{2}} + Bx + \mblackout{C} \]
% Modified
\[ \mblackout[.3ex]{y = \frac{a^3 + b^2 + c}{d_3}}\]
% \[ \mblackout[.3ex]{y = \frac{a^{3} + b^{2} + c}{d_{3}}}\]
\[ \mcensor[3ex]{y = \frac{a^{3} + b^{2} + c}{d_{3}}}\]
\xblackout{Quisque ullamcorper placerat ipsum. Cras nibh. Morbi vel
justo vitae lacus tincidunt ultrices. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In hac habitasse platea dictumst.
Integer tempus convallis augue. Etiam facilisis. Nunc elementum
fermentum wisi. Aenean placerat. Ut imperdiet, enim sed gravida sollicitudin, felis odio placerat quam, ac pulvinar elit purus
eget enim. Nunc vitae tortor. Proin tempus nibh sit amet nisl.
Vivamus quis tortor vitae risus porta vehicula.} \par \vspace{1cm}
% Added
\uline{\gls[hyper=true]{LED}} \par \vspace{1cm}
\uline{\gls[hyper=true]{LED}} \par \vspace{1cm}
% Error: Missing \endcsname inserted.
\xblackout{\gls[hyper=true]{LED}}
\end{document}