当我尝试下面的标签时,它不起作用。
\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}