2

I need to use a serif font - eg Times (New Roman) or Palatino - for the main text and a sans serif font - eg Helvetica or Arial - for headings and labelling diagrams, etc.

How do I get this format ?

In my class file, I have this:

\RequirePackage{sectsty,caption}
\ifthenelse{\boolean{sansheadings}}
{\allsectionsfont{\sffamily}
 \renewcommand{\@chapterfont}{\sffamily}
 \renewcommand{\captionfont}{\sffamily}
 \renewcommand{\headfootstyle}{\normalsize\sffamily}}
{}

Ideally I want to use Tahoma or Verdana (sans serif) for chapter titles and serif fonts (Charter or Palatino) in the remaining text. How do I get this?

4
  • Perhaps you should load your class with \documentclass[...,sansheading,...]{<class>}?
    – Werner
    Jul 18, 2014 at 17:04
  • 1
    Can you share this "class file"? In order to use non-standard fonts, you should use XeLaTeX.
    – Werner
    Jul 18, 2014 at 17:23
  • 1
    @Werner -- amend that to "...you should use XeLaTeX or LuaLaTeX." :-)
    – Mico
    Jul 18, 2014 at 17:30
  • Although you don't need to use those engines if look alikes will do (certainly not for the serifs). \usepackage{charter} for Charter? \usepackage{mathpazo} for Palatino? Or use TeX Gyre Pagella for Palatino.
    – cfr
    Jul 18, 2014 at 21:27

2 Answers 2

0

With xelatex, the definition of fonts is done this way (at least I do it this way):

\usepackage{xltxtra}
    \setmainfont{Palatino}
    \setsansfont{Tahoma}

Concerning the titles, you're right by using the sectsty package. But there is a more efficient way to define the font to use for all title or just for chapter.

\usepackage{sectsty} % Allows your to change titles style
    \allsectionsfont{\sffamily \mdseries} % Define the style of all titles

If you only want to change the chapter title font:

\usepackage{sectsty} % Allows your to change titles style
    \chapterfont{\sffamily \mdseries} % Delete the bold style and set the sans-serif font

For further informations, you can read the documentation: http://texdoc.net/texmf-dist/doc/latex/sectsty/sectsty.pdf

For the captions, the caption package allows you to do some customisations by passing parameters.

\usepackage[font=sf]{caption}

Here again, the documentation gives some example of customization (e.g. if you just want the label to be sans-serif or the whole caption).

\documentclass[11pt]{article}
    \usepackage{xltxtra}
        \setmainfont{Palatino}
        \setsansfont[Scale=.9]{Tahoma}
    \usepackage{sectsty} % Allows your to change titles style
        \allsectionsfont{\sffamily \mdseries} % Define the style of all titles
    \usepackage[font=sf]{caption}
\begin{document}
    \section{Just a title}
        My paragraph with the content of my mind.

        \begin{figure}[h]
            \centering
            \LaTeX
            \caption{The logo of \LaTeX}
        \end{figure}

        The rest of what I want to say.
\end{document}

enter image description here

1

Run with pdflatex or xelatex. It works with both.

\documentclass{scrartcl}
\usepackage{ifxetex}
\ifxetex
  \usepackage{unicode-math}
  \newfontfamily\fTitle{Arial}
  \setmainfont{TeXGyreBonum-Regular}
  \setsansfont[Scale=0.95]{TeXGyreHeros-Regular}
  \setmathfont{TeXGyreBonumMath-Regular}
\else
  \usepackage[T1]{fontenc}
  \usepackage[scale=0.95]{tgheros}
  \usepackage{mathpazo}%% For the math part
  \usepackage{tgbonum}
  \let\fTitle\sffamily
\fi
\addtokomafont{sectioning}{\fTitle}%% Sans Serif is the default
\addtokomafont{caption}{\fTitle}
\addtokomafont{captionlabel}{\fTitle}

\begin{document}
\section{This is a title}
This is some nonsense text in serif 

\begin{figure}[!htb]\centering
\fbox{$f(x)=x^2$}
\caption{My wonderful caption}
\end{figure}

This is some more nonsense text in serif and some in \textsf{Sans Serif}.
\end{document}

enter image description here

You must log in to answer this question.

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