Debian Codegraph @

texmf-dist/doc/latex/framed/framed.tex

raw
1 \documentclass[DIV=8, pagesize=auto]{scrartcl}
2
3 \usepackage{fixltx2e}
4 \usepackage{etex}
5 \usepackage{lmodern}
6 \usepackage[T1]{fontenc}
7 \usepackage{textcomp}
8 \usepackage{array}
9 \usepackage{booktabs}
10 \usepackage{microtype}
11 \usepackage[unicode=true]{hyperref}
12
13 \newcommand*{\mail}[1]{\href{mailto:#1}{\texttt{#1}}}
14 \newcommand*{\pkg}[1]{\textsf{#1}}
15 \newcommand*{\cs}[1]{\texttt{\textbackslash#1}}
16 \makeatletter
17 \newcommand*{\cmd}[1]{\cs{\expandafter\@gobble\string#1}}
18 \makeatother
19 \newcommand*{\env}[1]{\texttt{#1}}
20 \newcommand*{\opt}[1]{\texttt{#1}}
21 \newcommand*{\meta}[1]{\textlangle\textsl{#1}\textrangle}
22 \newcommand*{\marg}[1]{\texttt{\{}\meta{#1}\texttt{\}}}
23
24 \addtokomafont{title}{\rmfamily}
25
26 \title{The \pkg{framed} package\thanks{This manual corresponds to \pkg{framed}~v0.96, dated~2011/10/22.}}
27 \author{Donald Arseneau (\mail{[email protected]})}
28 \date{2012/05/31}
29
30
31 \begin{document}
32
33 \maketitle
34
35 \noindent
36 Create framed, shaded, or differently highlighted regions that can
37 break across pages. The environments defined are
38
39 \medskip
40 \noindent
41 \begin{tabular}{@{}>{\ttfamily}l@{~~--~~}l@{}}
42 framed & ordinary frame box (\cmd{\fbox}) with edge at margin \\
43 oframed & framed with open top/bottom at page breaks \\
44 shaded & shaded background (\cmd{\colorbox}) bleeding into margin \\
45 shaded* & shaded background (\cmd{\colorbox}) with edge at margin \\
46 snugshade & shaded with tight fit around text (esp. in lists) \\
47 snugshade*& like snugshade with shading edge at margin \\
48 leftbar & thick vertical line in left margin \\
49 titled-frame & frame with title-bar; template for others
50 \end{tabular}
51 \medskip
52
53 \noindent
54 to be used like
55 %
56 \begin{verbatim}
57 \begin{framed}
58 copious text
59 \end{framed}
60 \end{verbatim}
61
62
63 But the more general purpose of this package is to facilitate the
64 definition of new environments that take multi-line material,
65 wrap it with some non-breakable formatting (some kind of box or
66 decoration) and allow page breaks in the material. Such environments
67 are defined to declare (or use) \cmd{\FrameCommand} for applying the boxy
68 decoration, and \cmd{\MakeFramed}\marg{settings} \ldots\ \cmd{\endMakeFramed}
69 wrapped around the main text (environment body).
70
71 The ``\env{framed}'' environment uses \cmd{\fbox}, by default, as its \cmd{\FrameCommand}
72 with the additional settings \verb+\fboxrule=\FrameRule+ and \verb+\fboxsep=\FrameSep+.
73 You can change these lengths (using \cmd{\setlength}) and you can change
74 the definition of \cmd{\FrameCommand} to use much fancier boxes.
75
76 In fact, the ``\env{shaded}'' environment just redefines \cmd{\FrameCommand} to be
77 \verb+\colorbox{shadecolor}+ (and you have to define the color ``\texttt{shadecolor}'':
78 \verb+\definecolor{shadecolor}...+).
79
80 Although the intention is for other packages to define the varieties
81 of decoration, a command \cmd{\OpenFbox} is defined for frames with open
82 tops or bottoms, and used for the ``\env{oframed}'' environment. This
83 facility is based on a more complex and capable command \cmd{\CustomFBox} which can
84 be used for a wider range of frame styles. One such style of a title-bar
85 frame with continuation marks is provided as an example. It is used by
86 the ``\env{titled-frame}'' environment. To make use of \env{titled-frame} in your
87 document, or the \cmd{\TitleBarFrame} command in your own environment
88 definitions, you must define the colors \texttt{TFFrameColor} (for the frame)
89 and a contrasting \texttt{TFTitleColor} (for the title text).
90
91 A page break is allowed, and even encouraged, before the \env{framed}
92 and other environments. If you want to attach some text (a box title) to the
93 frame, then the text should be inserted by \cmd{\FrameCommand} so it cannot
94 be separated from the body.
95
96 The contents of the framed regions are restricted:
97 Floats, footnotes, marginpars and head-line entries will be lost.
98 (Some of these may be handled in a later version.)
99 This package will not work with the page breaking of \pkg{multicol.sty},
100 or other systems that perform column-balancing.
101
102 The \env{MakeFramed} environment does the work. Its ``\meta{settings}'' argument
103 should contain any adjustments to the text width (via a setting of \cmd{\hsize}).
104 Here, the parameter \cmd{\width} gives the measured extra width
105 added by the frame, so a common setting is ``\verb+\advance\hsize-\width+''
106 which reduces the width of the text just enough that the outer edge
107 of the frame aligns with the margins. The ``\meta{settings}'' should also
108 include a `restore' command -- \cmd{\@parboxrestore} or \cmd{\FrameRestore}
109 or something similar; for instance, the snugshade environment uses
110 settings to eliminate list indents and vertical space, but uses
111 \cmd{\hspace} in its \cmd{\FrameCommand} to reproduce the list margin ouside the
112 shading.
113
114 There are actually four variants of \cmd{\FrameCommand} to allow different
115 formatting for each part of an environment broken over pages. Unbroken
116 text is adorned by \cmd{\FrameCommand}, whereas split text first uses
117 \cmd{\FirstFrameCommand}, possibly followed by \cmd{\MidFrameCommand}, and
118 finishing with \cmd{\LastFrameCommand}. The default definitions for
119 these three just invokes \cmd{\FrameCommand}, so that all portions are
120 framed the same way. See the \env{oframe} environment for use of distinct
121 First/Mid/Last frames.
122
123 \section*{Expert commands:}
124
125 \begin{itemize}
126 \item \cmd{\MakeFramed}, \cmd{\endMakeFramed}: the ``\env{MakeFramed}'' environment
127 \item \cmd{\FrameCommand}: command to draw the frame around its argument
128 \item \cmd{\FirstFrameCommand}: the frame for the first part of a split environment
129 \item \cmd{\LastFrameCommand}: frame for the last portion
130 \item \cmd{\MidFrameCommand}: for any intermediate segments
131 \item \cmd{\FrameRestore}: restore some text settings, but fewer than \cmd{\@parbox\-restore}
132 \item \cmd{\FrameRule}: length register; \cmd{\fboxrule} for default ``\env{framed}''.
133 \item \cmd{\FrameSep}: length register; \cmd{\fboxsep} for default ``\env{framed}''.
134 \item \cmd{\FrameHeightAdjust}: macro; height of frame above baseline at top of page
135 \item \cmd{\OuterFrameSep}: vertical space before and after the framed env.; defaults to \cmd{\topsep}
136 \end{itemize}
137
138 \medskip
139 This is still a `pre-production' version because I can think of many
140 features/improvements that should be made. Also, a detailed manual needs
141 to be written. Nevertheless, starting with version~0.5 it should be bug-free.
142
143
144 \section*{ToDo:}
145
146 \begin{itemize}
147 \item Test more varieties of list
148 \item Improve and correct documentation
149 \item Propagation of \cmd{\marks}
150 \item Handle footnotes (how??) floats (?) and marginpars.
151 \item Stretchability modification.
152 \end{itemize}
153
154 \end{document}