0

I have a macro that is like this:

\newcommand{\note}[1]{
    \thenoteid
    \dosomething{#1}
}

That macro is being used in scenarios like this:

Aenean eu leo quam. \note{Pellue ornare \somelatex semcinia quam} venenatis vestibulum.

Now I'd like to adjust the \note macro to be something like this:

\newcommand{\note}[1]{
    \href{\thenoteid}{\printasstring{#1}}
    \dosomething{#1}
}

Where the output would do it's normal thing at \dosomething{#1} but would wrap \thenoteid in a link that would have the raw latex like this: Pellue ornare \somelatex semcinia quam as the actual href.

Note

I'm aware that this would result in URLs that aren't correct, but I'm planning to view my PDF in a custom built viewer that will disable the normal function of links and parse the "url" for another purpose.

Things I've Tried

\begin{verbatim} but this resulted in errors, it seems like that doesn't work inside of an \href call. Maybe there's an "inline" version of this?

I did a bunch of google searching, and tried many code snippets that didn't really make sense to me, but seemed like they were answering similar requests. Like \typeout, \expandafter, probably others...

5
  • 2
    Maybe \href{\thenoteid}{\detokenize{#1}}?
    – Marijn
    Mar 15, 2023 at 20:38
  • 1
    @Marijn that is what I was looking for! THANKS!!
    – Circle B
    Mar 15, 2023 at 20:44
  • @Marijn Your comment, simple as it is, deserves to be posted as an answer. And the OP should accept it.
    – user287367
    Mar 15, 2023 at 22:52
  • 1
    @rallg this is surely a duplicate, instead of answering I'll see if I can find a good target question to close this one.
    – Marijn
    Mar 16, 2023 at 6:32
  • Also related: tex.stackexchange.com/questions/538299/…
    – Marijn
    Mar 16, 2023 at 8:34

0

Browse other questions tagged .