我只需要获取命令打印的不带乳胶格式(并且不带换行符)的 ascii 文本。
我需要它自动生成pdf文档名称\hypersetup{pdftitle={<name of document>}}
在某些情况下,我可以将标题定义为\title{My \texttt{run.py} script}
但是,如果我尝试放置\hypersetup{pdftitle={\theauthor}}
(\theauthor
来自titling
包)。
这就是为什么我只需要从\theauthor
命令中提取文本。
答案1
也许这就是你正在寻找的:
\documentclass{article}
\usepackage{hyperref}
\newcommand\fauve{My \texorpdfstring{\textbf{name}}{name} is fauve}
\hypersetup{pdfauthor=\fauve}
\begin{document}
\verb+\fauve+: \fauve
\end{document}
答案2
最后,我找到了我的错误所在,我把 pdf 定义放在了\title
和\author
声明之前。
这是获得自动 pdf 适配的好方法(即使它包含 LaTeX 标签):
\title{My \textbf{Great} title\\ and subtitle}
\author{\textbsc{ME}}
\date{\today}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PDF specificity %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\hypersetup{
pdftitle={\@title},
pdfauthor={\@author}
}
\makeatother