String parameter passed to a class vanish the spaces between words
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}
defpdftitle{} % 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}{defpdftitle{#1}}
defpdfsubject{}
define@key{klass.cls}{pdfsubject}{defpdfsubject{#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.
luatex documentclass-writing parameters class-options
|
show 6 more comments
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}
defpdftitle{} % 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}{defpdftitle{#1}}
defpdfsubject{}
define@key{klass.cls}{pdfsubject}{defpdfsubject{#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.
luatex documentclass-writing parameters class-options
Even though when I enclose the string with brackets I got no spaces.
– Levy
2 hours ago
2
That's expected, I'm afraid. The code for absorbing global options zaps all spaces.
– egreg
2 hours ago
1
Related/possibly interesting github.com/latex3/latex2e/issues/85.
– moewe
2 hours ago
@moewe I changed the name of class in the code (it was different), try to compile again to see if it works now.
– Levy
2 hours ago
Sure. LaTeX zaps them as egreg explained and you can't even protect spaces from zapping by enclosing them in a brace group.
– moewe
2 hours ago
|
show 6 more comments
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}
defpdftitle{} % 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}{defpdftitle{#1}}
defpdfsubject{}
define@key{klass.cls}{pdfsubject}{defpdfsubject{#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.
luatex documentclass-writing parameters class-options
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}
defpdftitle{} % 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}{defpdftitle{#1}}
defpdfsubject{}
define@key{klass.cls}{pdfsubject}{defpdfsubject{#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.
luatex documentclass-writing parameters class-options
luatex documentclass-writing parameters class-options
edited 2 hours ago
asked 2 hours ago
Levy
193112
193112
Even though when I enclose the string with brackets I got no spaces.
– Levy
2 hours ago
2
That's expected, I'm afraid. The code for absorbing global options zaps all spaces.
– egreg
2 hours ago
1
Related/possibly interesting github.com/latex3/latex2e/issues/85.
– moewe
2 hours ago
@moewe I changed the name of class in the code (it was different), try to compile again to see if it works now.
– Levy
2 hours ago
Sure. LaTeX zaps them as egreg explained and you can't even protect spaces from zapping by enclosing them in a brace group.
– moewe
2 hours ago
|
show 6 more comments
Even though when I enclose the string with brackets I got no spaces.
– Levy
2 hours ago
2
That's expected, I'm afraid. The code for absorbing global options zaps all spaces.
– egreg
2 hours ago
1
Related/possibly interesting github.com/latex3/latex2e/issues/85.
– moewe
2 hours ago
@moewe I changed the name of class in the code (it was different), try to compile again to see if it works now.
– Levy
2 hours ago
Sure. LaTeX zaps them as egreg explained and you can't even protect spaces from zapping by enclosing them in a brace group.
– moewe
2 hours ago
Even though when I enclose the string with brackets I got no spaces.
– Levy
2 hours ago
Even though when I enclose the string with brackets I got no spaces.
– Levy
2 hours ago
2
2
That's expected, I'm afraid. The code for absorbing global options zaps all spaces.
– egreg
2 hours ago
That's expected, I'm afraid. The code for absorbing global options zaps all spaces.
– egreg
2 hours ago
1
1
Related/possibly interesting github.com/latex3/latex2e/issues/85.
– moewe
2 hours ago
Related/possibly interesting github.com/latex3/latex2e/issues/85.
– moewe
2 hours ago
@moewe I changed the name of class in the code (it was different), try to compile again to see if it works now.
– Levy
2 hours ago
@moewe I changed the name of class in the code (it was different), try to compile again to see if it works now.
– Levy
2 hours ago
Sure. LaTeX zaps them as egreg explained and you can't even protect spaces from zapping by enclosing them in a brace group.
– moewe
2 hours ago
Sure. LaTeX zaps them as egreg explained and you can't even protect spaces from zapping by enclosing them in a brace group.
– moewe
2 hours ago
|
show 6 more comments
1 Answer
1
active
oldest
votes
You can make this work:
Title: Do You See Spaces Here?
Subject: Where Are My Spaces?
using input
documentclass[
pdftitle = {{Do You See Spaces Here?}} ,
pdfsubject = {{Where Are My Spaces?}}
]{klass}
begin{document}
dummy text
end{document}
The fact that you need braces to protect the spaces is an unfortunate feature of the core latex option handling, the fact that you need double braces and a space before the comma seems to be a feature of xkeyval's version of key=value parsing.
There are some plans to have an option not to drop spaces here but it is a tricky area, changing anything has the potential to break every latex document....
Thank you! It worked!
– Levy
51 mins ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f468660%2fstring-parameter-passed-to-a-class-vanish-the-spaces-between-words%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can make this work:
Title: Do You See Spaces Here?
Subject: Where Are My Spaces?
using input
documentclass[
pdftitle = {{Do You See Spaces Here?}} ,
pdfsubject = {{Where Are My Spaces?}}
]{klass}
begin{document}
dummy text
end{document}
The fact that you need braces to protect the spaces is an unfortunate feature of the core latex option handling, the fact that you need double braces and a space before the comma seems to be a feature of xkeyval's version of key=value parsing.
There are some plans to have an option not to drop spaces here but it is a tricky area, changing anything has the potential to break every latex document....
Thank you! It worked!
– Levy
51 mins ago
add a comment |
You can make this work:
Title: Do You See Spaces Here?
Subject: Where Are My Spaces?
using input
documentclass[
pdftitle = {{Do You See Spaces Here?}} ,
pdfsubject = {{Where Are My Spaces?}}
]{klass}
begin{document}
dummy text
end{document}
The fact that you need braces to protect the spaces is an unfortunate feature of the core latex option handling, the fact that you need double braces and a space before the comma seems to be a feature of xkeyval's version of key=value parsing.
There are some plans to have an option not to drop spaces here but it is a tricky area, changing anything has the potential to break every latex document....
Thank you! It worked!
– Levy
51 mins ago
add a comment |
You can make this work:
Title: Do You See Spaces Here?
Subject: Where Are My Spaces?
using input
documentclass[
pdftitle = {{Do You See Spaces Here?}} ,
pdfsubject = {{Where Are My Spaces?}}
]{klass}
begin{document}
dummy text
end{document}
The fact that you need braces to protect the spaces is an unfortunate feature of the core latex option handling, the fact that you need double braces and a space before the comma seems to be a feature of xkeyval's version of key=value parsing.
There are some plans to have an option not to drop spaces here but it is a tricky area, changing anything has the potential to break every latex document....
You can make this work:
Title: Do You See Spaces Here?
Subject: Where Are My Spaces?
using input
documentclass[
pdftitle = {{Do You See Spaces Here?}} ,
pdfsubject = {{Where Are My Spaces?}}
]{klass}
begin{document}
dummy text
end{document}
The fact that you need braces to protect the spaces is an unfortunate feature of the core latex option handling, the fact that you need double braces and a space before the comma seems to be a feature of xkeyval's version of key=value parsing.
There are some plans to have an option not to drop spaces here but it is a tricky area, changing anything has the potential to break every latex document....
answered 1 hour ago
David Carlisle
483k4011151856
483k4011151856
Thank you! It worked!
– Levy
51 mins ago
add a comment |
Thank you! It worked!
– Levy
51 mins ago
Thank you! It worked!
– Levy
51 mins ago
Thank you! It worked!
– Levy
51 mins ago
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f468660%2fstring-parameter-passed-to-a-class-vanish-the-spaces-between-words%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Even though when I enclose the string with brackets I got no spaces.
– Levy
2 hours ago
2
That's expected, I'm afraid. The code for absorbing global options zaps all spaces.
– egreg
2 hours ago
1
Related/possibly interesting github.com/latex3/latex2e/issues/85.
– moewe
2 hours ago
@moewe I changed the name of class in the code (it was different), try to compile again to see if it works now.
– Levy
2 hours ago
Sure. LaTeX zaps them as egreg explained and you can't even protect spaces from zapping by enclosing them in a brace group.
– moewe
2 hours ago