![这些宏/命令声明中第二行(相同)的用途是什么?](https://linux22.com/image/358441/%E8%BF%99%E4%BA%9B%E5%AE%8F%2F%E5%91%BD%E4%BB%A4%E5%A3%B0%E6%98%8E%E4%B8%AD%E7%AC%AC%E4%BA%8C%E8%A1%8C%EF%BC%88%E7%9B%B8%E5%90%8C%EF%BC%89%E7%9A%84%E7%94%A8%E9%80%94%E6%98%AF%E4%BB%80%E4%B9%88%EF%BC%9F.png)
[免责声明:虽然我已经使用 LaTeX 很长一段时间了,但我仍然有很多关于代码和定制的内容需要学习]
在撰写硕士论文的过程中,我了解到这个模板。它在文件中有关于大学/部门名称等的命令,*.cls
如下所示:
\department {\texorpdfstring{\href{Department or School Web Site URL Here (include http://)}
{Department or School Name}}
{Department or School Name}}
\DEPARTMENT {\texorpdfstring{\href{Department or School Web Site URL Here (include http://)}
{DEPARTMENT OR SCHOOL NAME (IN BLOCK CAPITALS)}}
{DEPARTMENT OR SCHOOL NAME (IN BLOCK CAPITALS)}}
\group {\texorpdfstring{\href{Research Group Web Site URL Here (include http://)}
{Research Group Name}}
{Research Group Name}}
\GROUP {\texorpdfstring{\href{Research Group Web Site URL Here (include http://)}
{RESEARCH GROUP NAME (IN BLOCK CAPITALS)}}
{RESEARCH GROUP NAME (IN BLOCK CAPITALS)}}
\faculty {\texorpdfstring{\href{Faculty Web Site URL Here (include http://)}
{Faculty Name}}
{Faculty Name}}
\FACULTY {\texorpdfstring{\href{Faculty Web Site URL Here (include http://)}
{FACULTY NAME (IN BLOCK CAPITALS)}}
{FACULTY NAME (IN BLOCK CAPITALS)}}
其声明如下:
\newcommand*{\department}[1]{\def\deptname{#1}}
\newcommand*{\DEPARTMENT}[1]{\def\DEPTNAME{#1}}
\newcommand*{\group}[1]{\def\groupname{#1}}
\newcommand*{\GROUP}[1]{\def\GROUPNAME{#1}}
\newcommand*{\faculty}[1]{\def\facname{#1}}
\newcommand*{\FACULTY}[1]{\def\FACNAME{#1}}
模板中第二行相同的文本有什么用处?似乎只需更改最上面的一行,它就可以正确显示。有人能告诉我吗?
答案1
让我们选择您的一个命令调用(刚刚拆分):
\DEPARTMENT {
\texorpdfstring{
\href{Department or School Web Site URL Here (include http://)}
{DEPARTMENT OR SCHOOL NAME (IN BLOCK CAPITALS)}
}
{DEPARTMENT OR SCHOOL NAME (IN BLOCK CAPITALS)}
}
这意味着您定义\DEPTNAME
在输出和书签中的行为有所不同。在输出中,您将发现一个超链接,它将像第一个参数一样以大写形式出现。
如果没有生成超链接(例如在书签中),您将获得第二个全大写字符串。我不清楚为什么您必须给出这些相同的定义,但这是一个设计决定。