15

Sorry if this is a duplicate, but I can't find the right way of doing this.

I want to redefine my quote and quotation commands to use a different font. My main font is Linux Libertine O (I am using fontspec), and I want to use the small version of Linux Biolinum O inside my quotations.

Among some of the commands I've tried is this, but it ain't working:

\let\quoteOld\quote
\renewenvironment{quote}{\fontspec{Linux Biolinum O}\small\quoteOld}

Bonus question: What do I need to learn, in order to figure out how to achieve the above by myself? I would appreciate a book or resource to read.

lockstep
  • 250,273

3 Answers3

24

As I've commented on one of your other questions, you shouldn't use \fontspec to change fonts, but define a new fontfamily. The etoolbox package provides simple patching commands. For this you can just use its \AtBeginEnvironment command.

% !TEX TS-program = XeLaTeX

\documentclass{article}

\usepackage{etoolbox}
\usepackage{fontspec}
\setmainfont{Linux Libertine O}
\newfontfamily\quotefont{Linux Biolinum O}
\AtBeginEnvironment{quote}{\quotefont\small}
\begin{document}
Some text.
\begin{quote}
A quotation.
\end{quote}

\end{document}
Alan Munn
  • 218,180
4

Your code snippet is missing the third required argument of \renewenvironment which specifies the code to be executed at the end of the environment.

\documentclass{article}

\usepackage{fontspec}

\setmainfont{Linux Libertine O}
\newfontfamily{\quotefont}{Linux Biolinum O}

\let\quoteOld\quote
\let\endquoteOld\endquote
\renewenvironment{quote}{\quotefont\small\quoteOld}{\endquoteOld}

\usepackage{lipsum}

\begin{document}

\lipsum[1]

\begin{quote}
\lipsum*[1]
\end{quote}

\lipsum[1]

\end{document}
lockstep
  • 250,273
3

After adding the fontspec code for your font, just change the quote size.

% Using 'xelatex'
\documentclass{article}

\usepackage{fontspec}
\setmainfont{Linux Libertine O}
\expandafter\def\expandafter\quote\expandafter{\quote\small}

\begin{document}
 Normal text.

\begin{quote}
    This is a quote.
\end{quote}

\end{document}

The line: \expandafter\def\expandafter\quote\expandafter{\quote\small} works without adding any other package.

pferor
  • 131