5

I'm trying to use some icons from the fontawesome package as bullets for the itemize environment. As there are different characters and they are not the same width, the alignment looks mangled:

\begin{itemize}[leftmargin=0]
  \item[\faCode] Ruby, Python, Java, Javascript, Racket
  \item[\faGlobe] Sinatra, Rails, Django, Flask
  \item[\faHTMLfive] HTML5, CSS3, JQuery
  \item[\faCloud] Redis, CouchDB, PostgreSQL, MySQL
  \item[\faExchange] JSON, XML, OAuth
  \item[\faCodeFork] git, SVN
\end{itemize}

Example itemize

How can I align those symbols centred?

3 Answers 3

5

A variant using \clap from mathtools and the wideoption of enumitem:

\documentclass{article}

\usepackage[showframe]{geometry} \usepackage{fontawesome}
\usepackage{enumitem}
\usepackage{mathtools}
% page 3 of manual
\SetLabelAlign{center}{\clap{#1}}

\begin{document}

\begin{itemize}[wide, labelsep = 1em, align=center]
  \item[\faCode] Ruby, Python, Java, Javascript, Racket
  \item[\faGlobe] Sinatra, Rails, Django, Flask
  \item[\faHTMLfive] HTML5, CSS3, JQuery
  \item[\faCloud] Redis, CouchDB, PostgreSQL, MySQL
  \item[\faExchange] JSON, XML, OAuth
  \item[\faCodeFork] git, SVN
\end{itemize}

\end{document} 

enter image description here

5
  • \clap = \makebox[0pt]
    – Werner
    Mar 7, 2015 at 2:34
  • It's shorter to write :o)
    – Bernard
    Mar 7, 2015 at 2:35
  • @Werner Perhaps it will get used in a later answer?!
    – cfr
    Mar 7, 2015 at 2:47
  • @Werner: I do not add loading mathtools: it replaces loading amsmath. But you're not quite wrong: I do add two characters. However note I use clap more often than I load mathtools in a document…
    – Bernard
    Mar 8, 2015 at 12:03
  • 1
    Can this be made to work with Beamer? When I use \setlist[itemize,1]{wide,labelsep=1em,align=center} and \SetLabelAlign{center}{\clap{#1}} , default itemize bullets become invisible and alignment is also incorrect. EDIT: nevermind, already covered in tex.stackexchange.com/questions/280568/… .
    – eudoxos
    Apr 11, 2016 at 6:42
4

Perhaps something like this, which is based on the definition of the parleft alignment provided by enumitem. Gonzalo Medina's answer is better but I'd already written this....

\documentclass{article}

\usepackage{fontawesome}
\usepackage{enumitem}
% page 3 of manual
\SetLabelAlign{center}{\strut\smash{\parbox[t]\labelwidth{\centering#1}}}

\begin{document}

\begin{itemize}[leftmargin=0pt,align=center]
  \item[\faCode] Ruby, Python, Java, Javascript, Racket
  \item[\faGlobe] Sinatra, Rails, Django, Flask
  \item[\faHTMLfive] HTML5, CSS3, JQuery
  \item[\faCloud] Redis, CouchDB, PostgreSQL, MySQL
  \item[\faExchange] JSON, XML, OAuth
  \item[\faCodeFork] git, SVN
\end{itemize}

\end{document}

centred labels

3

Since you are using enumitem, you can use \SetLabelAlign to define a center alignment; I also increased the valur for leftmargin:

\documentclass{article}
\usepackage{enumitem}
\usepackage{fontawesome}

\SetLabelAlign{center}{\hss#1\hss}

\begin{document}

\begin{itemize}[leftmargin=30pt,align=center]
  \item[\faCode] Ruby, Python, Java, Javascript, Racket
  \item[\faGlobe] Sinatra, Rails, Django, Flask
  \item[\faHTMLfive] HTML5, CSS3, JQuery
  \item[\faCloud] Redis, CouchDB, PostgreSQL, MySQL
  \item[\faExchange] JSON, XML, OAuth
  \item[\faCodeFork] git, SVN
\end{itemize}

\end{document}

enter image description here

1
  • 1
    any idea how to do this in beamer? The enumitem package doesn't seem to work so easily there...
    – Knigge46
    Nov 29, 2015 at 10:45

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.