我想设置hyperref
为使用我的自定义命令title
& author
。
\documentclass{article} % or report or book
\makeatletter
\newcommand*{\titlul}[1]{%
\newcommand*{\@titlul}{#1}
}
\newcommand*{\autor}[1]{%
\newcommand*{\@autor}{#1}
}
\newcommand{\dotitle}{%
\begingroup
\thispagestyle{empty}%
\centering
\vspace*{1cm}
\ifcsname @titlul\endcsname
{\Large\bfseries\sffamily \@titlul\par}\smallskip
\fi
\ifcsname @autor\endcsname
{\large\sffamily \@autor\par}\vspace{.1cm}
\fi
\vspace{1cm}
\endgroup
}
\makeatother
\usepackage{hyperref}
\makeatletter
\hypersetup{pdftitle={\@titlul},pdfauthor={\@autor}}
% error
% Undefined control sequence.
% <argument> \@titlul
% l.40 ...tup{pdftitle={\@titlul},pdfauthor={\@autor}}
% https://tex.stackexchange.com/questions/17218/make-hyperref-take-pdfinfo-from-title-and-author
\makeatother
\titlul{Title here}
\autor{Author here}
\date{\today}
% start document
\begin{document}
\dotitle
\end{document}
答案1
尝试这个设置。
(苏门答腊)
(Adobe Reader)
\documentclass{article} % or report or book
\makeatletter
\newcommand{\titlul}[1]{%
\newcommand{\@titlul}{\Large\bfseries\sffamily #1}
}
\newcommand{\autor}[1]{%
\newcommand{\@autor}{\large\sffamily #1}}
\newcommand{\dotitle}{%
\begingroup
\thispagestyle{empty}%
\centering
\vspace*{1cm}
\ifcsname @titlul\endcsname%
{ \@titlul\par}\smallskip%
\fi
\ifcsname @autor\endcsname%
{ \@autor\par}\vspace{.1cm}
\fi%
\vspace{1cm}
\endgroup
}
\makeatother
\titlul{Title here}
\autor{Author here}
\date{\today}
\usepackage{hyperref}
\hypersetup{
pdftitle={\titlul\ },
pdfauthor={\autor\ Copyright \textcopyright\ \number\year\ },
pdfsubject={Subject I, Subject II},
pdfkeywords={keyOne; keyTwo; keyThree},
pdfcreator={Simon Dispa},
} % Set up
% start document
\begin{document}
\dotitle
\end{document}