| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% This is file `quoting.dtx'. |
| 4 |
% |
| 5 |
% Copyright (C) 2011--2014 by Thomas Titz <[email protected]> |
| 6 |
% |
| 7 |
% Permission is granted to distribute and/or modify this work under the |
| 8 |
% terms of the LaTeX Project Public License (LPPL), version 1.3c or |
| 9 |
% later. |
| 10 |
% |
| 11 |
% The LPPL maintenance status of this work is "maintained". |
| 12 |
% |
| 13 |
% This work consists of the files quoting.dtx, quoting.ins and README |
| 14 |
% and the derived files quoting.pdf and quoting.sty. |
| 15 |
% |
| 16 |
% \fi |
| 17 |
% |
| 18 |
% \iffalse |
| 19 |
% |
| 20 |
%<*driver> |
| 21 |
\documentclass{ltxdoc} |
| 22 |
\EnableCrossrefs |
| 23 |
\CodelineIndex |
| 24 |
\RecordChanges |
| 25 |
% \OnlyDescription |
| 26 |
\GlossaryPrologue{% |
| 27 |
\section*{{Change History}}% |
| 28 |
\markboth{{Change History}}{{Change History}}% |
| 29 |
\vspace{-\multicolsep}% |
| 30 |
} |
| 31 |
\newcommand*{\SpecialOptIndex}[1]{% |
| 32 |
\index{#1={\protect\sffamily#1} (option)|usage}% |
| 33 |
\index{options:>#1={\protect\sffamily#1}|usage}% |
| 34 |
} |
| 35 |
\usepackage{quoting} |
| 36 |
\usepackage{csquotes} |
| 37 |
\SetBlockEnvironment{quoting} |
| 38 |
\usepackage[bottom]{footmisc} |
| 39 |
\addtolength{\skip\footins}{5pt} |
| 40 |
\usepackage{cite,enumitem,url} |
| 41 |
\frenchspacing |
| 42 |
\def\quo/{\textsf{quoting}} |
| 43 |
\def\quoa/{\textsf{quotation}} |
| 44 |
\def\quoe/{\textsf{quote}} |
| 45 |
\widowpenalty=10000 |
| 46 |
\begin{document} |
| 47 |
\DocInput{quoting.dtx} |
| 48 |
\end{document} |
| 49 |
%</driver> |
| 50 |
% |
| 51 |
% \fi |
| 52 |
% |
| 53 |
% \CheckSum{169} |
| 54 |
% |
| 55 |
% \CharacterTable |
| 56 |
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 57 |
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 58 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 59 |
% Exclamation \! Double quote \" Hash (number) \# |
| 60 |
% Dollar \$ Percent \% Ampersand \& |
| 61 |
% Acute accent \' Left paren \( Right paren \) |
| 62 |
% Asterisk \* Plus \+ Comma \, |
| 63 |
% Minus \- Point \. Solidus \/ |
| 64 |
% Colon \: Semicolon \; Less than \< |
| 65 |
% Equals \= Greater than \> Question mark \? |
| 66 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 67 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 68 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 69 |
% Right brace \} Tilde \~} |
| 70 |
% |
| 71 |
% \changes{v0.1}{2011/08/08}{Initial public release} |
| 72 |
% |
| 73 |
% \GetFileInfo{quoting.sty} |
| 74 |
% |
| 75 |
% \DoNotIndex{\boolfalse,\booltrue,\csname,\def,\endcsname,\endinput} |
| 76 |
% \DoNotIndex{\ifbool,\item,\@M,\NeedsTeXFormat,\newbool,\newcommand} |
| 77 |
% \DoNotIndex{\newenvironment,\newlength,\par,\ProvidesPackage,\relax} |
| 78 |
% \DoNotIndex{\RequirePackage,\setlength,\z@} |
| 79 |
% \DoNotIndex{\do,\else,\fi,\ifcase,\ifcsname,\or} |
| 80 |
% |
| 81 |
% \title{The \quo/ package\thanks{This document corresponds to |
| 82 |
% \quo/~\fileversion, dated \filedate.}} |
| 83 |
% \author{Thomas Titz\thanks{E-mail: \texttt{[email protected]}}} |
| 84 |
% \maketitle |
| 85 |
% |
| 86 |
% \begin{abstract} |
| 87 |
% \noindent As an alternative to the \LaTeX\ standard environments |
| 88 |
% \quoa/ and \quoe/, the \quo/ package provides a consolidated |
| 89 |
% environment for displayed text. First-line indentation is activated by |
| 90 |
% adding a blank line before the \quo/ environment. A key--value |
| 91 |
% interface allows to configure font properties and spacing and to |
| 92 |
% control orphans within and after the environment. |
| 93 |
% \end{abstract} |
| 94 |
% |
| 95 |
% \section{Introduction} |
| 96 |
% |
| 97 |
% The \LaTeX\ standard classes as well as many custom classes provide |
| 98 |
% two environments for displayed text: \quoa/ and \quoe/. They can be |
| 99 |
% described as follows: \blockcquote[p.~480]{Kop04}{\textins{In} the |
| 100 |
% \quoa/ environment \textelp{} text is indented on both sides relative |
| 101 |
% to the normal page margins. Paragraphs within the environment are |
| 102 |
% marked with an additional indentation of the first line. |
| 103 |
% |
| 104 |
% \textins{The \quoe/ environment is} \textins*{t}he same as the \quoa/ |
| 105 |
% environment except that the first line of a paragraph is not indented; |
| 106 |
% instead, additional line spacing comes between paragraphs.} |
| 107 |
% |
| 108 |
% So when to prefer one environment to the other? A common suggestion is |
| 109 |
% to use the \quoa/ environment for quotes extending to several |
| 110 |
% paragraphs so that the paragraph indentation matches that of the |
| 111 |
% surrounding text \cite{Kot11,Lam94,Oet11}. For single-paragraph quotes |
| 112 |
% one may either use \quoe/ or, in case the quoted text starts a new |
| 113 |
% paragraph (which should be indicated by indentation), \quoa/. |
| 114 |
% |
| 115 |
% Why didn't Leslie Lamport, the initial developer of \LaTeX, implement |
| 116 |
% a single environment for displayed text and provide control over its |
| 117 |
% first-line indentation by other means, e.g. the presence of a blank |
| 118 |
% line (or a |\par| command) before the environment? The likely reason |
| 119 |
% is that Lamport envisaged an additional application of the \quoe/ |
| 120 |
% environment, namely \blockcquote[p.~24]{Lam94}{a sequence of short |
| 121 |
% quotations, separated by blank lines}. But such a sequence (which |
| 122 |
% seems to be of limited use) could also be put into effect by stringing |
| 123 |
% together several instances of a consolidated quoting environment. |
| 124 |
% |
| 125 |
% Some unfavourable effects of \quoa/ and \quoe/ in their present form |
| 126 |
% are: |
| 127 |
% |
| 128 |
% \begin{itemize} |
| 129 |
% |
| 130 |
% \item The \quoa/ environment isn't suited for documents which use |
| 131 |
% vertical spacing instead of indentation to denote the start of new |
| 132 |
% paragraphs. If one retroactively adopts such a layout, one should |
| 133 |
% change the definition of |\quotation| and |\endquotation| to |\quote| |
| 134 |
% resp. |\endquote|. |
| 135 |
% |
| 136 |
% \item The side-by-side existence of two environments for displayed |
| 137 |
% text narrows the utility of the \textsf{csquotes} package which |
| 138 |
% provides higher-level wrapper environments, e.g. for quoting in a |
| 139 |
% foreign language and specifying the source of citations. Currently, |
| 140 |
% \textsf{csquotes} uses \quoe/ as a backend environment, but with |
| 141 |
% \LaTeX's default settings, this is not appropriate for multi-paragraph |
| 142 |
% quotes. |
| 143 |
% |
| 144 |
% \end{itemize} |
| 145 |
% |
| 146 |
% \section{Using the \quo/ package} |
| 147 |
% |
| 148 |
% As an alternative to \quoa/ and \quoe/, the \quo/ package provides a |
| 149 |
% consolidated environment for displayed text. Besides being indented |
| 150 |
% relative to the normal page margins, the \quo/ environment behaves as |
| 151 |
% follows: |
| 152 |
% |
| 153 |
% \begin{itemize} |
| 154 |
% |
| 155 |
% \item A blank line before the environment marks a new paragraph, |
| 156 |
% i.\,e. the environment's first line will be (additionally) indented in |
| 157 |
% this case (assuming a positive |\parindent|). The mechanism also works |
| 158 |
% for adjoining \quo/ environments of the same depth and for nested |
| 159 |
% quotes.\footnote{See \cite[p.~120--121]{Fis95} for an example of |
| 160 |
% nested quotes.} |
| 161 |
% |
| 162 |
% \item If a \quo/ environment directly follows a sectioning command |
| 163 |
% (which may or may not be considered good style), its first line won't |
| 164 |
% be indented.\footnote{That is, unless the |@afterindent| switch was |
| 165 |
% set to true, e.g. by loading the \textsf{indentfirst} package. In this |
| 166 |
% case, the quote's first line will be indented.} |
| 167 |
% |
| 168 |
% \item As the start of a new paragraph is already indicated by |
| 169 |
% first-line indentation, the vertical space before and after the \quo/ |
| 170 |
% environment is kept constant (contrary to list environments like |
| 171 |
% \textsf{itemize} and \textsf{enumerate}). |
| 172 |
% |
| 173 |
% \item Because the \quo/ environment uses a custom mechanism to control |
| 174 |
% orphans\footnote{If a page break occurs after the first line of a |
| 175 |
% paragraph, that line is referred to as \enquote{orphan}.} within and |
| 176 |
% after it, it is not affected by \LaTeX\ bug 4065 (|\clubpenalty| not |
| 177 |
% always being reset after list environments). |
| 178 |
% |
| 179 |
% \end{itemize} |
| 180 |
% |
| 181 |
% The options provided by \quo/ use the key--value interface |
| 182 |
% `\meta{key}=\meta{value}'. Set them globally with |
| 183 |
% |\usepackage[|\meta{options}|]{quoting}| or for single environments |
| 184 |
% with |\begin{quoting}[|\meta{options}|]|. For boolean options, the |
| 185 |
% default value is \textsf{false}, and specifying \meta{key} is |
| 186 |
% equivalent to \meta{key}\textsf{=true}. |
| 187 |
% |
| 188 |
% \begin{description}[font=\sffamily] |
| 189 |
% |
| 190 |
% \changes{v0.1a}{2011/09/08}{New option \textsf{indentfirst}} |
| 191 |
% |
| 192 |
% \item[indentfirst]\SpecialOptIndex{indentfirst} An option that allows |
| 193 |
% to override \quo/'s indentation mechanism and to manually switch |
| 194 |
% on/off first-line indentation. The permitted values are \textsf{auto}, |
| 195 |
% \textsf{true}, and \textsf{false}. The default value is |
| 196 |
% \textsf{auto}.\footnote{The \textsf{indentfirst} option may act as a |
| 197 |
% fallback solution for cases where \quo/'s indentation mechanism fails. |
| 198 |
% Currently, first lines will always be indented a)~immediately after |
| 199 |
% \texttt{\textbackslash begin\{document\}} b)~after a |
| 200 |
% \textsf{sloppypar}, \textsf{center}, \textsf{flushleft}, or |
| 201 |
% \textsf{flushright} environment. Thanks to Enrico Gregorio for |
| 202 |
% pointing out \quo/'s behaviour with respect to \textsf{sloppypar}, |
| 203 |
% \textsf{center} \& friends.} |
| 204 |
% |
| 205 |
% \changes{v0.1b}{2012/02/21}{Improved syntax of options \textsf{font} |
| 206 |
% and \textsf{font+}} |
| 207 |
% |
| 208 |
% \item[font]\SpecialOptIndex{font} The font used for typesetting the |
| 209 |
% contents of a \quo/ environment. Permitted values are the names |
| 210 |
% (without preceding backslash) of \LaTeX's font-switching/formatting |
| 211 |
% commands; e.\,g, use \textsf{font=itshape} to typeset quotes in |
| 212 |
% italics. (By default, \quo/ uses the font/formatting of the |
| 213 |
% surrounding text.) To specify several font properties, use a |
| 214 |
% comma-separated list of font/formatting names, e.g., |
| 215 |
% \textsf{font=\{itshape,raggedright\}} (note the surrounding |
| 216 |
% braces).\footnote{Before \quo/ v0.1b, \textsf{font+} had to be invoked |
| 217 |
% for specifying several font properties.} |
| 218 |
% |
| 219 |
% \item[font+]\SpecialOptIndex{font+} Font properties used for |
| 220 |
% typesetting the contents of a \quo/ environment in addition to those |
| 221 |
% properties specified by \textsf{font} (and previous calls of |
| 222 |
% \textsf{font+}). |
| 223 |
% |
| 224 |
% \changes{v0.1b}{2012/02/21}{New options \textsf{begintext} |
| 225 |
% and \textsf{endtext}} |
| 226 |
% |
| 227 |
% \item[begintext]\SpecialOptIndex{begintext} Additional text (e.g., an |
| 228 |
% opening quotation mark) to be typeset at the start of a \quo/ |
| 229 |
% environment. By default, no text is added. |
| 230 |
% |
| 231 |
% \item[endtext]\SpecialOptIndex{endtext} Additional text (e.g., a |
| 232 |
% closing quotation mark) to be typeset at the end of a \quo/ |
| 233 |
% environment. By default, no text is added. |
| 234 |
% |
| 235 |
% \item[leftmargin]\SpecialOptIndex{leftmargin} The width of the |
| 236 |
% environment's left-hand indentation relative to the surrounding text. |
| 237 |
% The default value is |\leftmargin|.\footnote{Note that the value of |
| 238 |
% \texttt{\textbackslash leftmargin} depends on the depth of the \quo/ |
| 239 |
% environment, i.\,e. nested quotes will feature smaller indentation by |
| 240 |
% default.} |
| 241 |
% |
| 242 |
% \item[rightmargin]\SpecialOptIndex{rightmargin} The width of the |
| 243 |
% environment's right-hand indentation relative to the surrounding text. |
| 244 |
% By default, \textsf{rightmargin} matches \textsf{leftmargin}. |
| 245 |
% |
| 246 |
% \item[vskip]\SpecialOptIndex{vskip} The vertical space before and |
| 247 |
% after a \quo/ environment. The default value is the sum of |\topsep| |
| 248 |
% and |\partopsep|. |
| 249 |
% |
| 250 |
% \item[listvskip]\SpecialOptIndex{listvskip} A boolean option that, if |
| 251 |
% enabled, adjusts \quo/'s vertical spacing to that of list environments |
| 252 |
% (and ignores \textsf{vskip} in the process). |
| 253 |
% |
| 254 |
% \item[noorphanfirst]\SpecialOptIndex{noorphanfirst} A boolean option |
| 255 |
% that controls whether orphans are prohibited in the first paragraph of |
| 256 |
% a \quo/ environment. |
| 257 |
% |
| 258 |
% \item[noorphanafter]\SpecialOptIndex{noorphanafter} A boolean option |
| 259 |
% that controls whether orphans are prohibited directly after a \quo/ |
| 260 |
% environment. |
| 261 |
% |
| 262 |
% \item[noorphans]\SpecialOptIndex{noorphans} A shortcut boolean option |
| 263 |
% enabling both \textsf{noorphanfirst} and \textsf{noorphanafter}. |
| 264 |
% |
| 265 |
% \end{description} |
| 266 |
% |
| 267 |
% \DescribeMacro{\quotingsetup} |
| 268 |
% The command |\quotingsetup|, which takes a comma-separated list of |
| 269 |
% key--value options as argument, allows to change the attributes of the |
| 270 |
% \quo/ environment mid-document. |
| 271 |
% |
| 272 |
% \DescribeMacro{\quotingfont} |
| 273 |
% The options \textsf{font} and \textsf{font+} do not accept values |
| 274 |
% which itself take an argument. In such cases you must resort to |
| 275 |
% redefining the command |\quotingfont|, e.g. by including |
| 276 |
% |\renewcommand*{\quotingfont}{\setstretch{1.5}}| in your document |
| 277 |
% preamble (with the \textsf{setspace} package loaded). |
| 278 |
% |
| 279 |
% \StopEventually{% |
| 280 |
% |
| 281 |
% \bibliographystyle{plain} |
| 282 |
% |
| 283 |
% \begin{thebibliography}{9} |
| 284 |
% |
| 285 |
% \bibitem{Bra09} |
| 286 |
% Braams, Johannes, David Carlisle, Alan Jeffrey, Leslie Lamport, |
| 287 |
% Frank Mittelbach, Chris Rowley, and Rainer Sch\"opf. |
| 288 |
% \emph{The \LaTeXe\ sources}. |
| 289 |
% 2009/09/24. |
| 290 |
% \url{http://www.tug.org/texlive/Contents/live/texmf-dist/doc/latex/base/source2e.pdf} |
| 291 |
% (accessed August 2, 2011). |
| 292 |
% |
| 293 |
% \bibitem{dec09} |
| 294 |
% ``\textbackslash DeclareStringOption''. |
| 295 |
% Series of messages on \textsf{comp.text.tex}, December 14, 2009. |
| 296 |
% \url{http://groups.google.com/group/comp.text.tex/browse_thread/thread/1fb53938ac0026c5} |
| 297 |
% (accessed September 6, 2011). |
| 298 |
% |
| 299 |
% \bibitem{Fis95} |
| 300 |
% Fischel, William~A. |
| 301 |
% \emph{Regulatory takings: Law, economics, and politics}. |
| 302 |
% Cambridge, \textsc{ma}: Harvard University Press, 1995. |
| 303 |
% |
| 304 |
% \bibitem{Kop04} |
| 305 |
% Kopka, Helmut and Patrick~W. Daly. |
| 306 |
% \emph{Guide to \LaTeX}. 4\textsuperscript{th} edition. |
| 307 |
% Boston: Addison-Wesley, 2004. |
| 308 |
% |
| 309 |
% \bibitem{Kot11} |
| 310 |
% Kottwitz, Stefan. |
| 311 |
% \emph{\LaTeX\ beginner's guide}. |
| 312 |
% Birmingham: Packt Publishing, 2011. |
| 313 |
% |
| 314 |
% \bibitem{Lam94} |
| 315 |
% Lamport, Leslie. |
| 316 |
% \emph{\LaTeX: A document preparation system}. |
| 317 |
% 2\textsuperscript{nd} edition. |
| 318 |
% Boston: Addison-Wesley, 1994. |
| 319 |
% |
| 320 |
% \bibitem{Oet11} |
| 321 |
% Oetiker, Tobias, Hubert Partl, Irene Hyna, and Elisabeth Schlegl. |
| 322 |
% \emph{The not so short introduction to \LaTeXe}. |
| 323 |
% Version 5.01, April 6, 2011. |
| 324 |
% \url{http://mirror.ctan.org/info/lshort/english/lshort.pdf} |
| 325 |
% (accessed August 2, 2011). |
| 326 |
% |
| 327 |
% \end{thebibliography} |
| 328 |
% |
| 329 |
% \PrintIndex |
| 330 |
% \PrintChanges |
| 331 |
% |
| 332 |
% } |
| 333 |
% |
| 334 |
% \section{The package code} |
| 335 |
% |
| 336 |
% Announce the name and version of the package, which requires \LaTeXe. |
| 337 |
% \begin{macrocode} |
| 338 |
\NeedsTeXFormat{LaTeX2e} |
| 339 |
\ProvidesPackage{quoting} |
| 340 |
[2014/01/28 v0.1c Consolidated environment for displayed text] |
| 341 |
% \end{macrocode} |
| 342 |
% We require the packages \textsf{kvoptions} (to conveniently specify |
| 343 |
% options as key--value pairs) and \textsf{etoolbox} (e.g. for length |
| 344 |
% assignments and boolean switch handling). |
| 345 |
% \begin{macrocode} |
| 346 |
\RequirePackage{etoolbox,kvoptions} |
| 347 |
% \end{macrocode} |
| 348 |
% We use \texttt{quo@} as a short prefix to internal macros defined by |
| 349 |
% \textsf{kvoptions}. |
| 350 |
% \begin{macrocode} |
| 351 |
\SetupKeyvalOptions{family=quo,prefix=quo@} |
| 352 |
% \end{macrocode} |
| 353 |
% \begin{macro}{\quo@indentfirsttype} |
| 354 |
% The key \textsf{indentfirst} takes a list of three values with |
| 355 |
% associated functions and yields an error message if an unknown value |
| 356 |
% is given. We use code snippets presented by Heiko Oberdiek and Joseph |
| 357 |
% Wright in a series of messages on \textsf{comp.text.tex} \cite{dec09}. |
| 358 |
% \begin{macrocode} |
| 359 |
\def\quo@in@false{\def\quo@indentfirsttype{0}} |
| 360 |
\def\quo@in@true{\def\quo@indentfirsttype{1}} |
| 361 |
\def\quo@in@auto{\def\quo@indentfirsttype{2}} |
| 362 |
\define@key{quo}{indentfirst}{% |
| 363 |
\ifcsname quo@in@#1\endcsname |
| 364 |
\csname quo@in@#1\expandafter\endcsname |
| 365 |
\else |
| 366 |
\PackageError{quoting}{Unknown value #1 for option indentfirst}% |
| 367 |
\fi |
| 368 |
} |
| 369 |
\setkeys{quo}{indentfirst=auto} |
| 370 |
% \end{macrocode} |
| 371 |
% \end{macro} |
| 372 |
% |
| 373 |
% \changes{v0.1c}{2014/01/28}{Options \textsf{font} and \textsf{font+} |
| 374 |
% now work if a class (e.g. \textsf{scrbook}, \textsf{scrreprt}) or |
| 375 |
% another package uses \texttt{\textbackslash let\textbackslash |
| 376 |
% do\textbackslash relax}} |
| 377 |
% |
| 378 |
% \begin{macro}{\quotingfont} |
| 379 |
% The \textsf{keyval} command |\define@key| is used to define the keys |
| 380 |
% \textsf{font} and \textsf{font+}. With the help of |\docsvlist| |
| 381 |
% (provided by \textsf{etoolbox}), we convert their comma-separated list |
| 382 |
% of values to commands and use these commands to define |\quotingfont| |
| 383 |
% resp. to append its definition. We use |\def\do| so that the options |
| 384 |
% will also work if a class (e.g. \textsf{scrbook}, \textsf{scrreprt}) |
| 385 |
% or another package uses |\let\do\relax|. |
| 386 |
% \begin{macrocode} |
| 387 |
\newcommand*{\quotingfont}{} |
| 388 |
\define@key{quo}{font}{% |
| 389 |
\def\quotingfont{}% |
| 390 |
\def\do##1{\appto{\quotingfont}{\csname ##1\endcsname}}% |
| 391 |
\docsvlist{#1}% |
| 392 |
} |
| 393 |
\define@key{quo}{font+}{% |
| 394 |
\def\do##1{\appto{\quotingfont}{\csname ##1\endcsname}}% |
| 395 |
\docsvlist{#1}% |
| 396 |
} |
| 397 |
% \end{macrocode} |
| 398 |
% \end{macro} |
| 399 |
% \begin{macro}{\quo@begintext} |
| 400 |
% \begin{macro}{\quo@endtext} |
| 401 |
% \begin{macro}{\quo@leftmargin} |
| 402 |
% \begin{macro}{\quo@rightmargin} |
| 403 |
% We use \textsf{kvoptions} to define the keys \textsf{begintext}, |
| 404 |
% \textsf{endtext}, \textsf{leftmargin}, and \textsf{rightmargin} and to |
| 405 |
% set default values for the latter two. |
| 406 |
% \begin{macrocode} |
| 407 |
\DeclareStringOption{begintext} |
| 408 |
\DeclareStringOption{endtext} |
| 409 |
\DeclareStringOption[\leftmargin]{leftmargin} |
| 410 |
\DeclareStringOption[\quo@leftmargin]{rightmargin} |
| 411 |
% \end{macrocode} |
| 412 |
% \end{macro} |
| 413 |
% \end{macro} |
| 414 |
% \end{macro} |
| 415 |
% \end{macro} |
| 416 |
% \begin{macro}{\quo@toppartop} |
| 417 |
% \begin{macro}{\quo@vskip} |
| 418 |
% The length |\quo@toppartop| is set to the sum of |\topsep| and |
| 419 |
% |\partopsep| and used as the default value of the key \textsf{vskip}. |
| 420 |
% \begin{macrocode} |
| 421 |
\newlength{\quo@toppartop} |
| 422 |
\deflength{\quo@toppartop}{\topsep + \partopsep} |
| 423 |
\DeclareStringOption[\quo@toppartop]{vskip} |
| 424 |
% \end{macrocode} |
| 425 |
% \end{macro} |
| 426 |
% \end{macro} |
| 427 |
% We define the boolean options \textsf{listvskip}, |
| 428 |
% \textsf{noorphanfirst}, and \textsf{noorphanafter}. |
| 429 |
% \begin{macrocode} |
| 430 |
\DeclareBoolOption{listvskip} |
| 431 |
\DeclareBoolOption{noorphanfirst} |
| 432 |
\DeclareBoolOption{noorphanafter} |
| 433 |
% \end{macrocode} |
| 434 |
% The shortcut boolean option \textsf{noorphans} will pass its value to |
| 435 |
% |quo@noorphanfirst| and |quo@noorphanafter|. We then process our |
| 436 |
% options. |
| 437 |
% \begin{macrocode} |
| 438 |
\define@key{quo}{noorphans}[true]{% |
| 439 |
\setbool{quo@noorphanfirst}{#1}% |
| 440 |
\setbool{quo@noorphanafter}{#1}% |
| 441 |
} |
| 442 |
\ProcessKeyvalOptions* |
| 443 |
% \end{macrocode} |
| 444 |
% \begin{macro}{\quotingsetup} |
| 445 |
% We define |\quotingsetup| as an alias of |\setkeys{quo}|. |
| 446 |
% \begin{macrocode} |
| 447 |
\newcommand*{\quotingsetup}[1]{\setkeys{quo}{#1}} |
| 448 |
% \end{macrocode} |
| 449 |
% \end{macro} |
| 450 |
% The boolean switch |quo@afterquo| stores whether we are immediately |
| 451 |
% (without a paragraph in between) following a \quo/ environment; the |
| 452 |
% |quo@afterquoclub| switch stores whether an orphan is permitted after |
| 453 |
% the environment. (For the latter task, we don't use |
| 454 |
% |quo@noorphanafter| directly because its state needs to be forwarded |
| 455 |
% outside the group established by the current environment.) |
| 456 |
% \begin{macrocode} |
| 457 |
\newbool{quo@afterquo} |
| 458 |
\newbool{quo@afterquoclub} |
| 459 |
% \end{macrocode} |
| 460 |
% \begin{macro}{\quo@doendquoclub} |
| 461 |
% If the |quo@afterquoclub| switch is set to false, |\quo@doendquoclub| |
| 462 |
% will set |\clubpenalty| to 10\,000. It will restore |\everypar| and |
| 463 |
% the default value of |\clubpenalty| in the next paragraph. |
| 464 |
% \begin{macrocode} |
| 465 |
\newcommand*{\quo@doendquoclub}{% |
| 466 |
\ifbool{quo@afterquoclub}{% |
| 467 |
\clubpenalty=\@clubpenalty |
| 468 |
\everypar{}% |
| 469 |
}{% |
| 470 |
\booltrue{quo@afterquoclub}% |
| 471 |
\clubpenalty=\@M |
| 472 |
}% |
| 473 |
} |
| 474 |
% \end{macrocode} |
| 475 |
% \end{macro} |
| 476 |
% \begin{macro}{\quo@doendquo} |
| 477 |
% The macro |\quo@doendquo| is an extended version of the \LaTeX\ kernel |
| 478 |
% macro |\@doendpe|. In the original, |
| 479 |
% \blockcquote[p.~227]{Bra09}{\textins*{t}o suppress the paragraph |
| 480 |
% indentation in text immediately following a paragraph-making |
| 481 |
% environment, \texttt{\textbackslash everypar} is changed to remove the |
| 482 |
% space, and \texttt{\textbackslash par} is redefined to restore |
| 483 |
% \texttt{\textbackslash everypar}.} |\quo@doendquo| adds the following |
| 484 |
% changes to |\par|/|\everypar| over and above |\@doendpe|: |
| 485 |
% \begin{itemize} |
| 486 |
% |
| 487 |
% \item |\quo@doendquoclub| is executed; |
| 488 |
% |
| 489 |
% \item At the end, the |quo@afterquo| switch is globally set to false. |
| 490 |
% |
| 491 |
% \end{itemize} |
| 492 |
% \begin{macrocode} |
| 493 |
\newcommand*{\quo@doendquo}{% |
| 494 |
\booltrue{@endpe}% |
| 495 |
\def\par{% |
| 496 |
\@restorepar |
| 497 |
\everypar{\quo@doendquoclub}% |
| 498 |
\par |
| 499 |
\boolfalse{@endpe}% |
| 500 |
\global\boolfalse{quo@afterquo}% |
| 501 |
}% |
| 502 |
\everypar{% |
| 503 |
{\setbox\z@\lastbox}% |
| 504 |
\quo@doendquoclub |
| 505 |
\boolfalse{@endpe}% |
| 506 |
\global\boolfalse{quo@afterquo}% |
| 507 |
}% |
| 508 |
} |
| 509 |
% \end{macrocode} |
| 510 |
% \end{macro} |
| 511 |
% \begin{environment}{quoting} |
| 512 |
% The definition of the \quo/ environment includes an optional argument |
| 513 |
% which may be used to change package settings locally. |
| 514 |
% \begin{macrocode} |
| 515 |
\newenvironment{quoting}[1][]{% |
| 516 |
\setkeys{quo}{#1}% |
| 517 |
% \end{macrocode} |
| 518 |
% \end{environment} |
| 519 |
% We start a \textsf{list} environment and (unless the boolean switch |
| 520 |
% \textsf{listvskip} is set to true) use the value of \textsf{vskip} for |
| 521 |
% vertical spacing. |
| 522 |
% \begin{macrocode} |
| 523 |
\list{}{% |
| 524 |
\ifbool{quo@listvskip}{% |
| 525 |
}{% |
| 526 |
\setlength{\topsep}{\quo@vskip}% |
| 527 |
\setlength{\partopsep}{\z@}% |
| 528 |
}% |
| 529 |
% \end{macrocode} |
| 530 |
% The length |\itemindent| is responsible for the first-line indentation |
| 531 |
% of \quo/. Its value (0\,pt or |\parindent|) is controlled first and |
| 532 |
% foremost by the state of the key \textsf{indentfirst} (\textsf{false}, |
| 533 |
% \textsf{true}, or \textsf{auto}). In case automatic first-line |
| 534 |
% indentation is enabled, |\itemindent| will be set to |\parindent| |
| 535 |
% if the following conditions are met: |
| 536 |
% \begin{itemize} |
| 537 |
% |
| 538 |
% \item We are in vertical mode (which usually means that a blank line |
| 539 |
% or a |\par| command is present before the environment~-- but see |
| 540 |
% below); |
| 541 |
% |
| 542 |
% \item The boolean switch |quo@afterquo| is set to false (i.\,e., |
| 543 |
% vertical mode does not stem from a preceding \quo/ environment of the |
| 544 |
% same depth); |
| 545 |
% |
| 546 |
% \item The \LaTeX\ kernel switch |@nobreak| is either set to false (the |
| 547 |
% \quo/ environment does not directly follow a sectioning command), or |
| 548 |
% both |@nobreak| and |@afterindent| are set to true. |
| 549 |
% |
| 550 |
% \end{itemize} |
| 551 |
% \begin{macrocode} |
| 552 |
\ifcase\quo@indentfirsttype\relax |
| 553 |
\setlength{\itemindent}{\z@}% |
| 554 |
\or |
| 555 |
\setlength{\itemindent}{\parindent}% |
| 556 |
\or |
| 557 |
\setlength{\itemindent}{% |
| 558 |
\ifbool{vmode}{% |
| 559 |
\ifbool{quo@afterquo}{% |
| 560 |
\z@ |
| 561 |
}{% |
| 562 |
\ifbool{@nobreak}{% |
| 563 |
\ifbool{@afterindent}{% |
| 564 |
\parindent |
| 565 |
}{% |
| 566 |
\z@ |
| 567 |
}% |
| 568 |
}{% |
| 569 |
\parindent |
| 570 |
}% |
| 571 |
}% |
| 572 |
}{% |
| 573 |
\z@ |
| 574 |
}% |
| 575 |
}% |
| 576 |
\fi |
| 577 |
% \end{macrocode} |
| 578 |
% The lengths |\leftmargin|, |\rightmargin|, |\listparindent|, and |
| 579 |
% |\parsep| are set, the latter two in accordance with the settings for |
| 580 |
% the surrounding text. |
| 581 |
% \begin{macrocode} |
| 582 |
\setlength{\leftmargin}{\quo@leftmargin}% |
| 583 |
\setlength{\rightmargin}{\quo@rightmargin}% |
| 584 |
\setlength{\listparindent}{\parindent}% |
| 585 |
\setlength{\parsep}{\parskip}% |
| 586 |
}% |
| 587 |
% \end{macrocode} |
| 588 |
% We issue the necessary |\item| command, disable orphans in the |
| 589 |
% environment's first paragraph when indicated, and switch to |
| 590 |
% |\quotingfont|. (With regard to orphans, we make use of |\@item|'s |
| 591 |
% internal mechanism to prevent orphans directly after sectioning |
| 592 |
% commands \cite[p.~229]{Bra09}.) Lastly, we typeset the replacement |
| 593 |
% text of the \textsf{begintext} key. |
| 594 |
% \begin{macrocode} |
| 595 |
\item\relax |
| 596 |
\ifbool{quo@noorphanfirst}{% |
| 597 |
\global\booltrue{@nobreak}% |
| 598 |
}{% |
| 599 |
}% |
| 600 |
\quotingfont |
| 601 |
\quo@begintext\ignorespaces |
| 602 |
% \end{macrocode} |
| 603 |
% |
| 604 |
% \changes{v0.1c}{2014/01/28}{\quo/ is now permitted to close with a |
| 605 |
% list environment plus a blank line} |
| 606 |
% |
| 607 |
% At the end of \quo/, we typeset the replacement text of |
| 608 |
% \textsf{endtext}. (We also remove any preceding space if we are in |
| 609 |
% horizontal mode; this does not apply if, e.g., the \quo/ environment |
| 610 |
% closes with a list environment like \textsf{itemize} or |
| 611 |
% \textsf{enumerate} plus a blank line.) After that, the following |
| 612 |
% actions are taken: |
| 613 |
% \begin{itemize} |
| 614 |
% |
| 615 |
% \item The \LaTeX\ kernel switch |@endpe| is set to false (so that |
| 616 |
% |\@doendpe| won't be executed); |
| 617 |
% |
| 618 |
% \item The state of the |quo@noorphanafter| switch is forwarded outside |
| 619 |
% the current group (using \TeX\ syntax); |
| 620 |
% |
| 621 |
% \item |quo@afterquo| is globally set to true; |
| 622 |
% |
| 623 |
% \item |\quo@doendquo| is executed after the current group. |
| 624 |
% |
| 625 |
% \end{itemize} |
| 626 |
% \begin{macrocode} |
| 627 |
}{% |
| 628 |
\ifbool{hmode}{% |
| 629 |
\unskip |
| 630 |
}{% |
| 631 |
}% |
| 632 |
\quo@endtext |
| 633 |
\endlist |
| 634 |
\boolfalse{@endpe}% |
| 635 |
\ifbool{quo@noorphanafter}{% |
| 636 |
\aftergroup\quo@afterquoclubfalse |
| 637 |
}{% |
| 638 |
\aftergroup\quo@afterquoclubtrue |
| 639 |
}% |
| 640 |
\global\booltrue{quo@afterquo}% |
| 641 |
\aftergroup\quo@doendquo |
| 642 |
} |
| 643 |
% \end{macrocode} |
| 644 |
% The end of the package. |
| 645 |
% \begin{macrocode} |
| 646 |
\endinput |
| 647 |
% \end{macrocode} |
| 648 |
% |
| 649 |
% \Finale |
| 650 |
\endinput |