String parameter passed to a class vanish the spaces between words












2















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:



No spaces in the title and subject



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.










share|improve this question

























  • Even though when I enclose the string with brackets I got no spaces.

    – Levy
    Jan 4 at 23:07






  • 3





    That's expected, I'm afraid. The code for absorbing global options zaps all spaces.

    – egreg
    Jan 4 at 23:10






  • 2





    Related/possibly interesting github.com/latex3/latex2e/issues/85.

    – moewe
    Jan 4 at 23:11













  • @moewe I changed the name of class in the code (it was different), try to compile again to see if it works now.

    – Levy
    Jan 4 at 23:21











  • Sure. LaTeX zaps them as egreg explained and you can't even protect spaces from zapping by enclosing them in a brace group.

    – moewe
    Jan 4 at 23:23
















2















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:



No spaces in the title and subject



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.










share|improve this question

























  • Even though when I enclose the string with brackets I got no spaces.

    – Levy
    Jan 4 at 23:07






  • 3





    That's expected, I'm afraid. The code for absorbing global options zaps all spaces.

    – egreg
    Jan 4 at 23:10






  • 2





    Related/possibly interesting github.com/latex3/latex2e/issues/85.

    – moewe
    Jan 4 at 23:11













  • @moewe I changed the name of class in the code (it was different), try to compile again to see if it works now.

    – Levy
    Jan 4 at 23:21











  • Sure. LaTeX zaps them as egreg explained and you can't even protect spaces from zapping by enclosing them in a brace group.

    – moewe
    Jan 4 at 23:23














2












2








2








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:



No spaces in the title and subject



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.










share|improve this question
















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:



No spaces in the title and subject



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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 4 at 23:19







Levy

















asked Jan 4 at 23:02









LevyLevy

193112




193112













  • Even though when I enclose the string with brackets I got no spaces.

    – Levy
    Jan 4 at 23:07






  • 3





    That's expected, I'm afraid. The code for absorbing global options zaps all spaces.

    – egreg
    Jan 4 at 23:10






  • 2





    Related/possibly interesting github.com/latex3/latex2e/issues/85.

    – moewe
    Jan 4 at 23:11













  • @moewe I changed the name of class in the code (it was different), try to compile again to see if it works now.

    – Levy
    Jan 4 at 23:21











  • Sure. LaTeX zaps them as egreg explained and you can't even protect spaces from zapping by enclosing them in a brace group.

    – moewe
    Jan 4 at 23:23



















  • Even though when I enclose the string with brackets I got no spaces.

    – Levy
    Jan 4 at 23:07






  • 3





    That's expected, I'm afraid. The code for absorbing global options zaps all spaces.

    – egreg
    Jan 4 at 23:10






  • 2





    Related/possibly interesting github.com/latex3/latex2e/issues/85.

    – moewe
    Jan 4 at 23:11













  • @moewe I changed the name of class in the code (it was different), try to compile again to see if it works now.

    – Levy
    Jan 4 at 23:21











  • Sure. LaTeX zaps them as egreg explained and you can't even protect spaces from zapping by enclosing them in a brace group.

    – moewe
    Jan 4 at 23:23

















Even though when I enclose the string with brackets I got no spaces.

– Levy
Jan 4 at 23:07





Even though when I enclose the string with brackets I got no spaces.

– Levy
Jan 4 at 23:07




3




3





That's expected, I'm afraid. The code for absorbing global options zaps all spaces.

– egreg
Jan 4 at 23:10





That's expected, I'm afraid. The code for absorbing global options zaps all spaces.

– egreg
Jan 4 at 23:10




2




2





Related/possibly interesting github.com/latex3/latex2e/issues/85.

– moewe
Jan 4 at 23:11







Related/possibly interesting github.com/latex3/latex2e/issues/85.

– moewe
Jan 4 at 23:11















@moewe I changed the name of class in the code (it was different), try to compile again to see if it works now.

– Levy
Jan 4 at 23:21





@moewe I changed the name of class in the code (it was different), try to compile again to see if it works now.

– Levy
Jan 4 at 23:21













Sure. LaTeX zaps them as egreg explained and you can't even protect spaces from zapping by enclosing them in a brace group.

– moewe
Jan 4 at 23:23





Sure. LaTeX zaps them as egreg explained and you can't even protect spaces from zapping by enclosing them in a brace group.

– moewe
Jan 4 at 23:23










1 Answer
1






active

oldest

votes


















4














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....






share|improve this answer
























  • Thank you! It worked!

    – Levy
    Jan 5 at 0:40











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
});


}
});














draft saved

draft discarded


















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









4














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....






share|improve this answer
























  • Thank you! It worked!

    – Levy
    Jan 5 at 0:40
















4














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....






share|improve this answer
























  • Thank you! It worked!

    – Levy
    Jan 5 at 0:40














4












4








4







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....






share|improve this answer













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....







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 5 at 0:26









David CarlisleDavid Carlisle

485k4111181860




485k4111181860













  • Thank you! It worked!

    – Levy
    Jan 5 at 0:40



















  • Thank you! It worked!

    – Levy
    Jan 5 at 0:40

















Thank you! It worked!

– Levy
Jan 5 at 0:40





Thank you! It worked!

– Levy
Jan 5 at 0:40


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents