summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/quoting/quoting.sty
blob: 15066be7d1dbf976d72068f6092d202e81f09b39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
%%
%% This is file `quoting.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% quoting.dtx  (with options: `package')
%% 
%% Copyright (C) 2011 by Thomas Titz <thomas.titz@chello.at>
%% 
%% Permission is granted to distribute and/or modify this work under the
%% terms of the LaTeX Project Public License (LPPL), version 1.3c or
%% later.
%% 
%% The LPPL maintenance status of this work is "maintained".
%% 
%% This work consists of the files quoting.dtx, quoting.ins and README
%% and the derived files quoting.pdf and quoting.sty.
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{quoting}
    [2011/08/08 v0.1 Consolidated environment for displayed text]
\RequirePackage{etoolbox,kvoptions}
\SetupKeyvalOptions{family=quo,prefix=quo@}
\newcommand*{\quotingfont}{}
\define@key{quo}{font}{%
  \def\quotingfont{\csname #1\endcsname}%
}
\define@key{quo}{font+}{%
  \appto{\quotingfont}{\csname #1\endcsname}%
}
\DeclareStringOption[\leftmargin]{leftmargin}
\DeclareStringOption[\quo@leftmargin]{rightmargin}
\newlength{\quo@toppartop}
\deflength{\quo@toppartop}{\topsep + \partopsep}
\DeclareStringOption[\quo@toppartop]{vskip}
\DeclareBoolOption{listvskip}
\DeclareBoolOption{noorphanfirst}
\DeclareBoolOption{noorphanafter}
\define@key{quo}{noorphans}[true]{%
  \setbool{quo@noorphanfirst}{#1}%
  \setbool{quo@noorphanafter}{#1}%
}
\ProcessKeyvalOptions*
\newcommand*{\quotingsetup}[1]{\setkeys{quo}{#1}}
\newbool{quo@afterquo}
\newbool{quo@afterquoclub}
\newcommand*{\quo@doendquoclub}{%
  \ifbool{quo@afterquoclub}{%
    \clubpenalty=\@clubpenalty
    \everypar{}%
  }{%
    \booltrue{quo@afterquoclub}%
    \clubpenalty=\@M
  }%
}
\newcommand*{\quo@doendquo}{%
  \booltrue{@endpe}%
  \def\par{%
    \@restorepar
    \everypar{\quo@doendquoclub}%
    \par
    \boolfalse{@endpe}%
    \global\boolfalse{quo@afterquo}%
   }%
  \everypar{%
    {\setbox\z@\lastbox}%
    \quo@doendquoclub
    \boolfalse{@endpe}%
    \global\boolfalse{quo@afterquo}%
  }%
}
\newenvironment{quoting}[1][]{%
  \setkeys{quo}{#1}%
  \list{}{%
    \ifbool{quo@listvskip}{%
    }{%
      \setlength{\topsep}{\quo@vskip}%
      \setlength{\partopsep}{\z@}%
    }%
    \setlength{\itemindent}{%
      \ifbool{vmode}{%
        \ifbool{quo@afterquo}{%
          \z@
        }{%
          \ifbool{@nobreak}{%
            \ifbool{@afterindent}{%
              \parindent
            }{%
              \z@
            }%
          }{%
            \parindent
          }%
        }%
      }{%
        \z@
      }%
    }%
    \setlength{\leftmargin}{\quo@leftmargin}%
    \setlength{\rightmargin}{\quo@rightmargin}%
    \setlength{\listparindent}{\parindent}%
    \setlength{\parsep}{\parskip}%
  }%
  \item\relax
  \ifbool{quo@noorphanfirst}{%
    \global\booltrue{@nobreak}%
  }{%
  }%
  \quotingfont
}{%
  \endlist
  \boolfalse{@endpe}%
  \ifbool{quo@noorphanafter}{%
    \aftergroup\quo@afterquoclubfalse
  }{%
    \aftergroup\quo@afterquoclubtrue
  }%
  \global\booltrue{quo@afterquo}%
  \aftergroup\quo@doendquo
}
\endinput
%%
%% End of file `quoting.sty'.