Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'd like to use 3-4 different specific system fonts (e.g., Georgia, HelveticaNeui Light, and Lucida Sans) with certain font sizes for different sections of a page. How would I do this?

Edit: Thanks for the responses. I saw the fontspec package but the examples I found defined in the preamble \setmainfont{}, \setsansfont{}, etc. I couldn't figure out how to define a fontfamily and then reference it for a particular section. Here's an example:

\documentclass[12pt]{article}

\usepackage{fontspec}

\begin{document}

\section{Georgia}%here define font

This text shows in Georgia.

\section{Lucida Sans}%

This text shows in Lucida Sans

\section{HelveticaNeue Light}%here define font

This text shows in Helvetica Neue Light

\end{document}
share|improve this question
    
Welcome to TeX.sx! –  Peter Jansson Apr 14 '13 at 20:00
1  
Have you looked into the \newfontfamily directive of the fontspec package? –  Mico Apr 14 '13 at 20:15
    
Here's an example of pretty much exactly what you want to do: Change section fonts. –  Alan Munn Apr 14 '13 at 20:32
    
Thanks, Alan. I saw that example which defines the formatting by section, subsection, etc. I'm looking to specify formatting for different sections - I'm used to styling in HTML/CSS where to do this you'd assign each paragraph to different classes and then for each of those classes define the font size, font family, color, margin, etc. –  jack Apr 14 '13 at 21:01
    
@Jack The principle is the same. You can define various section-like headings using titlesec. I'll post an example shortly. But reading your question more carefully, I'm wondering, do you want the text within a section to be of a different font, or the section heading, or both? –  Alan Munn Apr 14 '13 at 21:08
add comment

1 Answer 1

up vote 9 down vote accepted

If you just want chunks of text to be a different font you can simply set up environments for them using whatever semantics makes sense for your document. The main thing to remember is that you should use \newfontfamily to define a font switching command for each font rather than using the \fontspec command directly. For example:

% Compile with XeLaTeX or LuaLaTeX
\documentclass[12pt]{article}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}

\newfontfamily\calibrifont{Calibri}
\newfontfamily\cambriafont{Cambria}
\newfontfamily\georgiafont{Georgia}

\newenvironment{calibri}{\calibrifont}{\par}
\newenvironment{cambria}{\cambriafont}{\par}
\newenvironment{georgia}{\georgiafont}{\par}

\begin{document}
\begin{calibri}
This text is in Calibri
\end{calibri}
\begin{cambria}
This text is in Cambria
\end{cambria}
\begin{georgia}
This text is in Georgia
\end{georgia}
\end{document}

output of code

share|improve this answer
    
Perfect, thanks everyone for the help –  jack Apr 14 '13 at 21:38
    
What happens if you use pdflatex? –  Mario S. E. Sep 30 '13 at 16:14
    
@MarioS.E. You don't. fontspec requires either XeLaTeX or LuaLaTeX. –  Alan Munn Sep 30 '13 at 19:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.