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 [email protected]
\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)

4
  • 1
    Must the circles all have the same size, or be adjusted to the glyph size?
    – Bernard
    Commented Oct 1, 2016 at 23:19
  • Same Size for all circles. Commented Oct 1, 2016 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.
    – user30471
    Commented Oct 1, 2016 at 23:38
  • Updated the question with MWE. Thanks for curating the question. Commented Oct 2, 2016 at 0:33

4 Answers 4

8

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}[email protected]
\enspace 
\pscircled{\faPhone}~+91-9985556304\\
%
\pscircled{\faGithub}~srrathi
\enspace 
\pscircled{\faLinkedin}~/in/shubhamrrathi

\end{document} 

enter image description here

5
  • I've followed your steps but the icons have disappeared. Please see this sharelatex file: goo.gl/SrsVa4 Commented Oct 2, 2016 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
    Commented Oct 2, 2016 at 0:57
  • How do you launch with -shell-escapein Sharelatex? Commented Oct 2, 2016 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
    Commented Oct 2, 2016 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. Commented Oct 2, 2016 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} [email protected]\par
\ci{\faPhone} +91-9985556304\par
\ci{\faGithub} srrathi\par
\ci{\faLinkedin} /in/shubhamrrathi\par
\end{document}
2
  • This caused the icons to shrink a bit. I've found a solution, have posted it below. Commented Oct 2, 2016 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
    Commented Oct 2, 2016 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}[email protected]\par
\srcircled{\faPhone}~+91-9985556304\par
\srcircled{\faGithub}~srrathi\par
\srcircled{\faLinkedin}~/in/shubhamrrathi
\end{document} 

enter image description here

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}[email protected]
\circled{\faPhone}~9985556304
\circled{\faGithub}~ShubhamRathi
\circled{\faLinkedin}/in/ShubhamRRathi

This looks such: enter image description here

You must log in to answer this question.

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