1

I am not a Latex expert so while writing my documents, I face many problems with TeX command. And TeX StackExchange provides answers for most of my problems. However, one of my problems still does not have a consistent answer. I would like to share a solution after conducting many searches on Tex StackExchange.

Problem

When making presentation slides with Beamer, sometimes I need to use a custom icon for the item in itemize environment. It's just sometimes so I really don't need to define \setbeamertemplate{enumerate items}[] and \setbeamertemplate{itemize items}[] globally.

My preferred package for custom icon is fontawesome5 CTAN: Package fontawesome5.

Let's have an example to demonstrate the problem.

\begin{frame}{Alginment Test}
\begin{itemize}
    \item[{\faThumbsUp}] Good condition
    \item[{\faMeh[regular]}] Degraded condition
    \item[{\faTimes}] Failure condition
\end{itemize}
\end{frame}

(remember to add \usepackage{fontawesome5} to your preamble)

will produce:

enter image description here

As you can see, the icons are not vertically center alignment. In other document classes, we can fix this problem easily using enumitem package. A complete workaround for regular classes like article or report can be found here: itemize - alignment of custom bullet symbols. However, we are using the beamer class, loading enumitem will ruined the beamer's structure. You can find a partial answer without using enumitem here itemize in beamer - alignment of custom bullets . But the syntax is quite complex for me.

2 Answers 2

3

You can load the fontawesome5 package with the fixed option, then all icons are automatically centered in fixed width boxes.

So just replace

\usepackage{fontawesome5}

with

\usepackage[fixed]{fontawesome5}

and then you don't have to change anything in your {itemize}.

1

Solution

To solve this problem, you will need mathtools package CTAN: Package mathtools and its \clap command. Let's have some observations.

First, put the icon inside \clap{}:

\begin{frame}{Alginment Test}
\begin{itemize}
    \item[\clap{\faThumbsUp}] Good condition
    \item[\clap{\faMeh[regular]}] Degraded condition
    \item[\clap{\faTimes}] Failure condition
\end{itemize}
\end{frame}

It will produce:

enter image description here

The icons are in vertically centering. But the space between the icons and text is too small. So I try to add a white space after the \clap{} command like this:

\begin{frame}{Alginment Test}
\begin{itemize}
    \item[\clap{\faThumbsUp} ] Good condition %<----- extra white space after \clap{}
    \item[\clap{{\faMeh[regular]}} ] Degraded condition
    \item[\clap{\faTimes} ] Failure condition
\end{itemize}
\end{frame}

Then we have:

enter image description here

It's better, right?

However, I do not want to put extra space after \clap{} command, the code does not look beautiful. I conducted another search session on TeX StackExchange and I found this thread: beamer: how to increase space between bullet and text in itemize environment?. Now, I add the following line of code to the itemize environment and remove all white space after \clap{}:

\begin{frame}{Alginment Test}
\begin{itemize}
    \setlength\labelsep{10pt} %<---- new line
    \item[\clap{\faThumbsUp}] Good condition
    \item[\clap{{\faMeh[regular]}}] Degraded condition
    \item[\clap{\faTimes}] Failure condition
\end{itemize}
\end{frame}

The final result:

enter image description here

You can adjust the space 10pt to any number that fit your need. Also remember to put \setlength\labelsep{10pt} inside the itemize environment you wish to adjust the space (in case you have some nested lists). You can define new shorter commands for \clap{your fontawesome5 icon} if you want. Since I just sometimes use the custom bullet, the original macros are fine.

Thank you very much for reading and I hope this workaround will be helpful.

You must log in to answer this question.

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