summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/sectionbox/sectionbox.sty
blob: 4649a70c085e8c41a9fc3dea202b153c3ea46e3c (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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
%% 
%% This is file `sectionbox.sty' v 1.01
%%
%% Author Michael H.F. Wilkinson 
%%   October 13, 2005
%% 
%% version 1.01, 2005/10/13:
%%               - widths of section boxes reduced by 2\colboxsep+3\fboxrule
%%                 which makes them properly flush with the current column 
%%                 width
%% version 1.00, 2005/08/24:
%%               - first release
%% 
%% 
\ProvidesPackage{sectionbox}[2005/10/13, v1.01 section boxes for posters (MHFW)]
\NeedsTeXFormat{LaTeX2e}[1995/06/01]

\RequirePackage{ifthen}
\RequirePackage{calc}
\RequirePackage{fancybox}
\RequirePackage{color}

\definecolor{sectboxrulecol}{rgb}{0,0,0}
\definecolor{sectboxfillcol}{rgb}{0.9,0.9,0.9}
\definecolor{sectboxtextcol}{rgb}{0,0,0}

\definecolor{subsectboxrulecol}{rgb}{0,0,0}
\definecolor{subsectboxfillcol}{rgb}{0.9,0.9,0.9}
\definecolor{subsectboxtextcol}{rgb}{0,0,0}

\definecolor{subsubsectboxrulecol}{rgb}{0,0,0}
\definecolor{subsubsectboxfillcol}{rgb}{0.9,0.9,0.9}
\definecolor{subsubsectboxtextcol}{rgb}{0,0,0}

\newlength{\sectboxskip}                          % skip below sectionbox
\setlength{\sectboxskip}{0.5ex plus0.1ex minus 0.5ex}
\newlength{\subsectboxskip}                       % skip below subsectionbox
\setlength{\subsectboxskip}{0.25ex plus0.1ex minus 0.25ex}
\newlength{\subsubsectboxskip}                    % skip below subsubsectionbox
\setlength{\subsubsectboxskip}{0.25ex plus0.1ex minus 0.25ex}
\newlength{\subsectmargin}                   %
\setlength{\subsectmargin}{0pt} 
\newlength{\subsubsectmargin}                   %
\setlength{\subsubsectmargin}{0pt} 

\newcommand{\makesectionbox}[1]{\fbox{#1}}         % default single frame box
\newcommand{\makesubsectionbox}[1]{\fbox{#1}}      % default single frame box
\newcommand{\makesubsubsectionbox}[1]{\fbox{#1}}   % default single frame box

\newcommand{\framesectionbox}{                     % set section boxes to single frame boxes
  \renewcommand{\makesectionbox}[1]{\fbox{##1}}
  \setlength{\sectboxskip}{0.5ex plus0.1ex minus 0.5ex}       
                                                   % set back to default
}

\newcommand{\framesubsectionbox}{                  % set section boxes to single frame boxes
  \renewcommand{\makesubsectionbox}[1]{\fbox{##1}}
  \setlength{\subsectboxskip}{0.25ex plus0.1ex minus 0.25ex0.5}    
                                                   % set back to default
  \setlength{\subsectmargin}{0pt} 
}

\newcommand{\framesubsubsectionbox}{               % set section boxes to single frame boxes
  \renewcommand{\makesubsubsectionbox}[1]{\fbox{##1}}
  \setlength{\subsubsectboxskip}{0.25ex plus0.1ex minus 0.25ex} 
                                                   % set back to default
  \setlength{\subsubsectmargin}{0pt} 
}

\newcommand{\doublesectionbox}{                    % set section boxes to double boxes
  \renewcommand{\makesectionbox}[1]{\doublebox{##1}}
  \setlength{\sectboxskip}{0.5ex plus0.1ex minus 0.5ex}       % set back to default
}

\newcommand{\doublesubsectionbox}{                 % set section boxes to double boxes
  \renewcommand{\makesubsectionbox}[1]{\doublebox{##1}}
  \setlength{\subsectboxskip}{0.25ex plus0.1ex minus 0.25ex}       
                                                   % set back to default
  \setlength{\subsectmargin}{0pt} 
}

\newcommand{\doublesubsubsectionbox}{              % set section boxes to double boxes
  \renewcommand{\makesubsubsectionbox}[1]{\doublebox{##1}}
  \setlength{\subsubsectboxskip}{0.25ex plus0.1ex minus 0.25ex}       % set back to default
  \setlength{\subsubsectmargin}{0pt} 
}

\newcommand{\shadowsectionbox}{                    % set section boxes to shadow boxes
  \renewcommand{\makesectionbox}[1]{\shadowbox{##1}}
  \setlength{\sectboxskip}{-2ex plus0.1ex minus 0.5ex}      % counteract effects of shadowbox
}

\newcommand{\shadowsubsectionbox}{          % set section boxes to shadow boxes
  \renewcommand{\makesubsectionbox}[1]{\shadowbox{##1}}
  \setlength{\subsectboxskip}{-2.25ex plus0.1ex minus 0.25ex}      
                                            % counteract effects of shadowbox
  \setlength{\subsectmargin}{\shadowsize} 
}

\newcommand{\shadowsubsubsectionbox}{                    % set section boxes to shadow boxes
  \renewcommand{\makesubsubsectionbox}[1]{\shadowbox{##1}}
  \setlength{\subsubsectboxskip}{-2.25ex plus0.1ex minus 0.25ex}  
                                             % counteract effects of shadowbox
  \setlength{\subsubsectmargin}{\shadowsize} 
}


\newsavebox{\sectsavebox}                          % saves contents of section box
\newsavebox{\subsectsavebox}                       % saves contents of subsection box
\newsavebox{\subsubsectsavebox}                    % saves contents of subsubsection box

\ifthenelse{\lengthtest{\paperwidth <\paperheight}}{% compute \fboxrule etc. 
  \setlength{\fboxrule}{0.0014\paperwidth}          % portrait mode
  \setlength{\shadowsize}{0.0042\paperwidth}
}{%
  \setlength{\fboxrule}{0.0014\paperheight}         % landscape mode
  \setlength{\shadowsize}{0.0042\paperheight}
}
\newlength{\colboxsep}                       % store value for \fcolsep for use in 
\setlength{\colboxsep}{2\fboxrule}            % the \colorbox 

\newenvironment{sectionbox}[2][\columnwidth]{% default width of minipage is \columnwidth
\setlength{\fboxsep}{0.5\fboxrule}% ensures colorbox is filled up to  
%                                   boundary of sectionbox 
\begin{lrbox}{\sectsavebox}                  % open lrbox and save in \sectsavebox
\begin{minipage}{#1-2\colboxsep-3\fboxrule}
\color{sectboxtextcol}%
\ifthenelse{\equal{#2}{}}{}{\section{#2}}%  only produce section if
%                                            mandatory parameter not empty
}{%
\end{minipage}                               
\end{lrbox}                                  % close lrbox
  \color{sectboxrulecol}                     % sets color of boundary
  \noindent
  \makesectionbox{\setlength{\fboxsep}{\colboxsep}\colorbox{sectboxfillcol}{\usebox{\sectsavebox}}}               
  \\[\sectboxskip]
}

\newenvironment{subsectionbox}[2][\columnwidth]{% default width of minipage is \columnwidth
\setlength{\fboxsep}{0.5\fboxrule}% ensures colorbox is filled up to  
%                                   boundary of sectionbox 
\begin{lrbox}{\subsectsavebox}                  % open lrbox and save in \subsectsavebox
\begin{minipage}{#1 -\subsectmargin - 2\colboxsep - 3\fboxrule}
\color{subsectboxtextcol}%
\ifthenelse{\equal{#2}{}}{}{\subsection{#2}}    % only produce subsection if
%                                                 mandatory parameter not empty
}{%
\end{minipage}                               
\end{lrbox}                                  % close lrbox
  \color{subsectboxrulecol}                     % sets color of boundary
  \noindent
  \makesubsectionbox{\setlength{\fboxsep}{\colboxsep}\colorbox{subsectboxfillcol}{\usebox{\subsectsavebox}}}               
  \\[\subsectboxskip]
}

\newenvironment{subsubsectionbox}[2][\columnwidth]{% default width of minipage is \columnwidth
\setlength{\fboxsep}{0.5\fboxrule}% ensures colorbox is filled up to  
%                                   boundary of sectionbox 
\begin{lrbox}{\subsubsectsavebox}                  % open lrbox and save in \subsectsavebox
\begin{minipage}{#1 -\subsubsectmargin - 2\colboxsep - 3\fboxrule}
\color{subsubsectboxtextcol}%
\ifthenelse{\equal{#2}{}}{}{\subsubsection{#2}}    % only produce subsection if
%                                                 mandatory parameter not empty
}{%
\end{minipage}                               
\end{lrbox}                                  % close lrbox
  \color{subsubsectboxrulecol}                     % sets color of boundary
  \noindent
  \makesubsubsectionbox{\setlength{\fboxsep}{\colboxsep}\colorbox{subsubsectboxfillcol}{\usebox{\subsubsectsavebox}}}               
  \\[\subsubsectboxskip]
}