19

I understand that there is a \quote (correct me if I'm wrong) macro to do this; but I'm using this for something else (not prose). I also want it to obey the right margin. My minimal working example below requires me to guess the \parbox width, which is not a best practice. See the line with the \newcommand{\myquote}...

\documentclass{article}

\newcommand{\myquote}[1]{\vskip6pt\noindent\hangindent=5em\hangafter=0\parbox{4in}{#1}\vskip6pt}

\begin{document}

The quick brown fox jumps over the lazy dog.

\myquote{The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.}

The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.

$E=mc^2$ by Einstein

\end{document}
lockstep
  • 250,273
Kit
  • 16,430

6 Answers6

19

I've always found it rather counter-intuitive that the various quote environments are implemented via the generic list environment (IIRC, the adjustwidth from memoir is also implemented that way). Recently, I had trouble combining adjustwidth with \obeylines (and some other stuff), giving me a "missing \item" error. Then I found \leftskip and \rightskip in the TeXbook. I think this is what you want:

\documentclass{article}
\usepackage{lipsum}

\newenvironment{blockquote}{% \par% \medskip \leftskip=4em\rightskip=2em% \noindent\ignorespaces}{% \par\medskip}

\begin{document}

\lipsum[1]

\begin{blockquote} \lipsum[2]

\lipsum[3] \end{blockquote}

\lipsum[4]

\end{document}

MWE

If you want the first paragraph of the quote indented, just remove the \noindent. If you don't want the first paragraph after the quote to be indented, insert \aftergroup\@afterindentfalse\aftergroup\@afterheading after the last \medskip, and put a \makeatletter / \makeatother pair before/after the \newenvironment.

tvk
  • 1,637
Villemoes
  • 4,131
  • https://tex.stackexchange.com/questions/370816/indent-a-whole-section-all-lines-but-the-first#comment915801_370819 – user202729 May 19 '22 at 13:55
8

Internally, quote is defined using the list environment, you can define your own by copying and modifying its original definition

\newenvironment{myquote}{%
   \list{}{\rightmargin\leftmargin}\item\relax
   % and maybe do more stuff
}{\endlist}
Juan A. Navarro
  • 62,139
  • 32
  • 140
  • 169
5

Old question, but I thought I'd mention \narrower, which increases the \left- and \rightskip by \parindent so things stay consistent. In the TeXbook exercise 14.15, it is used with a \smallskip before and after, as well as an initial \noindent:

\documentclass{article}
\usepackage{lipsum}
\newcommand{\blockquote}[1]{%
  {\narrower\smallskip\noindent#1\smallskip}}
\begin{document}
\lipsum[41]
\blockquote{\lipsum[34]}
\lipsum[12]
\end{document}
morbusg
  • 25,490
  • 4
  • 81
  • 162
3

By using the changepage package, one could achieve the same result:

enter image description here

\documentclass{article}
\usepackage{lipsum}
\usepackage{changepage}

\begin{document}

\lipsum[1]

\begin{adjustwidth*}{4em}{2em}
  \lipsum[2]

  \lipsum[3]
\end{adjustwidth*}

\lipsum[4]

\end{document}
azetina
  • 28,884
3

It's easier to take the according code for the quote environment from the class file, modify it slightly and create a new environment.

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{blindtext}

\newenvironment{lquote}{%
  \list{}{%
    \rightmargin0pt}%
    \item\relax
  }
{\endlist}

\begin{document}
  \blindtext
  \begin{lquote}
    \blindtext
  \end{lquote}
  \blindtext
\end{document}

Note that the blindtext package is only use for producing dummy text thus not part of the solution.

2

You can also just delete \parbox{4in} (and leave {} around #1) in your code; then it'll work. And no, guessing the \parbox width is definitely not best practice.

Hendrik Vogt
  • 37,935