6

Can you help me to compile this pie diagram with this document class.

main.tex

\documentclass[]{cv-style}

%-------------------------------------------------------------------------------------
% Diagram
%-------------------------------------------------------------------------------------
\begin{document}

\begin{tikzpicture}[text=white, border/.style={line width=14mm}]
  \foreach \angle/\col [remember=\angle as \last (initially 1)] in 
    {90/blue, 162/red, 234/green, 288/purple, 342/orange, 360/aquamarine}{
      \draw[\col, border] (\last:2cm) 
          arc[start angle=\last, end angle=\angle, radius=2cm];
      \draw[white, line width=1mm] (\last:1.3)--++(\last:1.4);
  }
  \node[line width=1mm, draw, circle, white, minimum width=2.5cm, fill=lightgray] {\large C/C++};
  \node[text width=1cm, align=center] at (50:2cm) {C\# (.NET)};
  \node[text width=1cm, align=center] at (130:2cm) {Java};
  \node[text width=1cm, align=center] at (195:2cm) {JS};
  \node[text width=1cm, align=center] at (260:2cm) {PHP HTML CSS};
  \node[text width=1cm, align=center] at (315:2cm) {SQL};
  \node[text width=1cm, align=center] at (353:2cm) {Scripts};
\end{tikzpicture}

\end{document}

cv-style.cls

\ProvidesClass{cv-style}[2015/02/27 CV class]
\NeedsTeXFormat{LaTeX2e}

\ProcessOptions\relax
\LoadClass{article}

\RequirePackage{tikz}

%-------------------------------------------------------------------------------------
% Définition des couleurs
%-------------------------------------------------------------------------------------
\RequirePackage{xcolor}

\definecolor{white}{RGB}{255,255,255}

\definecolor{lightgray}{HTML}{C0C0C0}
\definecolor{gray}{HTML}{303030}
\definecolor{darkgray}{HTML}{333333}

\definecolor{blue}{HTML}{1DB1FC}
\definecolor{red}{HTML}{DC3912}
\definecolor{orange}{HTML}{FF9900}
\definecolor{green}{HTML}{109618}
\definecolor{purple}{HTML}{9358FE}
\definecolor{aquamarine}{HTML}{0C343D}

\definecolor{date}{HTML}{A4A4A4}

\colorlet{fillheader}{white}
\colorlet{namecolor}{black}
\colorlet{headercolor}{black}
\colorlet{headerSub}{darkgray}
\colorlet{textcolor}{gray}


%-------------------------------------------------------------------------------------
% Définition des polices
%-------------------------------------------------------------------------------------
\RequirePackage[quiet]{fontspec}
\RequirePackage[math-style=TeX,vargreek-shape=unicode]{unicode-math}

\newfontfamily\bodyfont
[BoldFont=texgyreheros-bold.otf,
ItalicFont=texgyreheros-italic.otf,
BoldItalicFont=texgyreheros-bolditalic.otf]
{texgyreheros-regular.otf}
\newfontfamily\bodyfont{Roboto-Regular}[Path=fonts/]
\newfontfamily\bodyfontit{Roboto-LightItalic}[Path=fonts/]
\newfontfamily\thinfont{Roboto-Thin}[Path=fonts/]
\newfontfamily\headingfont{RobotoCondensed-Bold}[Path=fonts/]

\defaultfontfeatures{Mapping=tex-text}
\setmainfont[Mapping=tex-text, Color=textcolor, Path = fonts/]{Roboto-Light}

\renewcommand{\bfseries}{\fontsize{11pt}{11pt}\headingfont\color{headerSub}}

\newcommand{\italica}[1]{%
    {\color{gray}\bodyfontit #1}%
}

You can find it here.

4
  • You should use xelatex and not pdflatex. You can compile it in your PC or try to do it on overleaf.
    – Ignasi
    May 3, 2016 at 14:31
  • I got the same problem with xelatex.
    – hlapointe
    May 3, 2016 at 14:32
  • And the problem is?
    – Ignasi
    May 3, 2016 at 14:34
  • I can't apply the font correctly to the diagram.
    – hlapointe
    May 3, 2016 at 14:45

1 Answer 1

4

You need to pass the font option to your tikzpicture, using font= somewhere within the square brackets.

I don't have the Roboto fonts, so I've used Baskerville to demonstrate.

enter image description here

\begin{filecontents}{cv-style.cls}
\ProvidesClass{cv-style}[2015/02/27 CV class]
\NeedsTeXFormat{LaTeX2e}

\ProcessOptions\relax
\LoadClass{article}

\RequirePackage{tikz}

%-------------------------------------------------------------------------------------
% Définition des couleurs
%-------------------------------------------------------------------------------------
\RequirePackage{xcolor}

\definecolor{white}{RGB}{255,255,255}

\definecolor{lightgray}{HTML}{C0C0C0}
\definecolor{gray}{HTML}{303030}
\definecolor{darkgray}{HTML}{333333}

\definecolor{blue}{HTML}{1DB1FC}
\definecolor{red}{HTML}{DC3912}
\definecolor{orange}{HTML}{FF9900}
\definecolor{green}{HTML}{109618}
\definecolor{purple}{HTML}{9358FE}
\definecolor{aquamarine}{HTML}{0C343D}

\definecolor{date}{HTML}{A4A4A4}

\colorlet{fillheader}{white}
\colorlet{namecolor}{black}
\colorlet{headercolor}{black}
\colorlet{headerSub}{darkgray}
\colorlet{textcolor}{gray}


%-------------------------------------------------------------------------------------
% Définition des polices
%-------------------------------------------------------------------------------------
\RequirePackage[quiet]{fontspec}
\RequirePackage[math-style=TeX,vargreek-shape=unicode]{unicode-math}

\newfontfamily\bodyfont
[BoldFont=texgyreheros-bold.otf,
ItalicFont=texgyreheros-italic.otf,
BoldItalicFont=texgyreheros-bolditalic.otf]
{texgyreheros-regular.otf}
\newfontfamily\bodyfont{Baskerville}
\newfontfamily\bodyfontit{Baskerville Italic}
\newfontfamily\thinfont{Baskerville}
\newfontfamily\headingfont{Baskerville SemiBold}

\defaultfontfeatures{Mapping=tex-text}
\setmainfont[Mapping=tex-text, Color=textcolor]{Avenir Next}

\renewcommand{\bfseries}{\fontsize{11pt}{11pt}\headingfont\color{headerSub}}

\newcommand{\italica}[1]{%
    {\color{gray}\bodyfontit #1}%
}
\end{filecontents}

\documentclass[]{cv-style}

%-------------------------------------------------------------------------------------
% Diagram
%-------------------------------------------------------------------------------------
\begin{document}

\begin{tikzpicture}[text=white, border/.style={line width=14mm},font=\bodyfontit]
  \foreach \angle/\col [remember=\angle as \last (initially 1)] in 
    {90/blue, 162/red, 234/green, 288/purple, 342/orange, 360/aquamarine}{
      \draw[\col, border] (\last:2cm) 
          arc[start angle=\last, end angle=\angle, radius=2cm];
      \draw[white, line width=1mm] (\last:1.3)--++(\last:1.4);
  }
  \node[line width=1mm, draw, circle, white, minimum width=2.5cm, fill=lightgray] {\large C/C++};
  \node[text width=1cm, align=center] at (50:2cm) {C\# (.NET)};
  \node[text width=1cm, align=center] at (130:2cm) {Java};
  \node[text width=1cm, align=center] at (195:2cm) {JS};
  \node[text width=1cm, align=center] at (260:2cm) {PHP HTML CSS};
  \node[text width=1cm, align=center] at (315:2cm) {SQL};
  \node[text width=1cm, align=center] at (353:2cm) {Scripts};
\end{tikzpicture}

\end{document}
4
  • Why your code doesn't work with my police?
    – hlapointe
    May 3, 2016 at 15:28
  • You need to build with XeLaTeX, not pdflatex, and you need to have the Baskerville fonts installed. If you don't have them, you can easily change them to something else. The point is you need to add something like font=\bodyfontit to your tikzpicture options.
    – erik
    May 3, 2016 at 15:40
  • How can I install a font when I'm using Overleaf?
    – hlapointe
    May 3, 2016 at 15:41
  • @hlapointe I don't know. Try their help pages
    – erik
    May 3, 2016 at 15:44

You must log in to answer this question.

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