8

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?

lockstep
  • 250,273
Alex
  • 83
  • 1
  • 4

3 Answers3

6

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

Bernard
  • 271,350
  • \clap = \makebox[0pt] – Werner Mar 07 '15 at 02:34
  • It's shorter to write :o) – Bernard Mar 07 '15 at 02:35
  • @Werner Perhaps it will get used in a later answer?! – cfr Mar 07 '15 at 02: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 08 '15 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 http://tex.stackexchange.com/questions/280568/itemize-in-beamer-alignment-of-custom-bullets . – eudoxos Apr 11 '16 at 06:42
4

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

Gonzalo Medina
  • 505,128
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

cfr
  • 198,882