# Applying custom size and spacing to quote environment

Am using "article" document class in LyX and trying to get the quote paragraph-environment to run with "small" text size and single-spacing (globally), while keeping the rest of the document (standard paragraph environment) with the default settings -- default text size and double-spacing.

Have tried using the following in the LaTeX Preamble:

\let\oldquote\quote
\renewcommand\quote{\small\singlespacing\oldquote}


This almost works. The problem is that some paragraphs in the standard environment take on the singlespacing that I am trying to apply (exclusively) to the quote environment. How do I make sure that the singlespacing only applies to the quote environment?

Add the following to the preamble:

\expandafter\def\expandafter\quote\expandafter{\quote\small\singlespacing}


A complete example:

\documentclass{article}
\usepackage{setspace}
\usepackage{lipsum}

\expandafter\def\expandafter\quote\expandafter{\quote\small\singlespacing}
\doublespacing

\begin{document}

\lipsum[4]
\begin{quote}
\lipsum[4]
\end{quote}
\lipsum[4]

\end{document}


\expandafter<token1><token2> will be replaced by <token1> expansion of <token2> and <token1> won't be expanded until after <token2> gets expanded.

• Gonzalo, Thank you! This produces exactly the formatting that I was looking for. I am new to LyX and a novice when it comes to programming. If you have a moment, I would love to have a better understanding of the code that you've offered -- specifically, what is the function of "expandafter"? Jun 9 '13 at 16:35
• @JForney I've added a brief description of \expandafter. If you want a full understanding, you'll need some TeX reading; TeX by Topic is a good reference (texdoc texbytopic in a terminal). Jun 9 '13 at 16:50
• @JForney You're welcome! Don't forget, that now that you've received answers to your questions, you can accept the one that you consider best solved your problem by clicking the checkmark to its left. In case of doubt, please see How do you accept an answer?. With a little more reputation you'll also be able to up-vote good answers :-) Jun 9 '13 at 17:09

I am a friend of the package etoolbox. It provides a lot of useful macros. One of them is \appto which adds material to a definition.

\usepackage{etoolbox}
\appto\quote{\small\singlespacing}


This method fails it the environment has any arguments. Therefor you can use the command \AtBeginEnvironment which is also provided by etoolbox:

\usepackage{etoolbox}
\AtBeginEnvironment{quote}{\small\singlespacing}


The LaTeX-kernel defines also a hook. Unfortunately it's using the special symbol @. The command is \g@addto@macro. So you have to use \makeatletter/\makeatother:

\makeatletter