In the process to migrate from (x)keyval to pgfkeys, I realized that .estore in
was not expanding my command properly.
Here is my minimal working example:
\documentclass{report}
\usepackage{pgfkeys}
\makeatletter
\newif\if@wgetdoc@title@ownpage
\pgfkeys{
/wgetdoc/title/.cd,
maintitle/.estore in=\@wgetdoc@title@maintitle,
subtitle/.estore in=\@wgetdoc@title@subtitle,
author/.estore in=\@wgetdoc@title@author,
filename/.estore in=\@wgetdoc@title@filename,
ownpage/.is if=@wgetdoc@title@ownpage
}
\renewcommand{\title}[1][]{%
\pgfqkeys{/wgetdoc/title}{#1}
\@ifundefined{@wgetdoc@title@filename}{
\@ifundefined{@wgetdoc@title@maintitle}{
\ClassError{wgetdoc}{You did not specify a main title}{}
}{}
\@ifundefined{@wgetdoc@title@maintitle}{
\ClassError{wgetdoc}{You did not specify a main title}{}
}{}
\ifx\@wgetdoc@title@maintitle\@empty
\ClassError{wgetdoc}{The main title you specified is empty}{}
\fi
% Custom horizontale rule only local to this environment
\newcommand{\@wgetdoc@title@hrule}{\rule{\linewidth}{1mm}}
\if@wgetdoc@title@ownpage
\begin{titlepage}
\begin{center}
\@wgetdoc@title@hrule%
\vspace{0.4cm}
{\Huge\textbf{\@wgetdoc@title@maintitle}\par}%
\vspace{0.4cm}%
\@wgetdoc@title@hrule
\@ifundefined{@wgetdoc@title@subtitle}{}{
\vspace{1.5cm}
{\Large{\@wgetdoc@title@subtitle}\par}%
}
\@ifundefined{@wgetdoc@title@author}{}{
\vspace*{\fill}
{\emph{\GetTranslation{author}: \@wgetdoc@title@author}\par}%
}
\end{center}
\end{titlepage}%
\else
\begin{center}
{\huge\textbf{\@wgetdoc@title@maintitle}\par}
\@ifundefined{@wgetdoc@title@subtitle}{}{
{\large{\@wgetdoc@title@subtitle}\par}%
}
\end{center}
\@ifundefined{@wgetdoc@title@author}{}{
{\emph{\GetTranslation{author}: \@wgetdoc@title@author}\par}%
}
\@wgetdoc@title@hrule%
\fi
}{
\IfFileExists{\@wgetdoc@title@filename}{%
\includepdf[pages={1}]{\@wgetdoc@title@filename}%
\ClassInfo{wgetdoc}{\@wgetdoc@title@filename has been used as title page. Any other argument have been discarded.}{}
}{%
\ClassError{wgetdoc}{You specified \@wgetdoc@title@filename as filename for the page title, but it could not be found.}{}
}
}
}
\makeatother
\begin{document}
\title[maintitle=hello world, ownpage, subtitle=hello world]
Hello world
\end{document}
As soon I remove my formatting and type
\title[maintitle=hello world, ownpage, subtitle=hello world]
instead of
\title[maintitle=hello world, ownpage, subtitle=hello \textsc{world}]
This is working. Could anyone explain to me why estore in
is not working as expected (expanding the value before assigning it). This was working properly with xkeyval
.
The error I get when I try to compile (using xelatex
):
! Use of \\title doesn't match its definition.
\text@command #1->\def \reserved@a {
#1}\ifx \reserved@a \@empty \let \check@...
l.88 ...d, ownpage, subtitle=hello \textsc{world}]
?
\textsc
(and many other text formatting macros) is unexpandable. That's causing the problem.estore
breaks\\
; I see no need for it; why not simply.store
?\title[maintitle=my title, subtitle=\textsc{sub}, author=First \textsc{Last name} \href{mailto:[email protected]}{\nolinkurl{<[email protected]>}},ownpage=true]]
would not be expanded. But after deeper tests it appears they are. Some missing packages on my side.