2

I have defined a new class. Within this class, I am calling on the hyperref package, and I set the following options:

\RequirePackage{hyperref}
\hypersetup 
{
  pdfauthor={...},
  pdfsubject={...},
  pdftitle={...},
}

Now, I have defined certain variables within this class (which I can call with \variablename{}). However, if I use these within this package, as part of the option settings, then this fails (undefined control sequence). Am I not using the right syntax?

\RequirePackage{hyperref}
\hypersetup 
{
  pdfauthor={\variablename{}},
  pdfsubject={\variablename{}},
  pdftitle={\variablename{}},
}

I've read these questions (variable-name \newcommand with parameters within another \newcommand and Defining a newcommand, with variable name, inside another newcommand), but they are about newcommands... this is rather a regular package (hyperref) that I'm including, so I'm hoping it does not need to be this complicated)...

1
  • How have you defined \variablename? Can you post an MWE?
    – cgnieder
    Commented May 7, 2013 at 20:04

1 Answer 1

1

The following combination correctly sets the pdfauthor to "Andrew":

test.sty:

\newcommand{\myname}{Andrew}

\RequirePackage{hyperref}

\hypersetup{pdfauthor={\myname}}

main.tex:

\documentclass{article}

\usepackage{test}

\begin{document}
Text.
\end{document}

It is important not to call the \hypersetup command before the variable \myname has been set. However, it could be put in an \AtBeginDocument command to delay processing to the that point.

You must log in to answer this question.

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