我一直在尝试为我正在撰写的论文创建一个 KaTeX 徽标,但是当我组合以下包并尝试将徽标放在标题中时,它似乎崩溃了。
\documentclass[a4paper, 12pt]{article}
\usepackage{hyperref}
% define KaTeX logo
\makeatletter
\DeclareRobustCommand{\KaTeX}{%
K\kern -.19em
{\sbox \z@ T\vbox to\ht \z@ {\hbox{%
\check@mathfonts
\fontsize\sf@size\z@
\selectfont A}%
\vss}%
}\kern -.15em
\TeX}
\makeatother
\begin{document}
\section{\KaTeX}
\end{document}
我收到以下错误:
19: Argument of \select@group has an extra }. [ \section{\KaTeX}]
19: Paragraph ended before \select@group was complete. [ \section{\KaTeX}]
19: Argument of \select@group has an extra }. [ \section{\KaTeX}]
19: Paragraph ended before \select@group was complete. [ \section{\KaTeX}]
19: Argument of \select@group has an extra }. [ \section{\KaTeX}]
19: Paragraph ended before \select@group was complete. [ \section{\KaTeX}]
19: Argument of \select@group has an extra }. [ \section{\KaTeX}]
19: Paragraph ended before \select@group was complete. [ \section{\KaTeX}]
19: Paragraph ended before \HyPsd@@ProtectSpacesFi was complete. [ \section{\KaTeX}]
19: Missing { inserted. [ \section{\KaTeX}]
19: Extra }, or forgotten \endgroup. [ \section{\KaTeX}]
19: Extra }, or forgotten \endgroup. [ \section{\KaTeX}]
19: Infinite glue shrinkage found on current page. [ \section{\KaTeX}]
19: Extra }, or forgotten \endgroup. [ \section{\KaTeX}]
19: Use of \HyPsd@RemoveMask doesn't match its definition. [ \section{\KaTeX}]
19: Undefined control sequence. [ \section{\KaTeX}]
19: Paragraph ended before \HyPsd@RemoveBraces was complete. [ \section{\KaTeX}]
19: Extra }, or forgotten \endgroup. [ \section{\KaTeX}]
19: Argument of \HyPsd@CheckCatcodes has an extra }. [ \section{\KaTeX}]
19: Paragraph ended before \HyPsd@CheckCatcodes was complete. [ \section{\KaTeX}]
提前致谢!
答案1
问题是,章节标题不仅显示在 pdf 中,还用于书签等,这些书签不接受特殊字符并使标记复杂化。
\texorpdfstring{<for pdf>}{<for bookmarks>}
您可以通过提供用于书签的替代文本来解决该问题:
\documentclass[a4paper, 12pt]{article}
\usepackage{hyperref}
% define KaTeX logo
\makeatletter
\DeclareRobustCommand{\KaTeX}{%
K\kern -.19em
{\sbox \z@ T\vbox to\ht \z@ {\hbox{%
\check@mathfonts
\fontsize\sf@size\z@
\selectfont A}%
\vss}%
}\kern -.15em
\TeX}
\makeatother
\begin{document}
\section{\texorpdfstring{\KaTeX}{KaTeX}}
\end{document}