I would like to define a command that takes an input, passes through a list to generate another variable and then is fed to \href to give a link. As in the following example:

\documentclass[11pt, a4paper]{article}



{\csname Names@#1\endcsname\



Here is a page about \newhref{aaa}.


However the link I obtain is highlighted but doesn't link to anything. What is going wrong? Thank you!

  • 1
    show a complete example, that makes it much easier to test your code. – Ulrike Fischer Oct 28 '19 at 9:09
  • Ok, thanks. I included the \documentclass and end{document} commands. In the exemple above the word Einstein appears linked, but when clicking on it nothing happens. – Francesco Oct 28 '19 at 9:45

The problem is with the \ at the end of the line.

\newcommand{\links}[1]{\csname Names@#1\endcsname}

would solve the issue.

I'd use a friendlier way, though.

\documentclass[11pt, a4paper]{article}



% define the array
 {% #1 = array name, #2 = items
  \prop_new:c { g_francesco_array_#1_prop }
  \prop_gset_from_keyval:cn { g_francesco_array_#1_prop } { #2 }
% generic command for retrieving a value
 {% #1 = array name, #2 = array item
  \prop_item:cn { g_francesco_array_#1_prop } { #2 }





Here is a page about \newhref{aaa}.

| improve this answer | |
  • Thank you very much! It solved my problem! – Francesco Oct 28 '19 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.