I have a custom class file where I define some variables to be filled by users such as: \author, \title ...
And I would like to generate a .xmpdata file that grabs these information.
For these I have the following class file:
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{foo}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions\relax
\LoadClass[a4paper]{article}
\RequirePackage{luatextra}
\RequirePackage[pdftex]{pdflscape}
\RequirePackage[a-3u]{pdfx}
\RequirePackage[usenames,dvipsnames,svgnames]{xcolor}
\RequirePackage{etoolbox}
\begin{filecontents}{\jobname.xmpdata}
\Keywords{\@keywords}
\Title{\@title}
\Author{\@author}
\Org{\@org}
\end{filecontents}
\AtEndPreamble{%
\makeatletter
\hypersetup{
unicode = true,
final = true,
colorlinks = true,
urlcolor = blue,
citecolor = blue,
linkcolor = MidnightBlue,
unicode = true,
linktoc = section,
pdflang = fr-FR
}
\makeatother
}{}
\def\date#1{\def\@date{#1}}
\let\@date\@empty
\def\author#1{\def\@author{#1}}
\let\@author\@empty
\def\org#1{\def\@org{#1}}
\let\@org\@empty
\def\title#1{\def\@title{#1}}
\let\@title\@empty
\def\keywords#1{\def\@keywords{#1}}
\let\@keywords\@empty
And this main tex file to test it:
% !TeX encoding = utf8
% !TeX spellcheck = fr_FR
\documentclass{foo}
\author{foo}
\title{bar}
\keywords{baz}
\org{foz}
\begin{document}
it is a MWE
\end{document}
I used here lualatex as engine, and the .xmpdata file is created but the variables are not expanded:
cat bar.xmpdata
%% LaTeX2e file `bar.xmpdata'
%% generated by the `filecontents' environment
%% from source `bar' on 2017/02/23.
%%
\Keywords{\@keywords}
\Title{\@title}
\Author{\@author}
\Org{\@org}
Expected file:
\Title{bar}
\Author{foo}
\Keywords{baz}
\Publisher{foz}
Maybe by using \directlua there is a better way?
I do not understand the answer given in: https://tex.stackexchange.com/a/349521/24790
.xmpdatafile? – egreg Feb 23 '17 at 21:30