3

LaTeX:

\section{\faicon{cogs}\ Technical Skills}

Bookmark:

"F085 Technical Skills

How to remove the symbol code "F085?

4
  • 2
    Welcome to TeX.SX! With hyperref, \pdfstringdefDisableCommands{\def\faicon#1{}} should do... Commented Jul 31, 2019 at 12:55
  • @PhelypeOleinik Yes, this works! But why do you mention hyperref? I'm a newbie...
    – chaosink
    Commented Jul 31, 2019 at 13:02
  • I posted an answer with a better definition. I mentioned hyperref because it's the most common (if not the only) package for hyperlinking a LaTeX document. If you have pdf bookmarks you probably have hyperref loaded. Commented Jul 31, 2019 at 13:09
  • 1
    By the way, you don't need “backslash space”; \faicon{cogs} Technical Skills works as well.
    – egreg
    Commented Jul 31, 2019 at 13:32

1 Answer 1

6

hyperref provides the \pdfstringdefDisableCommands, which is a hook to execute commands before hyperref tries to translate TeX code into pdf strings. The argument of \pdfstringdefDisableCommands is arbitrary TeX code which should redefine commands which don't expand to valid pdf strings. You can redefine \faicon to consume an argument and do nothing:

\pdfstringdefDisableCommands{%
  \def\faicon#1{}%
}

However with that setup, the two sections:

\section{\faicon{cogs}\ Technical Skills}
\section{Technical Skills}

would produce the bookmarks (note the space):

 Technical Skills
Technical Skills

perhaps a better setting would be:

\pdfstringdefDisableCommands{%
  \def\faicon#1{\ignorespaces}%
}

so that spaces after \faicon{whatever} disappear.

Minimal example:

\documentclass{article}
\usepackage{fontawesome}
\usepackage{hyperref}

\pdfstringdefDisableCommands{\def\faicon#1{\ignorespaces}}

\begin{document}
\section{\faicon{cogs}\ Technical Skills}
\section{Technical Skills}
\end{document}
1
  • Note that this also works if you're using the shorthand for each icon, e.g., \faUsers
    – edallme
    Commented Jul 20, 2021 at 15:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .