I created a class in which I'd like to pass some parameters in \documentclass[parameters]{}
. The parameters I need to pass are pdftitle
and pdfsubject
to the hyperref
package. I succeeded in doing so, but if exist spaces in the title they simply vanish. So far I have written the following in my class:
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{klass}[2019/01/02]
\LoadClass[12pt,a4paper]{report}
\RequirePackage{xkeyval}
\def\pdftitle{} % define the token to be called in the options
% sets the token to be a recognizable command in the class options:
\define@key{klass.cls}{pdftitle}[]{\def\pdftitle{#1}}
\def\pdfsubject{}
\define@key{klass.cls}{pdfsubject}[]{\def\pdfsubject{#1}}
\ExecuteOptionsX{pdftitle,pdfsubject}
\ProcessOptionsX
\RequirePackage{hyperref}
\hypersetup{
pdftitle = \pdftitle,
pdfsubject = \pdfsubject
}
And here an usage example of the class:
\documentclass[
pdftitle = Do You See Spaces Here?,
pdfsubject = Where Are My Spaces?
]{klass}
\begin{document}
dummy text
\end{document}
You can see in the options that the pdftitle
and pdfsubject
got rid of the spaces:
Although I could simply write those options in the document, they need to be in the class file. So here's my question: how do I preserve the spaces in the string I pass as a parameter? I'm compiling it with LuaLaTeX
.