Frames

This page walks through ways to draw a frame around a piece of text or a block of paragraphs, from the plain to the powerful. To box a word or a line, the built-in **\fbox{...} and \framebox[width][pos]{...} are enough — but they cannot break across lines or pages. To frame whole paragraphs and still let them flow across a page break, reach for the framed** package (the framed, shaded, and leftbar environments); to frame an equation, amsmath’s **\boxed{...}; and to control color, titles, page breaks, and rounded corners freely, the standard choice is tcolorbox, the most powerful option, built on top of TikZ. We close with mdframed**, another breakable frame.

The built-in frame — \fbox and \framebox

\fbox{...} works with nothing loaded: it draws a thin frame fitted snugly around its argument. When you want to dictate the width or alignment, use \framebox[width][position]{...}. The first optional argument, width, sets the box’s width; the second, position**, sets how the content sits inside it — c (centered, the default), l (flush left), r (flush right), and s (stretched to both edges). \framebox with no options behaves exactly like \fbox.

Two lengths control the look. **\fboxrule is the rule thickness** (default 0.2pt), and **\fboxsep is the padding between the frame and its content** (default 3pt). Both are set with \setlength. To draw a thicker, roomier frame, for instance:

latex
\setlength{\fboxrule}{1pt}
\setlength{\fboxsep}{8pt}
\fbox{ここを枠で囲みます}

\framebox[5cm][l]{左寄せで幅 5cm}

The key caveat: **neither \fbox nor \framebox wraps its content**. Hand it a long passage and it stays on one line, stretching sideways and refusing to break across a line or page. To frame several lines, first wrap the content in a \parbox or minipage and box that (\fbox{\parbox{0.8\linewidth}{…}}), or use one of the paragraph-aware packages below. Note that \fbox is an inline box placed on the baseline, so it lines up naturally with \hspace and other inline material. For minipage and \parbox themselves, see the “Boxes” page.

Framing paragraphs across pages — framed

The framed package, loaded with \usepackage{framed}, fills the gap left by \fbox’s inability to wrap. Its central **framed environment has one defining feature: the boxed material can break across a page, so you can enclose a long admonition or sidebar whole. The companion shaded environment fills a background instead of drawing a rule, and the leftbar environment draws a single vertical rule down the left** (a common marker for quoted blocks).

latex
\usepackage{framed}

\begin{framed}
  この段落は枠で囲まれます。中身が長くてページの
  終わりに達しても、枠は自然に分割されて次のページへ
  続きます。\fbox にはできない芸当です。
\end{framed}

For shaded, set the background by defining the color shadecolor with **\colorlet{shadecolor}{...}** (you must load color or xcolor). Rule thickness and padding are tuned with the lengths **\FrameRule and \FrameSep**, the analogues of \fbox’s. The package also offers derived environments — **oframed (a frame left open at the top and bottom where it breaks), shaded* (a fill aligned to the text width), and snugshade** (a fill hugging the content). Redefining \FrameCommand or using \MakeFramed lets you build your own breakable frames.

framed is light and straightforward, but it does not do rounded corners, shadows, or elaborate titled boxes. When you want those, tcolorbox below is the better fit.

Framing an equation — \boxed

To highlight a final result by boxing it, use amsmath’s **\boxed{...}**. Because \fbox is a text-mode command it misbehaves inside mathematics, whereas \boxed is math-mode only: it typesets its argument as math and then frames it. Load \usepackage{amsmath} and use it inside math mode.

latex
\usepackage{amsmath}

\[
  \boxed{E = mc^2}
\]

The frame \boxed draws is internally an \fbox, so it responds to \fboxrule and \fboxsep. You can box a single line inside an alignment such as align, but for advanced needs — wrapping a frame neatly around an equation number or several lines — the empheq package (shipped with mathtools) is more flexible. For math mode in general, see the “Math mode basics” page.

The most powerful frame — tcolorbox

For nearly every framing need — color, titles, page breaks — **tcolorbox (by Thomas Sturm) delivers. The usual incantation is \usepackage[most]{tcolorbox}**, which enables most of its rich add-on libraries at once (most loads the bulk of them, leaving out the ones that depend on external tools such as minted). Because tcolorbox is built on pgf/TikZ, TikZ does the drawing underneath, and the box inherits its expressive power.

It helps to learn it in three tiers. To drop a single small frame inline, **\tcbox{...}** — a command that fits the box to its content (it behaves like \fbox and does not break) while accepting the full range of color and title options. To enclose a block of paragraphs, the **tcolorbox environment. And to reuse one look repeatedly, \newtcolorbox{mybox}{...} defines a reusable box**.

Color and titles are set through key options. **colback= is the background color, colframe= the frame color, and giving title= turns the box into a titled box (a heading bar). Adding breakable lets the box span pages**; sharp corners (square corners) / rounded corners (the default), boxrule= (rule thickness, default 0.5mm), and arc= (corner radius, default 1.0mm) shape it. The title bar’s color is colbacktitle=, and the heading font is set with fonttitle=.

latex
\usepackage[most]{tcolorbox}

\begin{tcolorbox}[colback=blue!5, colframe=blue!60!black,
                  title=覚え書き, fonttitle=\bfseries, breakable]
  色付きでタイトルの付いた枠です。\texttt{breakable} を
  指定したので、長くなればページをまたいで分割されます。
\end{tcolorbox}

To repeat a look, define the box once in the preamble. The form **\newtcolorbox[init options]{name}[number of args][default]{options}** can, like \newenvironment, create boxes that take arguments. For example, an admonition box that takes its heading as an argument:

document.tex
\usepackage[most]{tcolorbox}
\newtcolorbox{note}[1]{%
  colback=yellow!10, colframe=orange!70!black,
  fonttitle=\bfseries, title=#1, breakable}

\begin{document}
\begin{note}{注意}
  これで \texttt{note} 環境を定義しました。引数で
  見出しを渡せます。
\end{note}
\end{document}

The skins library (included in most) goes further: the enhanced skin switches on TikZ-powered touches such as shadows, double frames, transparency, and decorated titles. There is a theorems library for theorem-like boxes, a two-part mode that places source above output (split with \tcblower), and much more. For the full picture, consult the large manual via texdoc tcolorbox (version 6.9.x as of 2026).

Another option — mdframed

When you want a breakable frame that looks better than framed but you don’t need everything tcolorbox offers, **mdframed** is the middle ground. Load it with \usepackage{mdframed} and enclose content in the **mdframed environment**. Built as an extension of framed, it adds color, rounded corners, and shadows to frames that span pages.

A distinctive feature is the choice of rendering backend: besides plain LaTeX commands, framemethod=TikZ or framemethod=pstricks unlock fancier decoration. Define your own framed environment with \newmdenv{...}, or a framed theorem environment with \newmdtheoremenv{...}. A minimal rounded, colored example:

latex
\usepackage{mdframed}

\begin{mdframed}[backgroundcolor=gray!10, roundcorner=5pt,
                 linecolor=gray!60, linewidth=1pt]
  mdframed の枠です。ページをまたいで折り返せます。
\end{mdframed}

Which one to use

When in doubt, pick by the scale of the job. To box a word or a line quickly, **\fbox / \framebox. To box an equation, \boxed. To merely frame across paragraphs, the lightweight framed. For color, titles, rounded corners, and page breaks, tcolorbox** (with mdframed as the step before it). Color names and mixing live on the “Colors (xcolor)” page, length units and the thinking behind dimensions like \fboxsep on “Lengths & spacing,” and boxes in general (\parbox, minipage, \rule) on the “Boxes” page.

UseWhat it framesBreaks pages?Best for
\fbox / \frameboxOne line of contentNoA word or short line, fast
\boxedMath (in math mode)NoStressing a result
framedBlocks of paragraphsYesFraming paragraphs lightly
mdframedBlocks of paragraphsYesColor/rounded, modestly
tcolorboxBlocks, inline, theoremsYesColor, titles, the full kit