0

I want to create a new environment that takes one of its inputs as a link which might contain a special character and I want it to be escaped without each person manually escaping each character. I couldn't use verbatim environment inside my parameters and neither google nor ChatGPT understood/helped with it.

Here is my environment in my cls:

\newenvironment{rProjects}[4]{ % 4 input arguments - project title, brief description, project link name, project link
 {\bf #1} {#2} % Bold project name then description
 \ifthenelse{\equal{#3}{}}{}{
  \hfill \href{#3}{#4}
 }\smallskip
}{}

and here is how I use it in my .tex

\begin{rProjects}{Project name}{description}{link with special characters}{link name}
\end{rProjects}
0

1 Answer 1

2

you can try the v-type:

\documentclass[]{article}

\usepackage{hyperref,ifthen}
\NewDocumentEnvironment{rProjects}{mmvm}{% 
 \textbf{#1} {#2} % Bold project name then description
  
 \ifthenelse{\equal{#3}{}}{}{
  \hfill \href{#3}{#4}
 }\smallskip
}{}

\begin{document}

\begin{rProjects}{Project name}{description}{https://abc.de&%blub xxx}{link name}
\end{rProjects}

\end{document}

But you should test the special chars you want to use. I'm not sure if all are passed correctly to hyperref.

2
  • Thank you, If I want the hyperlink to be v yet optional how to do so? Commented Aug 3, 2023 at 8:09
  • I don't think you can, see the documentation of xparse, but you could ask a new question about it (and then with a proper example and not only some snippets). Commented Aug 3, 2023 at 8:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .