| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2014 by José Romildo Malaquias <[email protected]> |
| 4 |
% --------------------------------------------------------------------------- |
| 5 |
% This work may be distributed and/or modified under the |
| 6 |
% conditions of the LaTeX Project Public License, either version 1.3 |
| 7 |
% of this license or (at your option) any later version. |
| 8 |
% The latest version of this license is in |
| 9 |
% http://www.latex-project.org/lppl.txt |
| 10 |
% and version 1.3 or later is part of all distributions of LaTeX |
| 11 |
% version 2005/12/01 or later. |
| 12 |
% |
| 13 |
% This work has the LPPL maintenance status `maintained'. |
| 14 |
% |
| 15 |
% The Current Maintainer of this work is José Romildo Malaquias. |
| 16 |
% |
| 17 |
% This work consists of the files efbox.dtx and efbox.ins |
| 18 |
% and the derived filebase efbox.sty. |
| 19 |
% |
| 20 |
% \fi |
| 21 |
% |
| 22 |
% \iffalse |
| 23 |
%<*driver> |
| 24 |
\ProvidesFile{efbox.dtx} |
| 25 |
%</driver> |
| 26 |
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] |
| 27 |
%<package>\ProvidesPackage{efbox} |
| 28 |
%<*package> |
| 29 |
[2014/03/19 1.0 An enhanced fbox command.] |
| 30 |
%</package> |
| 31 |
% |
| 32 |
%<*driver> |
| 33 |
\documentclass{ltxdoc} |
| 34 |
\usepackage{efbox}[2014/03/19] |
| 35 |
\usepackage[utf8]{inputenc} |
| 36 |
\usepackage{xcolor} |
| 37 |
\usepackage[final]{showexpl} |
| 38 |
\EnableCrossrefs |
| 39 |
\CodelineIndex |
| 40 |
\RecordChanges |
| 41 |
\lstset{% |
| 42 |
language=[LaTeX]TeX, |
| 43 |
basicstyle=\ttfamily\small, |
| 44 |
breaklines=true, |
| 45 |
backgroundcolor=\color{lightgray}, |
| 46 |
breakautoindent=true, |
| 47 |
} |
| 48 |
\begin{document} |
| 49 |
\DocInput{efbox.dtx} |
| 50 |
\PrintChanges |
| 51 |
% \PrintIndex |
| 52 |
\end{document} |
| 53 |
%</driver> |
| 54 |
% \fi |
| 55 |
% |
| 56 |
% \CheckSum{0} |
| 57 |
% |
| 58 |
% \CharacterTable |
| 59 |
% {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 |
| 60 |
% 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 |
| 61 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 62 |
% Exclamation \! Double quote \" Hash (number) \# |
| 63 |
% Dollar \$ Percent \% Ampersand \& |
| 64 |
% Acute accent \' Left paren \( Right paren \) |
| 65 |
% Asterisk \* Plus \+ Comma \, |
| 66 |
% Minus \- Point \. Solidus \/ |
| 67 |
% Colon \: Semicolon \; Less than \< |
| 68 |
% Equals \= Greater than \> Question mark \? |
| 69 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 70 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 71 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 72 |
% Right brace \} Tilde \~} |
| 73 |
% |
| 74 |
% |
| 75 |
% \changes{v0.1}{2011/12/22}{Converted to DTX file.} |
| 76 |
% |
| 77 |
% \changes{v1.0}{2014/03/28}{Many changes in preparation for release.} |
| 78 |
% |
| 79 |
% \DoNotIndex{\newcommand,\newenvironment} |
| 80 |
% \DoNotIndex{\def,\ifpdf,\begin} |
| 81 |
% \DoNotIndex{\DeclareOption,\ExecuteOptions,\RequirePackage} |
| 82 |
% \DoNotIndex{\renewcommand,\else,\fi,\relax,\@bsphack,\@esphack} |
| 83 |
% \DoNotIndex{\active,\AtEndOfPackage,\catcode,\centering} |
| 84 |
% \DoNotIndex{\closeout,\comment,\do,\dospecials,\end,\endcomment} |
| 85 |
% \DoNotIndex{\fbox,\gdef,\immediate,\includegraphics,\let} |
| 86 |
% \DoNotIndex{\linewidth,\message,\newif,\newwrite,\openout} |
| 87 |
% \DoNotIndex{\PackageWarning,\space,\the,\verbatim@line} |
| 88 |
% \DoNotIndex{\verbatim@processline,\verbatim@start,\write} |
| 89 |
% \DoNotIndex{\@makeother,\IfFileExists,\ProcessOptions} |
| 90 |
% \DoNotIndex{\@ifnextchar,\define@key,\MessageBreak,\setkeys} |
| 91 |
% \DoNotIndex{\stepcounter,\newcounter,\trivlist,\AtEndDocument} |
| 92 |
% \DoNotIndex{\@empty,\edef,\csname,\endcsname,\edef,\begingroup} |
| 93 |
% \DoNotIndex{\endgroup,\endtrivlist,\global,\if,\ifx,\item} |
| 94 |
% \DoNotIndex{\PackageWarningNoLine,\PassOptionsToPackage} |
| 95 |
% \DoNotIndex{\ProvidesPackage,\@arabic} |
| 96 |
% |
| 97 |
% \providecommand*{\url}{\texttt} |
| 98 |
% \GetFileInfo{efbox.dtx} |
| 99 |
% \title{The \textsf{efbox} package} |
| 100 |
% \author{José Romildo Malaquias \\ \url{[email protected]}} |
| 101 |
% \date{\fileversion~from \filedate} |
| 102 |
% |
| 103 |
% \maketitle |
| 104 |
% |
| 105 |
% \section{Introduction} |
| 106 |
% |
| 107 |
% The \texttt{efbox} package defines the command \texttt{efbox}, which |
| 108 |
% is an enhanced version of the \texttt{fbox} command. It creates a box |
| 109 |
% just wide enough to hold the text created by its argument, allowing to |
| 110 |
% draw a frame around the outside of the box at the chosen borders, and |
| 111 |
% to set a background color for the box. |
| 112 |
% |
| 113 |
% \section{Usage} |
| 114 |
% |
| 115 |
% In order to use the package, just load it in the preamble of your |
| 116 |
% document: |
| 117 |
% \begin{verbatim} |
| 118 |
% \usepackage{efbox} |
| 119 |
% \end{verbatim} |
| 120 |
% |
| 121 |
% \DescribeMacro{\efbox} |
| 122 |
% |
| 123 |
% The macro \verb|efbox| can be used to create a horizontal box just |
| 124 |
% wide enough to hold the text created by its argument (like the |
| 125 |
% \verb|makebox| macro). Additionaly a frame can be drawn around the |
| 126 |
% outside of the box (like the \verb|fbox| macro) at the chosen |
| 127 |
% borders. Also it can set a background color for the box. |
| 128 |
% \begin{quote} |
| 129 |
% \verb|\efbox[|\meta{keyword}$=$\meta{value}\verb|...]{|\meta{text}\verb|}| |
| 130 |
% \end{quote} |
| 131 |
% |
| 132 |
% The available keywords are: |
| 133 |
% \begin{description} |
| 134 |
% \item[\normalfont\texttt{leftline}:] This is a boolean, either true |
| 135 |
% or false; the default is true. If true, a line is drawn in the left |
| 136 |
% border of the box. |
| 137 |
% |
| 138 |
% \item[\normalfont\texttt{rightline}:] This is a boolean, either true |
| 139 |
% or false; the default is true. If true, a line is drawn in the right |
| 140 |
% border of the box. |
| 141 |
% |
| 142 |
% \item[\normalfont\texttt{topline}:] This is a boolean, either true |
| 143 |
% or false; the default is true. If true, a line is drawn in the top |
| 144 |
% border of the box. |
| 145 |
% |
| 146 |
% \item[\normalfont\texttt{bottomline}:] This is a boolean, either |
| 147 |
% true or false; the default is true. If true, a line is drawn in the |
| 148 |
% bottom border of the box. |
| 149 |
% |
| 150 |
% \item[\normalfont\texttt{hidealllines}:] This is a boolean, either |
| 151 |
% true or false; the default is false. If true, no line is drawn in |
| 152 |
% the borders of the box. |
| 153 |
% |
| 154 |
% \item[\normalfont\texttt{backgroundcolor=}\meta{backgroundcolor}:] |
| 155 |
% \meta{backgroundcolor} is the color used as the background for the |
| 156 |
% box. The default is the current background color. |
| 157 |
% |
| 158 |
% \item[\normalfont\texttt{linecolor=}\meta{linecolor}:] |
| 159 |
% \meta{linecolor} is the color used for the border lines. The default |
| 160 |
% is black. |
| 161 |
% |
| 162 |
% \item[\normalfont\texttt{linewidth=}\meta{linewidth}:] |
| 163 |
% \meta{linewidth} is the width of the lines drawn at the borders of |
| 164 |
% the box. The default is \verb|\fboxrule|. |
| 165 |
% |
| 166 |
% \item[\normalfont\texttt{margin=}\meta{margin}:] \meta{margin} is |
| 167 |
% the distance between the border lines and the box text. The default |
| 168 |
% is \verb|\fboxsep|. |
| 169 |
% |
| 170 |
% \item[\normalfont\texttt{font=}\meta{font}:] \meta{font} is the font |
| 171 |
% used to typeset the text in the box. The default is the current |
| 172 |
% font. |
| 173 |
% |
| 174 |
% \item[\normalfont\texttt{baselinestretch=}\meta{baselinestretch}:] |
| 175 |
% \meta{baselinestretch} is the base line stretch. There is no |
| 176 |
% default. |
| 177 |
% \end{description} |
| 178 |
% |
| 179 |
% \DescribeMacro{\efboxsetup} |
| 180 |
% |
| 181 |
% The macro \verb|efboxsetup| can be used to set options used by |
| 182 |
% \verb|\efbox|. |
| 183 |
% \begin{quote} |
| 184 |
% \verb|\efboxsetup{|\meta{keyword}$=$\meta{value}\verb|...]| |
| 185 |
% \end{quote} |
| 186 |
% The available keyworkds are the same from the \verb|\efbox| macro. |
| 187 |
% |
| 188 |
% \StopEventually{} |
| 189 |
% |
| 190 |
% \section{Examples} |
| 191 |
% |
| 192 |
% This is a demonstration of the \texttt{efbox} macro. |
| 193 |
% |
| 194 |
% \iffalse |
| 195 |
%<*example> |
| 196 |
% \fi |
| 197 |
% \begin{LTXexample}[pos=b,numbers=none] |
| 198 |
\efbox{Foo} |
| 199 |
\efbox[rightline=false,topline=false]{Foo} |
| 200 |
\efbox[topline,backgroundcolor=red]{Foo} |
| 201 |
\efbox[linewidth=2pt,font=\Large]{Large Foo} |
| 202 |
\efbox[rightline=false,topline=false,linecolor=blue,linewidth=2pt]{Foo} |
| 203 |
\efbox[margin=10pt,backgroundcolor=yellow,font=\ttfamily\itshape]{Italic Typewriter Foo} |
| 204 |
|
| 205 |
\efbox[linewidth=3pt,margin=5pt,backgroundcolor=red]{Foo} |
| 206 |
\efbox[hidealllines,backgroundcolor=red]{Foo} |
| 207 |
\efbox{Foo} |
| 208 |
\efbox[hidealllines,backgroundcolor=red,margin=15pt]{Foo} |
| 209 |
\efbox[margin=15pt,linewidth=5pt]{Foo} |
| 210 |
\efbox[bottomline=false,rightline=false,linewidth=2pt,margin=1pt,backgroundcolor=yellow]{Foo} |
| 211 |
|
| 212 |
\efbox{Foo} |
| 213 |
% \end{LTXexample} |
| 214 |
% \iffalse |
| 215 |
%</example> |
| 216 |
% \fi |
| 217 |
% |
| 218 |
% \section{Implementation} |
| 219 |
% |
| 220 |
% \iffalse |
| 221 |
%<*package> |
| 222 |
% \fi |
| 223 |
% |
| 224 |
% \begin{macrocode} |
| 225 |
\NeedsTeXFormat{LaTeX2e} |
| 226 |
\ProvidesPackage{efbox}[2014/03/19 v1.0 An enhanced fbox command] |
| 227 |
\RequirePackage{color} |
| 228 |
\RequirePackage{pgfkeys} |
| 229 |
\newif\if@efbox@leftline |
| 230 |
\newif\if@efbox@rightline |
| 231 |
\newif\if@efbox@topline |
| 232 |
\newif\if@efbox@bottomline |
| 233 |
\pgfkeys{ |
| 234 |
/efbox/.cd, |
| 235 |
leftline/.is if = @efbox@leftline, |
| 236 |
rightline/.is if = @efbox@rightline, |
| 237 |
topline/.is if = @efbox@topline, |
| 238 |
bottomline/.is if = @efbox@bottomline, |
| 239 |
hidealllines/.style = {leftline=false,rightline=false,topline=false,bottomline=false}, |
| 240 |
backgroundcolor/.store in = \efbox@backgroundcolor, |
| 241 |
linecolor/.store in = \efbox@linecolor, |
| 242 |
linewidth/.store in = \efbox@linewidth, |
| 243 |
margin/.store in = \efbox@margin, |
| 244 |
font/.store in = \efbox@font, |
| 245 |
baselinestretch/.store in = \efbox@baselinestretch, |
| 246 |
} |
| 247 |
\pgfqkeys{/efbox}{ |
| 248 |
leftline = true, |
| 249 |
rightline = true, |
| 250 |
topline = true, |
| 251 |
bottomline = true, |
| 252 |
linecolor = black, |
| 253 |
linewidth = \fboxrule, |
| 254 |
margin = \fboxsep, |
| 255 |
} |
| 256 |
\newif\if@efbox@hasframe |
| 257 |
% \end{macrocode} |
| 258 |
% |
| 259 |
% \begin{macro}{\efboxsetup} |
| 260 |
% \begin{macrocode} |
| 261 |
\def\efbox@global@options{} |
| 262 |
\newcommand\efboxsetup[1]{% |
| 263 |
\def\efbox@global@options{#1}% |
| 264 |
}% |
| 265 |
\newcommand*\mypgfqkeys@with@saved@options[3]{% |
| 266 |
% #1 => path |
| 267 |
% #2 => macro holding saved options |
| 268 |
% #3 => keys |
| 269 |
\def\@pgfqkeys@##1{\pgfqkeys{#1}{##1}}% |
| 270 |
\expandafter\@pgfqkeys@\expandafter{#2,#3}% |
| 271 |
}% |
| 272 |
% \end{macrocode} |
| 273 |
% \end{macro} |
| 274 |
% |
| 275 |
% \begin{macro}{\efbox} |
| 276 |
% \begin{macrocode} |
| 277 |
\newcommand\efbox[2][]{% |
| 278 |
\begingroup% |
| 279 |
\mypgfqkeys@with@saved@options{/efbox}{\efbox@global@options}{#1}% |
| 280 |
%\expandafter\pgfqkeys\expandafter{/efbox}\expandafter{\efbox@global@options,#1}% |
| 281 |
% \end{macrocode} |
| 282 |
% |
| 283 |
% \begin{macrocode} |
| 284 |
\ifdefined\efbox@font\efbox@font\fi |
| 285 |
% \end{macrocode} |
| 286 |
% |
| 287 |
% \begin{macrocode} |
| 288 |
\ifdefined\efbox@baselinestretch |
| 289 |
\def\baselinestretch{\efbox@baselinestretch}% |
| 290 |
\fi |
| 291 |
% \end{macrocode} |
| 292 |
% |
| 293 |
% \begin{macrocode} |
| 294 |
\@efbox@hasframefalse |
| 295 |
\if@efbox@topline\@efbox@hasframetrue\else\fi |
| 296 |
\if@efbox@bottomline\@efbox@hasframetrue\else\fi |
| 297 |
\if@efbox@leftline\@efbox@hasframetrue\else\fi |
| 298 |
\if@efbox@rightline\@efbox@hasframetrue\else\fi |
| 299 |
\ifdefined\efbox@backgroundcolor\@efbox@hasframetrue\else\fi |
| 300 |
\if@efbox@hasframe |
| 301 |
\ifdefined\efbox@backgroundcolor\else\def\efbox@backgroundcolor{white}\fi |
| 302 |
\fboxsep=\efbox@margin |
| 303 |
\fboxrule=\efbox@linewidth |
| 304 |
\let\@frameb@x\@my@frameb@x |
| 305 |
\fboxsep=\efbox@margin |
| 306 |
\def\efbox@body{\fcolorbox{\efbox@linecolor}{\efbox@backgroundcolor}{#2}}% |
| 307 |
\else |
| 308 |
\def\efbox@body{#2}% |
| 309 |
\fi |
| 310 |
\ifdefined\efbox@title |
| 311 |
\ifx\@empty\efbox@title |
| 312 |
\noindent\efbox@body |
| 313 |
\else |
| 314 |
\vbox{% |
| 315 |
\nobreak\vskip\fboxsep |
| 316 |
\rlap{\frametitle{\efbox@title}}% |
| 317 |
\nobreak\nointerlineskip |
| 318 |
\vskip-\baselineskip |
| 319 |
\vskip \fboxsep |
| 320 |
\noindent\efbox@body |
| 321 |
}% |
| 322 |
\fi |
| 323 |
\else |
| 324 |
\efbox@body |
| 325 |
\fi |
| 326 |
\endgroup |
| 327 |
} |
| 328 |
% \end{macrocode} |
| 329 |
% \end{macro} |
| 330 |
% |
| 331 |
% |
| 332 |
% \begin{macro}{\@my@frameb@x} |
| 333 |
% \begin{macrocode} |
| 334 |
\def\@my@frameb@x#1{% |
| 335 |
\@tempdima\fboxrule |
| 336 |
\advance\@tempdima\fboxsep |
| 337 |
\advance\@tempdima\dp\@tempboxa |
| 338 |
\hbox{% |
| 339 |
\lower\@tempdima\hbox{% |
| 340 |
\vbox{% |
| 341 |
\if@efbox@topline\hrule\@height\fboxrule\fi |
| 342 |
\hbox{% |
| 343 |
\if@efbox@leftline\vrule\@width\fboxrule\fi |
| 344 |
#1% |
| 345 |
\vbox{% |
| 346 |
\vskip\fboxsep |
| 347 |
\box\@tempboxa |
| 348 |
\vskip\fboxsep}% |
| 349 |
#1% |
| 350 |
\if@efbox@rightline\vrule\@width\fboxrule\fi |
| 351 |
}% |
| 352 |
\if@efbox@bottomline\hrule\@height\fboxrule\fi |
| 353 |
}% |
| 354 |
}% |
| 355 |
}% |
| 356 |
}% |
| 357 |
\endinput |
| 358 |
% \end{macrocode} |
| 359 |
% \end{macro} |
| 360 |
% |
| 361 |
% |
| 362 |
% \iffalse |
| 363 |
%</package> |
| 364 |
% \fi |
| 365 |
% |
| 366 |
% \Finale |
| 367 |
\endinput |