A while ago, I asked for a method to comfortably define several variables and the best answer came up with xparse and its key-value pairs. I now have two related issues, which I would like to discuss here.
Note: It's probably very useful to check the original post before going on, so you know my xparse setup.
Issue 1
I now tried to use the \lowercase{} function on these "variables".
\lowercase{\GetInvoiceData{FirstName}}
This results in the output Unknown, if I just call \GetInvoiceData{FirstName}, everything works just fine.
So my question is, how to print the value of an xparse key in lowercase.
Issue 2
I added the % as proposed by Christian Hupfer in the comments, which solves this issue.
Furthermore I wanted to print my whole name in lowercase letters and joined together (the first name in a thin font, the second name in a bold type) like so:
johndoe
My current code looks like this
\newcommand{\headertext}[2]
{%
\color{white}%
{%
\Huge{%
%\lowercase{%
\textlight{#1}\textbold{#2}%
%}%
}%
}%
}
% later in the code
\headertext{\GetInvoiceData{FirstName}}{\GetInvoiceData{SecondName}}
Note that \textlight{} and \textbold{} only define which font should be used:
\newcommand{\textlight}[1]
{%
% Normally defines another font
{#1}
}
% Same for \textbold{}
As you see, \lowercase{} is currently commented out because of the Unknown-issue, but the output of this is:
John Doe
So the font selection works well, but why is there a space between the two values? And how can I get rid of it?
MWE
\documentclass{article}
%% %%%%%%%%%%%%%%%%%%%%%%%
%% Variables Configuration
%% %%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{xparse}
\ExplSyntaxOn
\prop_new:N \g_invoice_prop
\cs_new:Nn \invoice_store_property:nn {
\prop_gput:Nnn \g_invoice_prop {#1} {#2}
}
%Defining key-value interface
\keys_define:nn {invoice} {
FirstName .code:n = {\invoice_store_property:nn {FirstName}{#1} },
LastName .code:n = {\invoice_store_property:nn {LastName}{#1} },
}
\NewDocumentCommand{\StoreInvoiceData}{+m}{
\prop_gclear:N \g_invoice_prop% Clearing the property list
% Set the keys
\keys_set:nn {invoice}{#1}
}
\NewDocumentCommand{\GetInvoiceData}{m}{
\prop_if_in:NnTF \g_invoice_prop {#1}
{% True
\prop_item:Nn \g_invoice_prop {#1}% Extract the key #1 from the property list
}{% False
Unknown
}
}
% Check if the field is given and execute #2 for true case, otherwise #3
\NewDocumentCommand{\IfInvoiceFieldGivenTF}{m+m+m}{%
\prop_if_in:NnTF \g_invoice_prop {
#1% Check to check
}{% True #2
#2
}{% False
#3
}
}% End of \IfInVoiceFieldGivenT
% Do something only if #1 is given
\NewDocumentCommand{\IfInvoiceFieldGivenT}{m+m}{%
\prop_if_in:NnT \g_invoice_prop {
#1% Check to check
}{% True #2
#2
}%
}% End of \IfInVoiceFieldGivenT
\ExplSyntaxOff
\StoreInvoiceData{
FirstName = {John},
LastName = {Doe},
}
%% %%%%%%%%%%%%%%%%%%
%% Font Configuration
%% %%%%%%%%%%%%%%%%%%
\newcommand{\textlight}[1]
{%
% Normally defines another font
{#1}%
}
\newcommand{\textbold}[1]
{%
% Normally defines another font
{\bfseries#1}%
}
\newcommand{\headertext}[2]
{%
\color{black}
{%
\Huge{%
\lowercase{%
\textlight{#1}\textbold{#2}
}
}
}
}
\begin{document}
\headertext{\GetInvoiceData{FirstName}}{\GetInvoiceData{LastName}}
\end{document}
Comment out \lowercase{} and you'll see, that the name is printed correctly. When using the function, it only prints Unknown.
\newcommand{\headertext}[2]{there should be a%character, as well as for\textlightdefinition. I am the author of the linked answer, but I can't make a test for your setup right now because I have no idea what\Ralewaylightdoes... – Aug 18 '17 at 20:36\RalewayLight. – Sam Aug 18 '17 at 20:47%. Thanks for that! – Sam Aug 18 '17 at 20:48\lowercase{\GetInvoiceData{FirstName}}is\GetInvoiceData{firstname}– David Carlisle Aug 18 '17 at 21:16\headertextdefinition is missing lots of%at ends of lines and will add 5 space tokens after the text – David Carlisle Aug 18 '17 at 21:19\Hugedoesn't take an argument.\colortakes only one. – cfr Aug 19 '17 at 02:26