![根据给定的标题和作者自动生成元数据。这可能吗?](https://linux22.com/image/308540/%E6%A0%B9%E6%8D%AE%E7%BB%99%E5%AE%9A%E7%9A%84%E6%A0%87%E9%A2%98%E5%92%8C%E4%BD%9C%E8%80%85%E8%87%AA%E5%8A%A8%E7%94%9F%E6%88%90%E5%85%83%E6%95%B0%E6%8D%AE%E3%80%82%E8%BF%99%E5%8F%AF%E8%83%BD%E5%90%97%EF%BC%9F.png)
当我尝试下面的标签时,它不起作用。
\documentclass{article}
\usepackage{hyperref}
\makeatletter
\hypersetup{%
pdfauthor={\@author},
pdftitle={\@title},
}
\makeatother
\begin{document}
\title{This is my Sample}
\date{}
\maketitle
\author{John J. Tan}
\end{document}
答案1
你可以做这样的事情
\documentclass{article}
\usepackage{hyperref}
%% put these before \hypersetup
\title{This is my Sample}
\author{John J. Tan}
\date{}
\makeatletter
\let\mytitle\@title
\let\myauthor\@author
\makeatother
\hypersetup{%
pdfauthor={\myauthor},
pdftitle={\mytitle},
}
\begin{document}
\maketitle
\end{document}
或者甚至简单
\documentclass{article}
\usepackage{hyperref}
%% put these before \hypersetup
\title{This is my Sample}
\author{John J. Tan}
\date{}
\makeatletter
\hypersetup{%
pdfauthor={\@author},
pdftitle={\@title},
}
\makeatother
\begin{document}
\maketitle
\end{document}