0

I try to set dynamicaly pdf metadata with:

\def\date#1{\def\@date{#1}}
\def\author#1{\def\@author{#1}}
\def\title#1{\def\@title{#1}}
\def\subtitle#1{\def\@subtitle{#1}}
\def\location#1{\def\@location{#1}}
\def\thesisdirector#1{\def\@thesisdirector{#1}}
\def\thesiscodirector#1{\def\@thesiscodirector{#1}}
\def\discipline#1{\def\@discipline{#1}}
\def\doctoralschool#1{\def\@doctoralschool{#1}}
\def\doctoralschoolnumber#1{\def\@doctoralschoolnumber{#1}}
\def\nationalthesisnumber#1{\def\@nationalthesisnumber{#1}}

\makeatletter
\hypersetup{
    final       = true,
    colorlinks  = true,
    urlcolor    = blue,
    citecolor   = blue,
    linkcolor   = MidnightBlue,
    unicode     = true,
    linktoc     = section,
    pdfauthor   = {\@author},
    pdfkeywords = {biocomputing, biotechnology, software , scientific},
    pdftitle    = {\@title},
    pdfsubject  = {Genomic expert annotation}   
}
\makeatother

or this

\makeatletter
\def\date#1{\def\@date{#1}}

\def\author#1{\gdef\@author{#1}\gdef\@@author{#1}}
\let\@@author\@empty
\def\title#1{\gdef\@title{#1}\gdef\@@title{#1}}
\let\@@title\@empty

\def\subtitle#1{\def\@subtitle{#1}}
\def\location#1{\def\@location{#1}}
\def\thesisdirector#1{\def\@thesisdirector{#1}}
\def\thesiscodirector#1{\def\@thesiscodirector{#1}}
\def\discipline#1{\def\@discipline{#1}}
\def\doctoralschool#1{\def\@doctoralschool{#1}}
\def\doctoralschoolnumber#1{\def\@doctoralschoolnumber{#1}}
\def\nationalthesisnumber#1{\def\@nationalthesisnumber{#1}}


\hypersetup{
    final       = true,
    colorlinks  = true,
    urlcolor    = blue,
    citecolor   = blue,
    linkcolor   = MidnightBlue,
    unicode     = true,
    linktoc     = section,
    pdfauthor   = {\@@author},
    pdfkeywords = {biocomputing, biotechnology, software , scientific},
    pdftitle    = {\@@title},
    pdfsubject  = {Genomic expert annotation}   
}
\makeatother

This piece of code is put right after required package into my cls file.

But that do not build:

You can't use `\spacefactor' in internal vertical mode. \maketitle

I agree with you is a common error. I found lot of report (some ref: 1, 2)

But each time the answer do not have a MWE or do not works

Thanks for your light

  • 1
    As you are complaining about answers about MWE you seem to know their importance. So can you please add MWE to your question instead of code fragments? – user36296 Sep 30 '16 at 12:13
  • you have right, I should do it. I found my mistake. I put hypersetup command after required package declaration while title and author variable was defined before begin document. Moving the hypersetup declation after defnied variable fix my problem. Unfortunately I do not found how to do a lazy evaluation to let the hypersetup command into my cls file. Thanks @samcarter, I hope my answer is enough – – bioinfornatics Sep 30 '16 at 12:38
  • Good to hear, you could fix your problem. But please don't edit your question to include the answer, but provide an answer below. tex.stackexchange.com/help/self-answer – user36296 Sep 30 '16 at 12:43
1

SOLVED

Problem was hypersetup declaration was into my cls file after required package. At this position variable was defined but set to their final values. I move the hypersetup statement after that title and author variable are set. And that works.

in my cls file

\RequirePackage[xetex]{hyperref}
\def\date#1{\def\@date{#1}}
\let\@date\@empty

\def\author#1{\def\@author{#1}}
\let\@author\@empty

\def\title#1{\def\@title{#1}}
\let\@title\@empty

\def\keywords#1{\def\@keywords{#1}}
\let\@keywords\@empty

into main tex file:

\author{blah}
\title{blah}

\makeatletter
\hypersetup{%
    final       = true,
    colorlinks  = true,
    urlcolor    = blue,
    citecolor   = blue,
    linkcolor   = MidnightBlue,
    unicode     = true,
    linktoc     = section,
    pdflang     = fr-FR,
    pdfauthor   = {\@author},
    pdfkeywords = {\@keywords},
    pdftitle    = {\@title},
    pdfsubject  = {...}
}
\makeatother


\begin{document}
... 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.