Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have an "XYZ's Law" quote that I'd like to show somewhere on a page vertically centered in a box with some form of simple border around it. Basically I'm trying to achieve the LaTeX equivalent of how Norvig's Law is shown at http://norvig.com/norvigs-law.html where there's some text centred and placed inside a bordered box on the page. Can anyone begin to make suggestions on how I'd go about creating something of such an appearance?

I apologize if my use of the term box here overlaps with another use of the term that is specific to LaTeX. I've seen the term box come up a number of times in LaTeX, so I don't know whether it has special meaning within the realms of LaTeX that I've gone and unintentionally overlapped here.

share|improve this question

6 Answers 6

For start, you may want to look at the fancybox package. For some ideas how to create even fancier boxes, look at this tikz example.

share|improve this answer

To get you started, and following Jan's suggestion of using fancybox, you could define an environment such as

\usepackage{fancybox}

\newenvironment{boxedlaw}[1]
  {\begin{Sbox}\begin{minipage}{#1}\centering}
  {\end{minipage}\end{Sbox}\begin{center}\shadowbox{\TheSbox}\end{center}}

...

\begin{boxedlaw}{5cm}
XYZ's Law
\end{boxedlaw}

And really have a look at the documentation from this package for further suggestions as well as other styles of boxes.

share|improve this answer

Metafun/ConTeXt is great at this. See for example chapter 4 in the metafun manual.

share|improve this answer
2  
I think this sort of stuff is overkill for the task in question, but the in-paragraph shading of sentences shown in Chapter 5 are seriously cool. (P.S. wish that manual had PDF bookmarks!) –  Will Robertson Sep 29 '10 at 4:41

For proclamations like such, you can also consider using the ntheorem package, which provides a "framed theorem" environment.

\usepackage{ntheorem}

\theoremstyle{nonumberplain}
\newframedtheorem{XYZLaw}{XYZ's Law}

...

\begin{XYZLaw}
XYZ's law states that blah implies foobar
\end{XYZLaw}
share|improve this answer

You can use adjustbox for this with the following keys:

  • minipage=<width> for the paragraph box.
  • margin=<amount> to add some padding.
  • bgcolor=<color> to set the background color.
  • frame to draw a border around it (Note: option values can be used to adjust it).
    There is also cframe=<color> (again plus optional values) if you want a colored frame.
  • center to center it the current \linewidth.
  • margin=0pt <vskip> to add some vertical skip above and below.

Note that the order of the keys is meaningful.

\documentclass{article}

\usepackage{lipsum}% For dummy text to show centering
\usepackage{xcolor}
\usepackage{adjustbox}

\begin{document}

\lipsum[1]

\begin{adjustbox}{minipage=200pt,margin=10pt,bgcolor=blue!25,frame,center,margin=0pt \medskipamount}
    \centering\sffamily
{\LARGE Norvig's Law
\par\medskip}
\normalsize
Any technology that surpasses 50\% penetration\\
will \textbf{never} double again\\
(in any number of months)
\end{adjustbox}

\lipsum[2]

\end{document}

Result

share|improve this answer

Previous answers have presented several options to draw framed and colored boxes but tcolorbox was missing. Next there is an example using it.

\documentclass{article}

\usepackage{lipsum}% For dummy text to show centering
\usepackage{xcolor}
\usepackage[skins]{tcolorbox}

\begin{document}

\lipsum[1]

{\par\centering
 \begin{tcolorbox}[enhanced, width=.75\linewidth, 
            colback=blue!50!green!20,
            arc=0pt, outer arc=0pt, 
            borderline={1.5pt}{0pt}{black!90},
            borderline={0.25pt}{3pt}{black!70, sharp corners},
            drop fuzzy shadow]
    \centering
{\LARGE Norvig's Law
\par\medskip}
\normalsize\itshape
Any technology that surpasses 50\% penetration\\
will \textbf{never} double again\\
(in any number of months)
\end{tcolorbox}\par}

\lipsum[2]

\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.