Debian Codegraph @

texmf-dist/source/latex/href-ul/href-ul.dtx

raw
1 % \iffalse meta-comment
2 % SPDX-FileCopyrightText: Copyright (c) 2021-2025 Yegor Bugayenko
3 % SPDX-License-Identifier: MIT
4 % \fi
5
6 % \CheckSum{0}
7 %
8 % \CharacterTable
9 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
10 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
11 % Digits \0\1\2\3\4\5\6\7\8\9
12 % Exclamation \! Double quote \" Hash (number) \#
13 % Dollar \$ Percent \% Ampersand \&
14 % Acute accent \' Left paren \( Right paren \)
15 % Asterisk \* Plus \+ Comma \,
16 % Minus \- Point \. Solidus \/
17 % Colon \: Semicolon \; Less than \<
18 % Equals \= Greater than \> Question mark \?
19 % Commercial at \@ Left bracket \[ Backslash \\
20 % Right bracket \] Circumflex \^ Underscore \_
21 % Grave accent \` Left brace \{ Vertical bar \|
22 % Right brace \} Tilde \~}
23
24 % \GetFileInfo{href-ul.dtx}
25 % \DoNotIndex{\endgroup,\begingroup,\let,\else,\fi,\newcommand,\newenvironment}
26
27 % \iffalse
28 %<*driver>
29 \ProvidesFile{href-ul.dtx}
30 %</driver>
31 %<package>\NeedsTeXFormat{LaTeX2e}
32 %<package>\ProvidesPackage{href-ul}
33 %<*package>
34 [2025/03/07 0.5.2 Underlined Hyperlinks]
35 %</package>
36 %<*driver>
37 \documentclass{ltxdoc}
38 \usepackage[tt=false, type1=true]{libertine}
39 \usepackage{microtype}
40 \AddToHook{env/verbatim/begin}{\microtypesetup{protrusion=false}}
41 \usepackage{href-ul}
42 \usepackage{xcolor}
43 \usepackage[dtx]{docshots}
44 \PageIndex
45 \EnableCrossrefs
46 \CodelineIndex
47 \RecordChanges
48 \begin{document}
49 \DocInput{href-ul.dtx}
50 \PrintChanges
51 \PrintIndex
52 \end{document}
53 %</driver>
54 % \fi
55
56 % \title{|href-ul|: \LaTeX{} Package \\ That Makes Underscored Links\thanks{The sources are in GitHub at \href{https://github.com/yegor256/href-ul}{yegor256/href-ul}}}
57 % \author{Yegor Bugayenko \\ \texttt{[email protected]}}
58 % \date{\filedate, \fileversion}
59 %
60 % \maketitle
61 %
62 % \section{Introduction}
63 %
64 % This package helps you make your hyperlinks underlined, using |\href| command:
65 %
66 % \begin{docshot}
67 % \documentclass{article}
68 % \pagestyle{empty}
69 % \usepackage{href-ul}
70 % \begin{document}
71 % Go to
72 % \href{https://google.com}{Google}!
73 % \end{document}
74 % \end{docshot}
75 %
76 % The package doesn't support line breaking inside the title of the link.
77
78 % Changing the color of the text also changes the color of the line:
79 % \begin{docshot}
80 % \documentclass{article}
81 % \pagestyle{empty}
82 % \usepackage{href-ul}
83 % \usepackage{xcolor}
84 % \begin{document}
85 % Go to {\color{red}
86 % \href{https://google.com}{Google}}!
87 % \end{document}
88 % \end{docshot}
89
90 % Changing the size of the text doesn't change the height of the line:
91 % \begin{docshot}
92 % \documentclass{article}
93 % \pagestyle{empty}
94 % \usepackage{href-ul}
95 % \begin{document}
96 % You can always find \\ anything in
97 % {\Large \href{https://google.com}{Google}},
98 % but \\ it's better to learn
99 % something \\ from a school too!
100 % \end{document}
101 % \end{docshot}
102
103 % With the help of the |plain| package option, it's possible to avoid underscores:
104 % \docshotOptions{firstline=3,lastline=7}
105 % \begin{docshot}
106 % \documentclass{article}
107 % \pagestyle{empty}
108 % \usepackage[plain]{href-ul}
109 % \begin{document}
110 % This link has no underscore: \\
111 % \href{https://google.com}{Google}.
112 % \end{document}
113 % \end{docshot}
114
115 % \StopEventually{}
116
117 % \section{Implementation}
118 % \changes{v0.2.0}{2021/06/11}{Initial version}
119 % \changes{v0.3.0}{2022/10/31}{We started using "docshots" package for better rendering of examples.}
120 % \changes{0.4.0}{2024/01/09}{Package options processing introduced with a single \texttt{plain} option.}
121 % \changes{0.5.0}{2025/03/02}{Enhanced URL breaking functionality to improve handling of long URLs.}
122 % \changes{0.5.1}{2025/03/02}{Added text breaking capabilities to the second argument of \texttt{\char`\\href} and shifted from \texttt{ulem} to \texttt{soul} package.}
123 % \changes{0.5.2}{2025/03/07}{Decided not to use \texttt{soul} package, because it's too fragile, and returned back to \texttt{ulem}.}
124
125 % First, we process package options:
126 % \begin{macrocode}
127 \RequirePackage{pgfopts}
128 \pgfkeys{
129 /href/.cd,
130 plain/.store in=\href@plain
131 }
132 \ProcessPgfPackageOptions{/href}
133 % \end{macrocode}
134
135 % Then, we include the |ulem| package in order to enable underscores:
136 % \begin{macrocode}
137 \makeatletter
138 \ifdefined\href@plain\else
139 \RequirePackage{ulem}
140 \fi
141 \makeatother
142 % \end{macrocode}
143
144 % Then, we include the |hyperref| package for PDF hyperlinks:
145 % \begin{macrocode}
146 \PassOptionsToPackage{hidelinks}{hyperref}
147 \PassOptionsToPackage{hyphens}{url}
148 \RequirePackage{hyperref}
149 \RequirePackage{url}
150 % \end{macrocode}
151
152 % Then, we re-define the default |\href| command:
153 % \begin{macrocode}
154 \makeatletter
155 \begingroup
156 \catcode`\$=6
157 \catcode`\#=12
158 \gdef\href@split$1#$2#$3\\$4{%
159 \hyper@@link{$1}{$2}{%
160 \ifdefined\href@plain$4\else\uline{$4}\fi%
161 }%
162 \endgroup%
163 }
164 \endgroup
165 \makeatother
166 % \end{macrocode}
167
168 % \Finale
169
170 %\clearpage
171 %
172 %\PrintChanges
173 %\clearpage
174 %\PrintIndex