
Eu tenho dois arquivos. Meu arquivo tex principal e um arquivo com várias definições (não um arquivo .sty, mas outro arquivo .tex).
Se eu tentar definir meus metadados PDF de minhas \@title
-macros com o \AtBeginDocument
-command (mas definido no arquivo externo), recebo alguns erros como:
Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding): (hyperref) removing `\spacefactor' on input line 14.
Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding): (hyperref) removing `\@m' on input line 14.
e meus metadados são apenas "título". No entanto, se eu colocar o código no meu arquivo principal, ele funcionará conforme o esperado. Um mwe seria o seguinte:
% main file
\documentclass{scrartcl}
\input{externalfile.tex}
\title{This is a test}
% WORKS
% \makeatletter
% \hypersetup{
% pdftitle={\@title}
% }
% \makeatother
\begin{document}
test
\end{document}
% external file
\usepackage{hyperref}
% DOESN'T WORK
\AtBeginDocument{
\makeatletter
\hypersetup{
pdftitle={\@title}
}
\makeatother
}
Todas as ideias são apreciadas. No entanto, eu gostaria de manter o arquivo externo como um arquivo .tex (e não mudar para um arquivo .sty. Se isso fizer alguma diferença)