5

I have been trying to create a KaTeX logo for a paper that I'm writing, but it seems to break when I combine the following packages and try to put the logo in the title.

\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}

I get the following errors:

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}]

Thanks in advance!

7

The problem is that section titles are not only displayed in the pdf, but are also used for bookmarks etc. which don't accept special characters and complicate markup.

You can workaround the problem by using \texorpdfstring{<for pdf>}{<for bookmarks>} to giving an alternative text which will be used 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}
  • 1
    @TomášSláma \LaTeX works because hyperref redefines the macro if it is used in bookmarks etc to avoid this problem. – user36296 Feb 2 at 13:02
  • That makes sense. Thanks for the great explanation! – Tomáš Sláma Feb 2 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.