Accepting special characters in arguments passing them further

by stefanct   Last Updated July 12, 2019 14:23 PM

I would like to define a macro very similar to \url, that accepts more or less arbitrary strings (including hashes/#) and passes them to other commands (i.e., \href, \url, \nolinkurl). I have tried to apply some other solutions (e.g., changing catcodes locally etc.), but failed. I would also like my new macro to be passable to other macros like \footnote.

The following non-working MWE shows an implementation, taking arbitrary strings as inputs, converts them to escaped tex-compatible strings (by use of \tl_to_str:n as an xparse command processor), and passes them along without errors. However, this completely breaks the meaning of the macros, which just output the escaped text (I don't really understand why).

Ideally, the macro would even detect hashes and escape them when passing the respective argument to \href, because that's required (but not for the original \url).











footnote: \footnote{\url{}{}}

Related Questions

Updated October 20, 2017 19:23 PM

Updated July 07, 2018 11:23 AM

Updated July 24, 2019 23:23 PM

Updated March 28, 2017 09:23 AM