0

I have a situation where the document title is set later, wrapped in another command (it has to do with language versions).

Hypersetup load order

I would like to put the new title into the hypersetup pdftitle command. The result is not desired. The file's metadata shows up in Adobe Reader as Baluga. It does not seem to matter whether I put the \hypersetup below my specialmacro or not.

Example

\documentclass{article}
\usepackage{fontspec}
\usepackage{hyperref}
\newcommand\baluga{Baluga}
\newcommand\whale{}
\hypersetup{%
    pdftitle={\baluga{} \whale{}},%
}%
\newcommand\specialmacro{
    \renewcommand\whale{whale}
}
\begin{document}
\specialmacro{}

Test

\end{document}

Update: Solution using Wrapper for \hypersetup

\documentclass{article}
\usepackage{fontspec}
\usepackage{hyperref}
\newcommand\baluga{Baluga}
\newcommand\whale{}
\newcommand\hyperset{
\hypersetup{%
    pdftitle={\baluga{} \whale{}},%
}%
}
\newcommand\specialmacro{
    \renewcommand\whale{whale}
    \hyperset
}
\begin{document}
\specialmacro{}

Test

\end{document}
2

Here is the new edited version:

\documentclass{article}
\usepackage{fontspec}
\usepackage{hyperref}
\newcommand\baluga{Baluga}
\newcommand\whale{}

\newcommand\hyperset{\hypersetup{pdftitle={\baluga{} \whale{}},}}

\begin{document}
 Test
\renewcommand\whale{whale}
\hyperset  
\end{document}
5
  • I am sorry, but that does not answer the question, "Is there a way to post-process setting the hyperref hypersetup values?" I appreciate the effort anyway. Apr 23 '15 at 10:44
  • perhaps \hypersetup command can be called just before the \end{document}. That would post-process the settings. Apr 23 '15 at 10:47
  • That is in interesting idea. I will try wrapping \hypersetupin a macro and calling it in the \specialmacro after the title is set. Apr 23 '15 at 10:48
  • It works. Here it is: \newcommand\hyperset{\hypersetup{pdftitle={\baluga{} \whale{}},}} and call it after the \renewcommand\whale{whale} in the \specialmacro. If you incorporate that into your answer I will give you credit for it. Apr 23 '15 at 10:52
  • 1
    You may also use \AtEndDocument{\hypersetup{...}} in the preamble so avoiding the need of typing it manually.
    – egreg
    Apr 23 '15 at 11:52

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.