7

So I downloaded a template for a CV. It uses XeLaTeX. I would like to change the font but I lost hope to find myself how I am supposed to do that. My OS is Windows 7. Here is a functional code that uses the original font Fontin. I downloaded it to make it work, and I would like to use something else (and something that uses accents (I speak french) !)

\documentclass[a4paper,10pt]{article} % Default font size and paper size
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{textpos}
\usepackage{fontspec} % For loading fonts
\defaultfontfeatures{Mapping=tex-text}
\setmainfont[SmallCapsFont = Fontin SmallCaps]{Fontin}

\usepackage{xunicode,xltxtra,url,parskip} % Formatting packages

\usepackage[usenames,dvipsnames]{xcolor} % Required for specifying custom colors

\usepackage[big]{layaureo} 

\usepackage{hyperref} % Required for adding links   and customizing them
\definecolor{linkcolour}{rgb}{0,0.2,0.6} % Link color
\hypersetup{colorlinks,breaklinks,urlcolor=linkcolour,linkcolor=linkcolour} % Set link colors throughout the document

\usepackage{titlesec} % Used to customize the \section command
\titleformat{\section}{\Large\raggedright}{}{0em}{} % Text formatting of sections
\titlespacing{\section}{0pt}{2pt}{2pt} % Spacing around sections
\usepackage{vmargin}
\usepackage{fullpage}

\begin{document}
\setmarginsrb{25mm}{0mm}{30mm}{0mm}{1cm}{5mm}{1mm}{10mm}
\pagestyle{empty} % Removes page numbering

\font\fb=''[cmr10]'' % Change the font of the \LaTeX command under the skills section

\par{\Huge TacTac \textsc{TicToc} - OncheOnche \bigskip\par} 
\par{\Huge \hspace{8mm}  huehuehue \bigskip\par}

\section{Données personnelles}
\begin{textblock}{.9}(0,0)
\rule{97mm}{0.09mm}
\end{textblock}
\begin{tabular}{rl}
\textsc{Date de naissance:} & 01 brumeneige 3030 \\
\textsc{Adresse:} & Somewhere, sometimes \\
\textsc{Téléphone:} & +123456789\\
\textsc{Email:} & what about
\end{tabular}


\section{Objectifs}\titlerule

I met a traveler from an antic land who said : Two vast and trunkless legs of stone stand in the desert... \\

%----------------------------------------------------------------------------------------
%   EDUCATION
%-------------------------------------------------------------------------------                      ---------



\end{document}

I believe the problem comes from the lines

\defaultfontfeatures{Mapping=tex-text}
\setmainfont[SmallCapsFont = Fontin SmallCaps]{Fontin}

But I don't know what I must change, where does the compiler look for the fonts... I saw other questions that look like mine, but all used Linux. I also saw that there could be some problems with fonts using spaces in their name (seriously...?)... Anyway. Someone got an idea ?

  • 2
    Welcome! Well, Fontin is the name of the font. If you want to use a different one, use a different name. Which fonts depend on which fonts are installed on you system. Any truetype or opentype font should work. See the fontspec manual for details. By the way, this is not a good template. The fact that it uses vmargin is more than enough reason not to use it. – cfr Jul 28 '15 at 16:45
  • 1
    Your assumption is right. To change the main font from Fontin to something else, just change \setmainfont{Fontin} to \setmainfont{Some other font}. Also, it's a bad idea to just use someone else's template if you have no idea what it is doing. The first step should be to do a search for "xelatex" and "fontspec" in order to learn the basics. – Sverre Jul 28 '15 at 17:14
  • I recommend avoiding vmargin and preferring geometry. – egreg Jul 28 '15 at 17:24
  • Got it, indeed I just need to change \setmainfont{Fontin} to \setmainfont{Arial} or something. That's strange, I thought that I tried that and that didn't work... mmmh. Anyway, it works now. Even with CMU Serif ! – Darryl Jul 28 '15 at 17:28
  • How do I vote for the comment of @Sverre ? That is his comment that unlocked me.. – Darryl Jul 28 '15 at 17:32
12

Stripping down your document to the bare minimum required for this question (see minimal working example (MWE) for more detail), the following shows how to change the main font of your document with \setmainfont:

\documentclass{article}
\usepackage{lipsum} % add nonsense text
\usepackage{fontspec}
    \setmainfont{Arial}

\begin{document}
\lipsum[1]
\end{document}

enter image description here

2

This works for me:

\documentclass[a4paper,10pt]{article} % Default font size and paper size
\usepackage{fontspec} % For loading fonts
\setmainfont[SmallCapsFont=Fontin SmallCaps]{Fontin-Regular}

\usepackage{url,parskip} % Formatting packages
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{textpos}
\usepackage[usenames,dvipsnames]{xcolor} % Required for specifying custom colors    
\usepackage[big]{layaureo}     

\usepackage{titlesec} % Used to customize the \section command
\titleformat{\section}{\Large\raggedright}{}{0em}{} % Text formatting of sections
\titlespacing{\section}{0pt}{2pt}{2pt} % Spacing around sections
\usepackage{hyperref} % Required for adding links   and customizing them
\hypersetup{colorlinks,breaklinks,urlcolor=linkcolour,linkcolor=linkcolour} % Set link colors throughout the document
\definecolor{linkcolour}{rgb}{0,0.2,0.6} % Link color

\usepackage{vmargin}
\usepackage{fullpage}

\begin{document}
    \setmarginsrb{25mm}{0mm}{30mm}{0mm}{1cm}{5mm}{1mm}{10mm}
    \pagestyle{empty} % Removes page numbering

    \par{\Huge TacTac \textsc{TicToc} - OncheOnche \bigskip\par} 
    \par{\Huge \hspace{8mm}  huehuehue \bigskip\par}

    \section{Données personnelles}
    \begin{textblock}{.9}(0,0)
        \rule{97mm}{0.09mm}
    \end{textblock}
    \begin{tabular}{rl}
        \textsc{Date de naissance:} & 01 brumeneige 3030 \\
        \textsc{Adresse:} & Somewhere, sometimes \\
        \textsc{Téléphone:} & +123456789\\
        \textsc{Email:} & what about
    \end{tabular}

    \section{Objectifs}\titlerule

    I met a traveler from an antic land who said : Two vast and trunkless legs of stone stand in the desert... \\

    %----------------------------------------------------------------------------------------
    %   EDUCATION
    %-------------------------------------------------------------------------------                      ---------

\end{document}

enter image description here

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.