8

I need to circle font awesome icons. Currently, this is how it looks. enter image description here

The code for this is:

\usepackage{fontawesome}
\begin{document}
\faDesktop shubhamrathi.in
\faEnvelope hello@shubhamrathi.in
\faPhone +91-9985556304
\faGithub srrathi
\faLinkedin /in/shubhamrrathi

\end{document}

I need icons to be enclosed in a circle like this:

enter image description here

How should this be done? I'm preferably looking for a solution without pstricks ( one which works with Sharelatex)

  • 1
    Must the circles all have the same size, or be adjusted to the glyph size? – Bernard Oct 1 '16 at 23:19
  • Same Size for all circles. – user3426358 Oct 1 '16 at 23:20
  • 1
    ICan you please expand the code snippet that you have posted to a full minimal working example. A MWE should compile and be as small as possible to demonstrate your problem. – Andrew Oct 1 '16 at 23:38
  • Updated the question with MWE. Thanks for curating the question. – user3426358 Oct 2 '16 at 0:33
7

Here is a solution based on pstricks. I define a \pscircled{#1} command:

\documentclass{article}
\usepackage[utf8]{inputenc} %
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{fontawesome}
\usepackage{pst-node, auto-pst-pdf}
\usepackage{hyperref}

\newcommand\pscircled[1]{%
\raisebox{-0.315\height}{\begin{postscript}
\Cnodeput[radius=2.3ex](0,0){P}{#1}
\end{postscript}}}

\begin{document}

\noindent       
\pscircled{\faDesktop}~\href{www.shubhamrathi.in}{shubhamrathi.in}
\enspace 
\pscircled{\faEnvelope}~hello@shubhamrathi.in
\enspace 
\pscircled{\faPhone}~+91-9985556304\\
%
\pscircled{\faGithub}~srrathi
\enspace 
\pscircled{\faLinkedin}~/in/shubhamrrathi

\end{document} 

enter image description here

| improve this answer | |
  • I've followed your steps but the icons have disappeared. Please see this sharelatex file: goo.gl/SrsVa4 – user3426358 Oct 2 '16 at 0:30
  • 2
    Sorry! I forgot to mention, for pstricks commands to work with pdflatex, you have to launch it with the -shell-escape switch. – Bernard Oct 2 '16 at 0:57
  • How do you launch with -shell-escapein Sharelatex? – user3426358 Oct 2 '16 at 9:47
  • I'm sorry, I don't use Share LaTeX and have no idea. If this is not possible (for security reasons), I suggest you write individual graphic files for each of the circled icons in the classic way (latex -> dvips ->pstopdf) as standalone files, and use them with \includegraphics. For this method, \raisebox{-0.315\height} command can be removed. – Bernard Oct 2 '16 at 10:01
  • I see. Writing individual files was always an option but I would prefer a solution that is compatible with Sharelatex too. Nonetheless, this is help. Thanks. – user3426358 Oct 2 '16 at 10:23
5

A simple solution with \textcircled and \resizebox:

simple MWE

\documentclass{article}
\usepackage{graphicx,fontawesome}
\def\ci#1{\textcircled{\resizebox{.5em}{!}{#1}}}
\begin{document}
\ci{\faDesktop} shubhamrathi.in\par
\ci{\faEnvelope} hello@shubhamrathi.in\par
\ci{\faPhone} +91-9985556304\par
\ci{\faGithub} srrathi\par
\ci{\faLinkedin} /in/shubhamrrathi\par
\end{document}
| improve this answer | |
  • This caused the icons to shrink a bit. I've found a solution, have posted it below. – user3426358 Oct 2 '16 at 16:42
  • @user3426358 The was the idea, so that the circle size is consistent with the size of circles surrounding a normal character. If you want bigger circled icons you can always use a bigger font for the circle and resize the icon accordingly (some like {\Large\textcircled{\resizebox{.6em}{!}{\faDesktop}}} ) but a larger icon does not look very nice, IMHO, at least with single spacing. – Fran Oct 2 '16 at 18:40
2

With scalerel and stackengine (what else?)

\documentclass{article}
\usepackage{fontawesome}
\usepackage{scalerel,stackengine}
\usepackage{hyperref}
\newcommand\srcircled[1]{%
  \stackinset{c}{}{c}{-.2ex}{\scalerel*{$#1$}{x}}{\textcircled{\strut}}}
\begin{document}
\srcircled{\faDesktop}~\href{www.shubhamrathi.in}{shubhamrathi.in}\par
\srcircled{\faEnvelope}~hello@shubhamrathi.in\par
\srcircled{\faPhone}~+91-9985556304\par
\srcircled{\faGithub}~srrathi\par
\srcircled{\faLinkedin}~/in/shubhamrrathi
\end{document} 

enter image description here

| improve this answer | |
0

After reading around more on the forum, this answer has helped me get the right solution.

\usepackage{hyperref, tikz}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
            \node[shape=circle,draw,inner sep=1pt] (char) {#1};}}

\circled{\faDesktop}~{shubhamrathi.in}
\circled{\faEnvelope}~hello@shubhamrathi.in
\circled{\faPhone}~9985556304
\circled{\faGithub}~ShubhamRathi
\circled{\faLinkedin}/in/ShubhamRRathi

This looks such: enter image description here

| improve this answer | |

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.