2

I'm attempting to use ModernCV's \social tool with the stackoverflow logo.

Following this advise, I uploaded this version of moderncv.cls to my project: http://tug.ctan.org/tex-archive/macros/latex/contrib/moderncv/moderncv.cls.

I added the stackoverflow logo to my project as a jpg image title SO.jpg.

I've tried adding the following to line 270 of the cls file, right before the line that says \collectionnew{socials}:

\newcommand*{\stackoverflowsocialsymbol} {\includegraphics[width=0.33cm]{SO.jpg}~}

I've also tried replacing line 335, which originally has \newcommand*{\stackoverflowsocialsymbol}{} to \newcommand*{\stackoverflowsocialsymbol} {\includegraphics[width=0.33cm]{SO.jpg}~}.

What am I doing wrong? I'm working Overleaf.

Here is my example tex file:

\documentclass[12pt,a4paper,roman]{moderncv}

\moderncvstyle{classic} \moderncvcolor{black}

\firstname{kilo} \familyname{Joules}

\social[linkedin]{kilojoules}

\social[stackoverflow][stackoverflow.com/users/3474956/kilojoules]{kilojoules}

\begin{document}

\makecvtitle

The LinkedIn icon shows up fine, but the StackOverflow icon is missing.

\end{document}

enter image description here

  • are there any compilation errors? – Willie Wong Dec 06 '21 at 18:52
  • @WillieWong When I compile with the baseline cls file, there are no errors. When I do the first approach I describe (defining stackoverflowsocialsymbol immediately before line 270) , there is an error: \stackoverflowsocialsymbol already defined. When I do the second approach, replacing the definition of stackoverflowsocialsymbol on line 332, there are no errors. In all cases, the stackoverflow symbol does not appear. – kilojoules Dec 06 '21 at 19:00
  • I don't know why you are mucking around with editing the class file yourself; testing on Overleaf just now and the bundled moderncv already has the stackoverflow symbol included. – Willie Wong Dec 06 '21 at 19:06
  • This is with Document Class: moderncv 2021-07-28 v2.2.0 modern curriculum vitae and letter document class, built using TeXLive 2021 as the distribution of choice on Overleaf. – Willie Wong Dec 06 '21 at 19:07
  • @WillieWong Thank you for looking into this. Could you post the successful tex file as an answer? My tex file does not work when I compile it with overleaf. In my real problem, I am also hoping to include a icon/link to my google scholar. – kilojoules Dec 06 '21 at 19:10
  • Wait, I think I see the issue. – Willie Wong Dec 06 '21 at 19:15

1 Answers1

3

Work-around: In Overleaf, please change the "compiler" to "XeLaTeX". (Do so by clicking on the Overleaf Menu on the top left corner and change the selection under "Settings".)

moderncv includes built-in symbols for both StackOverflow and GoogleScholar, via the fontawesome5 and academicons packages, if you compile using LuaTex or XeTeX. (Side note: fontawesome5 works fine with pdflatex too, but academicons do require Xe/LuaTeX.)

If you compile using pdfLatex, unfortunately, it uses a different method for defining icons (see the moderncviconsmarvosym.sty file). For LinkedIn a rendering of the LinkedIn icon is included in that file as a Tikz drawing, but no analogue of SO or GoogleScholar can be found in that file.


The reason that editing the .cls file doesn't do jack squat is because for the built-in symbols they are \renewcommanded later on in the load process (when you issue \moderncvstyle{...}), so changing the definition in moderncv.cls doesn't help (as they get rewritten in moderncviconsmarvosym.sty).

If you want to use pdflatex, you should actually include the line

\renewcommand*{\stackoverflowsocialsymbol}{\includegraphics[width=0.33cm]{SO.jpg}~} 

in the Preamble of your .tex file, after you call \moderncvstyle. This way it will overwrite the built-in and use the jpeg image you downloaded.

Willie Wong
  • 24,733
  • 8
  • 74
  • 106