我正在尝试使用fontawesome
包中的某些图标作为itemize
环境的项目符号。由于字符不同且宽度不同,因此对齐看起来混乱:
\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}
我怎样才能将这些符号居中对齐?
答案1
使用\clap
frommathtools
和wide
选项的变体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}
答案2
也许是这样的,它基于parleft
提供的对齐定义enumitem
。 Gonzalo Medina 的答案更好,但我已经写过了……
\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}
答案3
由于您正在使用enumitem
,因此您可以使用\SetLabelAlign
来定义中心对齐;我还增加了 的价值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}