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 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367
|
% \iffalse meta-comment
%
% Copyright (C) 2014 by José Romildo Malaquias <malaquias@gmail.com>
% ---------------------------------------------------------------------------
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is José Romildo Malaquias.
%
% This work consists of the files efbox.dtx and efbox.ins
% and the derived filebase efbox.sty.
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{efbox.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{efbox}
%<*package>
[2014/03/19 1.0 An enhanced fbox command.]
%</package>
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{efbox}[2014/03/19]
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage[final]{showexpl}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\lstset{%
language=[LaTeX]TeX,
basicstyle=\ttfamily\small,
breaklines=true,
backgroundcolor=\color{lightgray},
breakautoindent=true,
}
\begin{document}
\DocInput{efbox.dtx}
\PrintChanges
% \PrintIndex
\end{document}
%</driver>
% \fi
%
% \CheckSum{0}
%
% \CharacterTable
% {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
% 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
% Digits \0\1\2\3\4\5\6\7\8\9
% Exclamation \! Double quote \" Hash (number) \#
% Dollar \$ Percent \% Ampersand \&
% Acute accent \' Left paren \( Right paren \)
% Asterisk \* Plus \+ Comma \,
% Minus \- Point \. Solidus \/
% Colon \: Semicolon \; Less than \<
% Equals \= Greater than \> Question mark \?
% Commercial at \@ Left bracket \[ Backslash \\
% Right bracket \] Circumflex \^ Underscore \_
% Grave accent \` Left brace \{ Vertical bar \|
% Right brace \} Tilde \~}
%
%
% \changes{v0.1}{2011/12/22}{Converted to DTX file.}
%
% \changes{v1.0}{2014/03/28}{Many changes in preparation for release.}
%
% \DoNotIndex{\newcommand,\newenvironment}
% \DoNotIndex{\def,\ifpdf,\begin}
% \DoNotIndex{\DeclareOption,\ExecuteOptions,\RequirePackage}
% \DoNotIndex{\renewcommand,\else,\fi,\relax,\@bsphack,\@esphack}
% \DoNotIndex{\active,\AtEndOfPackage,\catcode,\centering}
% \DoNotIndex{\closeout,\comment,\do,\dospecials,\end,\endcomment}
% \DoNotIndex{\fbox,\gdef,\immediate,\includegraphics,\let}
% \DoNotIndex{\linewidth,\message,\newif,\newwrite,\openout}
% \DoNotIndex{\PackageWarning,\space,\the,\verbatim@line}
% \DoNotIndex{\verbatim@processline,\verbatim@start,\write}
% \DoNotIndex{\@makeother,\IfFileExists,\ProcessOptions}
% \DoNotIndex{\@ifnextchar,\define@key,\MessageBreak,\setkeys}
% \DoNotIndex{\stepcounter,\newcounter,\trivlist,\AtEndDocument}
% \DoNotIndex{\@empty,\edef,\csname,\endcsname,\edef,\begingroup}
% \DoNotIndex{\endgroup,\endtrivlist,\global,\if,\ifx,\item}
% \DoNotIndex{\PackageWarningNoLine,\PassOptionsToPackage}
% \DoNotIndex{\ProvidesPackage,\@arabic}
%
% \providecommand*{\url}{\texttt}
% \GetFileInfo{efbox.dtx}
% \title{The \textsf{efbox} package}
% \author{José Romildo Malaquias \\ \url{malaquias@gmail.com}}
% \date{\fileversion~from \filedate}
%
% \maketitle
%
% \section{Introduction}
%
% The \texttt{efbox} package defines the command \texttt{efbox}, which
% is an enhanced version of the \texttt{fbox} command. It creates a box
% just wide enough to hold the text created by its argument, allowing to
% draw a frame around the outside of the box at the chosen borders, and
% to set a background color for the box.
%
% \section{Usage}
%
% In order to use the package, just load it in the preamble of your
% document:
% \begin{verbatim}
% \usepackage{efbox}
% \end{verbatim}
%
% \DescribeMacro{\efbox}
%
% The macro \verb|efbox| can be used to create a horizontal box just
% wide enough to hold the text created by its argument (like the
% \verb|makebox| macro). Additionaly a frame can be drawn around the
% outside of the box (like the \verb|fbox| macro) at the chosen
% borders. Also it can set a background color for the box.
% \begin{quote}
% \verb|\efbox[|\meta{keyword}$=$\meta{value}\verb|...]{|\meta{text}\verb|}|
% \end{quote}
%
% The available keywords are:
% \begin{description}
% \item[\normalfont\texttt{leftline}:] This is a boolean, either true
% or false; the default is true. If true, a line is drawn in the left
% border of the box.
%
% \item[\normalfont\texttt{rightline}:] This is a boolean, either true
% or false; the default is true. If true, a line is drawn in the right
% border of the box.
%
% \item[\normalfont\texttt{topline}:] This is a boolean, either true
% or false; the default is true. If true, a line is drawn in the top
% border of the box.
%
% \item[\normalfont\texttt{bottomline}:] This is a boolean, either
% true or false; the default is true. If true, a line is drawn in the
% bottom border of the box.
%
% \item[\normalfont\texttt{hidealllines}:] This is a boolean, either
% true or false; the default is false. If true, no line is drawn in
% the borders of the box.
%
% \item[\normalfont\texttt{backgroundcolor=}\meta{backgroundcolor}:]
% \meta{backgroundcolor} is the color used as the background for the
% box. The default is the current background color.
%
% \item[\normalfont\texttt{linecolor=}\meta{linecolor}:]
% \meta{linecolor} is the color used for the border lines. The default
% is black.
%
% \item[\normalfont\texttt{linewidth=}\meta{linewidth}:]
% \meta{linewidth} is the width of the lines drawn at the borders of
% the box. The default is \verb|\fboxrule|.
%
% \item[\normalfont\texttt{margin=}\meta{margin}:] \meta{margin} is
% the distance between the border lines and the box text. The default
% is \verb|\fboxsep|.
%
% \item[\normalfont\texttt{font=}\meta{font}:] \meta{font} is the font
% used to typeset the text in the box. The default is the current
% font.
%
% \item[\normalfont\texttt{baselinestretch=}\meta{baselinestretch}:]
% \meta{baselinestretch} is the base line stretch. There is no
% default.
% \end{description}
%
% \DescribeMacro{\efboxsetup}
%
% The macro \verb|efboxsetup| can be used to set options used by
% \verb|\efbox|.
% \begin{quote}
% \verb|\efboxsetup{|\meta{keyword}$=$\meta{value}\verb|...]|
% \end{quote}
% The available keyworkds are the same from the \verb|\efbox| macro.
%
% \StopEventually{}
%
% \section{Examples}
%
% This is a demonstration of the \texttt{efbox} macro.
%
% \iffalse
%<*example>
% \fi
% \begin{LTXexample}[pos=b,numbers=none]
\efbox{Foo}
\efbox[rightline=false,topline=false]{Foo}
\efbox[topline,backgroundcolor=red]{Foo}
\efbox[linewidth=2pt,font=\Large]{Large Foo}
\efbox[rightline=false,topline=false,linecolor=blue,linewidth=2pt]{Foo}
\efbox[margin=10pt,backgroundcolor=yellow,font=\ttfamily\itshape]{Italic Typewriter Foo}
\efbox[linewidth=3pt,margin=5pt,backgroundcolor=red]{Foo}
\efbox[hidealllines,backgroundcolor=red]{Foo}
\efbox{Foo}
\efbox[hidealllines,backgroundcolor=red,margin=15pt]{Foo}
\efbox[margin=15pt,linewidth=5pt]{Foo}
\efbox[bottomline=false,rightline=false,linewidth=2pt,margin=1pt,backgroundcolor=yellow]{Foo}
\efbox{Foo}
% \end{LTXexample}
% \iffalse
%</example>
% \fi
%
% \section{Implementation}
%
% \iffalse
%<*package>
% \fi
%
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{efbox}[2014/03/19 v1.0 An enhanced fbox command]
\RequirePackage{color}
\RequirePackage{pgfkeys}
\newif\if@efbox@leftline
\newif\if@efbox@rightline
\newif\if@efbox@topline
\newif\if@efbox@bottomline
\pgfkeys{
/efbox/.cd,
leftline/.is if = @efbox@leftline,
rightline/.is if = @efbox@rightline,
topline/.is if = @efbox@topline,
bottomline/.is if = @efbox@bottomline,
hidealllines/.style = {leftline=false,rightline=false,topline=false,bottomline=false},
backgroundcolor/.store in = \efbox@backgroundcolor,
linecolor/.store in = \efbox@linecolor,
linewidth/.store in = \efbox@linewidth,
margin/.store in = \efbox@margin,
font/.store in = \efbox@font,
baselinestretch/.store in = \efbox@baselinestretch,
}
\pgfqkeys{/efbox}{
leftline = true,
rightline = true,
topline = true,
bottomline = true,
linecolor = black,
linewidth = \fboxrule,
margin = \fboxsep,
}
\newif\if@efbox@hasframe
% \end{macrocode}
%
% \begin{macro}{\efboxsetup}
% \begin{macrocode}
\def\efbox@global@options{}
\newcommand\efboxsetup[1]{%
\def\efbox@global@options{#1}%
}%
\newcommand*\mypgfqkeys@with@saved@options[3]{%
% #1 => path
% #2 => macro holding saved options
% #3 => keys
\def\@pgfqkeys@##1{\pgfqkeys{#1}{##1}}%
\expandafter\@pgfqkeys@\expandafter{#2,#3}%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\efbox}
% \begin{macrocode}
\newcommand\efbox[2][]{%
\begingroup%
\mypgfqkeys@with@saved@options{/efbox}{\efbox@global@options}{#1}%
%\expandafter\pgfqkeys\expandafter{/efbox}\expandafter{\efbox@global@options,#1}%
% \end{macrocode}
%
% \begin{macrocode}
\ifdefined\efbox@font\efbox@font\fi
% \end{macrocode}
%
% \begin{macrocode}
\ifdefined\efbox@baselinestretch
\def\baselinestretch{\efbox@baselinestretch}%
\fi
% \end{macrocode}
%
% \begin{macrocode}
\@efbox@hasframefalse
\if@efbox@topline\@efbox@hasframetrue\else\fi
\if@efbox@bottomline\@efbox@hasframetrue\else\fi
\if@efbox@leftline\@efbox@hasframetrue\else\fi
\if@efbox@rightline\@efbox@hasframetrue\else\fi
\ifdefined\efbox@backgroundcolor\@efbox@hasframetrue\else\fi
\if@efbox@hasframe
\ifdefined\efbox@backgroundcolor\else\def\efbox@backgroundcolor{white}\fi
\fboxsep=\efbox@margin
\fboxrule=\efbox@linewidth
\let\@frameb@x\@my@frameb@x
\fboxsep=\efbox@margin
\def\efbox@body{\fcolorbox{\efbox@linecolor}{\efbox@backgroundcolor}{#2}}%
\else
\def\efbox@body{#2}%
\fi
\ifdefined\efbox@title
\ifx\@empty\efbox@title
\noindent\efbox@body
\else
\vbox{%
\nobreak\vskip\fboxsep
\rlap{\frametitle{\efbox@title}}%
\nobreak\nointerlineskip
\vskip-\baselineskip
\vskip \fboxsep
\noindent\efbox@body
}%
\fi
\else
\efbox@body
\fi
\endgroup
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@my@frameb@x}
% \begin{macrocode}
\def\@my@frameb@x#1{%
\@tempdima\fboxrule
\advance\@tempdima\fboxsep
\advance\@tempdima\dp\@tempboxa
\hbox{%
\lower\@tempdima\hbox{%
\vbox{%
\if@efbox@topline\hrule\@height\fboxrule\fi
\hbox{%
\if@efbox@leftline\vrule\@width\fboxrule\fi
#1%
\vbox{%
\vskip\fboxsep
\box\@tempboxa
\vskip\fboxsep}%
#1%
\if@efbox@rightline\vrule\@width\fboxrule\fi
}%
\if@efbox@bottomline\hrule\@height\fboxrule\fi
}%
}%
}%
}%
\endinput
% \end{macrocode}
% \end{macro}
%
%
% \iffalse
%</package>
% \fi
%
% \Finale
\endinput
|