summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/quoting/quoting.sty
blob: 120ed1fed5bc0b375fb65196a748280f40682103 (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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
%%
%% This is file `quoting.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% quoting.dtx  (with options: `package')
%% 
%% Copyright (C) 2011--2012 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}
    [2012/02/21 v0.1b Consolidated environment for displayed text]
\RequirePackage{etoolbox,kvoptions}
\SetupKeyvalOptions{family=quo,prefix=quo@}
\def\quo@in@false{\def\quo@indentfirsttype{0}}
\def\quo@in@true{\def\quo@indentfirsttype{1}}
\def\quo@in@auto{\def\quo@indentfirsttype{2}}
\define@key{quo}{indentfirst}{%
  \ifcsname quo@in@#1\endcsname
    \csname quo@in@#1\expandafter\endcsname
  \else
    \PackageError{quoting}{Unknown value #1 for option indentfirst}%
  \fi
}
\setkeys{quo}{indentfirst=auto}
\newcommand*{\quotingfont}{}
\define@key{quo}{font}{%
  \def\quotingfont{}%
  \renewcommand*{\do}[1]{\appto{\quotingfont}{\csname ##1\endcsname}}%
  \docsvlist{#1}%
}
\define@key{quo}{font+}{%
  \renewcommand*{\do}[1]{\appto{\quotingfont}{\csname ##1\endcsname}}%
  \docsvlist{#1}%
}
\DeclareStringOption{begintext}
\DeclareStringOption{endtext}
\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@}%
    }%
    \ifcase\quo@indentfirsttype\relax
      \setlength{\itemindent}{\z@}%
    \or
      \setlength{\itemindent}{\parindent}%
    \or
      \setlength{\itemindent}{%
        \ifbool{vmode}{%
          \ifbool{quo@afterquo}{%
            \z@
          }{%
            \ifbool{@nobreak}{%
              \ifbool{@afterindent}{%
                \parindent
              }{%
                \z@
              }%
            }{%
              \parindent
            }%
          }%
        }{%
          \z@
        }%
      }%
    \fi
    \setlength{\leftmargin}{\quo@leftmargin}%
    \setlength{\rightmargin}{\quo@rightmargin}%
    \setlength{\listparindent}{\parindent}%
    \setlength{\parsep}{\parskip}%
  }%
  \item\relax
  \ifbool{quo@noorphanfirst}{%
    \global\booltrue{@nobreak}%
  }{%
  }%
  \quotingfont
  \quo@begintext\ignorespaces
}{%
  \unskip\quo@endtext
  \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'.