Skip to content

Instantly share code, notes, and snippets.

Created March 4, 2012 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1971055 to your computer and use it in GitHub Desktop.
Save anonymous/1971055 to your computer and use it in GitHub Desktop.
framed box
\documentclass[10pt]{article}
\usepackage{fullwidth,lipsum,xcolor}
\RequirePackage{pgf}[2008/01/15]
\overfullrule0pt
\pgfkeys{/combo/.is family}
\makeatletter
\pgfkeys{/combo
vrule-height/.store in=\vrule@height,
vrule-height/.default=10pt,
vrule-thickness/.store in=\vrule@thickness,
vrule-thickness/.default=.4pt,
hrule-thickness/.store in=\hrule@thickness,
hrule-thickness/.default=0.4pt,
text-color/.store in=\text@color,
text-color/.default=black,
rule-color/.store in=\rule@color,
rule-color/.default=purple,
left-padding/.store in=\left@padding,
left-padding/.default=10pt,
right-padding/.store in=\right@padding,
right-padding/.default=10pt,
top-padding/.store in=\top@padding,
top-padding/.default=5pt,
bottom-padding/.store in=\bottom@padding,
bottom-padding/.default=5pt,
}
\def\setdefaults{\pgfkeys{/combo
vrule-height,vrule-thickness,hrule-thickness,
text-color, left-padding,right-padding,
top-padding,bottom-padding,rule-color}%
}
\setdefaults
\newcommand\startbox[1][\setdefaults]{%
\bgroup
\pgfkeys{/combo #1}%
\hfuzz\maxdimen\vfuzz\maxdimen
\def\VR{\hskip-\parindent
\vrule height\vrule@height width\vrule@thickness}%
\leavevmode%
{\color\rule@color%
\hrule height\hrule@thickness depth0pt\relax%
\vbox to -0.4pt{\VR}}%
\vskip\top@padding%
\leftskip\left@padding\relax
\rightskip\right@padding\relax%
}
\def\stopbox{%
{\color\rule@color
\vskip\bottom@padding
\vskip-\vrule@height
\hskip\dimexpr\hsize-\left@padding-\vrule@thickness\relax
\VR
\hrule width\hsize}%
\egroup
\par
}
\begin{document}
Here is introductory text.
\begin{fullwidth}[outermargin = -3cm, width = \linewidth +3.0cm]
\startbox[vrule-height=12pt,bottom-padding=5pt,left-padding=10pt,right-padding=10pt]
\lipsum[1-2]
\stopbox
\end{fullwidth}
Here is concluding text.\lipsum[1-2]
\startbox[vrule-height=12pt,bottom-padding=5pt,left-padding=30pt,right-padding=30pt]
\lipsum[1-2]
\stopbox
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment