3

From an external file I get a list with keywords separated by ;. Since hyperref only works with keywords separated by , I need to replace the semicola.

Following MWE works for text but not for pdfkeywords from hyperref

% !TEX TS-program = lualatex
\documentclass[12pt]{scrartcl}
\usepackage{xstring}
\usepackage{hyperref}
\def\fmkeywords{Keyword1; Keyword2; Keyword3}
\hypersetup{                    
  unicode,                      
  pdftitle={My title},
  pdfencoding=auto,             
  pdfkeywords={\StrSubstitute{\fmkeywords}{;}{,}},   
}
\begin{document}
wrong: \fmkeywords

correct: \StrSubstitute{\fmkeywords}{;}{,}
\end{document}

In the PDF-info it won't display the keywords:

Keywords are not listed

But all is fine in the text:

Keywords in text work fine

2

Expand the substitution and store it in the same variable (\fmkeywords):

enter image description here

\documentclass{article}

\usepackage{xstring}
\usepackage{hyperref}

\def\fmkeywords{Keyword1; Keyword2; Keyword3}

\StrSubstitute{\fmkeywords}{;}{,}[\fmkeywords]
\hypersetup{
  unicode,
  pdftitle={My title},
  pdfencoding=auto,
  pdfkeywords={\fmkeywords}
}
\begin{document}

correct: \fmkeywords

correct: \StrSubstitute{\fmkeywords}{;}{,}

\end{document}
  • this does not work properly as far as I see: In the Dublin Core it is still considered as one keyword: dc:subject (bag container) -- [1]: Keyword1, Keyword2, Keyword3 – LukasCB Aug 1 '17 at 9:32
  • @LukasCB: Try this paste. It expands the keywords before calling \hypersetup. – Werner Aug 1 '17 at 10:11
  • Still as if one keyword. No separation internally. – LukasCB Aug 1 '17 at 10:18
  • 1
    @LukasCB: And how does that compare to pdfkeywords={one,two,three}? Three keywords? – Werner Aug 1 '17 at 10:19
  • Yes, then they listed in the dublin core as [1]: one [2]: two [3]: three --> three keywords. – LukasCB Aug 1 '17 at 10:20

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.