2

I have a problem with hyperref: it does not take into account the language when I use the macro \today in my pdftitle. In fact, I use this macro in other pdf fields too.

The date in the pdftitle remains in english.

I compile with pdflatex, xelatex and lualatex.

\documentclass[oneside,a4paper, 12pt]{article}


%%\usepackage[T1]{fontenc}
%%\usepackage[frenchb]{babel}


%%%% \usepackage{alternative4ht}
  \usepackage{fontspec}
  \setmainfont{TeX Gyre Termes}
  \usepackage{polyglossia}
  \setmainlanguage{czech}



\usepackage{hyperref}
\hypersetup{
pdfencoding=auto,
psdextra,
pdfdisplaydoctitle=true,
}

\hypersetup{
pdftitle={\today.},
}

\begin{document}
\today

\end{document}
2

\hypersetup{pdftitle=\today} is too early, since the language isn't set at that time.

However, \hypersetup can be used just before \begin{document} with \AtBeginDocument hook. Since there's no other hook defined, this is the last one being executed and at this time of compilation the language settings are done.

This gives the correct output of \today for pdftitle then.

\documentclass[oneside,a4paper, 12pt]{article}


%%\usepackage[T1]{fontenc}
%%\usepackage[frenchb]{babel}


%%%% \usepackage{alternative4ht}
  \usepackage{fontspec}
%  \setmainfont{TeX Gyre Termes}
  \usepackage{polyglossia}
  \setmainlanguage{czech}



\usepackage{hyperref}
\hypersetup{
  pdfencoding=auto,
  psdextra,
  pdfdisplaydoctitle=true,
}


\AtBeginDocument{%
  \hypersetup{pdftitle=\today}
} 


\begin{document}
\today
\hypersetup{pdftitle=\today}

\end{document}

enter image description here

| improve this answer | |

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.