footurl command
authorThomas Pietrzak <thomas.pietrzak@gmail.com>
Tue, 15 Feb 2022 10:47:17 +0000 (11:47 +0100)
committerThomas Pietrzak <thomas.pietrzak@gmail.com>
Tue, 15 Feb 2022 10:47:17 +0000 (11:47 +0100)
mystyle.sty

index b8c68d69dde5f66a81529653157b37fa66575746..ac342e4d8c1255a48a6951b82bc35528efa9c000 100644 (file)
 \newcommand{\centrevertical}[1]{\raisebox{-\height + \ht\@arstrutbox}{#1}}
 \makeatother
 
+\newcommand{\footurl}[1]{\footnote{\href{#1}{\replunderscores{#1}}}}
+
+\makeatletter
+% \expandafter for the case that the filename is given in a command
+\newcommand{\replunderscores}[1]{\expandafter\@repl@underscores#1_\relax}
+
+\def\@repl@underscores#1_#2\relax{%
+    \ifx \relax #2\relax
+        % #2 is empty => finish
+        #1%
+    \else
+        % #2 is not empty => underscore was contained, needs to be replaced
+        #1%
+        \textunderscore
+        % continue replacing
+        % #2 ends with an extra underscore so I don't need to add another one
+        \@repl@underscores#2\relax
+    \fi
+}
+\makeatother
 
 \renewenvironment{Abstract}{%
   %\vspace{5mm}