我需要将链接部分的第一个字母改为大写。虽然我可以轻松地用 为标签执行此操作\makefirstuc
,但我无法让它在链接本身中工作。在下面的 MWE 中,标签正确地从 更改为,testname
但Testname
链接变为https://someaddresss/\makefirstuc {testname}.py
\documentclass{article}
\usepackage{mfirstuc}
\usepackage{hyperref}
\newcommand{\addlink}[1]
{
\href{https://someaddress/\makefirstuc{#1}.py}{\makefirstuc{#1}.py}
}
\begin{document}
\addlink{testname}
Label is changed as expected from \verb+testname+ to \verb+Testname+.
Link stays \verb+https://someaddresss/\makefirstuc {testname}.py+
\end{document}
MWE 输出为:
测试名称.py
标签按预期从 testname 更改为 Testname。
链接保持 https://someaddresss/\makefirstuc {testname}.py
我怀疑有一个简单的答案,但我找不到它...谢谢!
答案1
\documentclass[11pt]{book}
\usepackage{hyperref}
\ExplSyntaxOn
\cs_set_eq:NN\texttitlecasefirst\text_titlecase_first:n
\ExplSyntaxOff
\begin{document}
\href{https://someaddress/\texttitlecasefirst{blub}.py}{\texttitlecasefirst{blub}.py}
\end{document}