1

Oveleaf say that it's possible to use a set of pre-installed fonts here. One of these is "CMU Classical Serif" I want to change the section title in my document to be "CMU Classical Serif"

I try the following, but the font does not change at all (using package titlesec, XeLaTex compiler for fontspec)

    \newfontfamily\sectionfonts{CMU Classical Serif}
    \titleformat*{\section}{ \center \large \bf}
    \titleformat*{\subsection}{\bf} 
    \titleformat*{\subsubsection}{\it} 

Is this a problem with Overleaf or have I done something wrong?

Edit: there are no errors, not even "font not found", just no changes...

  • 1
    Welcome to TeX.SE! Did you ask the support of overleaf? They should know ... – Mensch May 29 at 9:14
  • titlesec doesn't use \sectionfonts directly, so you'll need to actually call it in your \titleformat perhaps? – LianTze Lim May 29 at 9:28
  • unrelated but note that \center should never be used as a command form, I think you intended \centering` – David Carlisle May 29 at 9:40
0

You are using the deprecated font commands such as \bf they will always use the document default encoding and family, they do not combine in the way that latex2e font commands do

Presumably you want something like

\titleformat*{\section}{\centering\sectionfonts\large\bfseries}
0

I think I found a solution: I just need to define a fontfamily separately and then call this inside \titelformat* as @LianTze Lim was suggesting, i.e:

\newfontfamily\headingfont[]{Alexander} 
 \titleformat{\section}{\headingfont \centering \large\bfseries}{\S \thesection.}{0.5em}{}[{\titlerule[0.2pt]}]

(the last parts are irrelevant). Thanks also to @DavidCarlisle, although I admit I haven't checked this :)

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.