How to Write Mathematical Expressions in a Box in LaTeX?

Integrating mathematical expressions within a boxed format is a common requirement for effectively presenting and emphasizing key equations, theorems, or proofs in scientific and academic documents. LaTeX, as a powerful typesetting system, offers various methods for encapsulating mathematical content within visually distinct boxes. Understanding how to insert mathematical expressions in a box in LaTeX involves familiarity with specific commands and packages. In this comprehensive blog post, we will delve into the various methods to seamlessly incorporate boxed equations into your LaTeX documents.

Method 1: Using “amsmath” package

In amsmath package, \boxed{} is a direct command for producing mathematical expressions in boxes. Math-mode is used for processing its argument.

In your LaTeX document preamble, include the amsmath package by adding the following line:

\usepackage{amsmath}

Let us take an example in which an equation is written in a box within the text.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

The standard form for a parabola that opens vertically is \boxed{y = a(x - h)^2 + k}. Here, $a$ is the coefficient determining the direction and width of the parabola, and $(h,k)$ is the vertex of the parabola.

\end{document}

Output

Let us take another example to create a boxed equation in an equation environment.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

The standard form for a parabola that opens vertically is
\begin{equation}
\boxed{y = a(x - h)^2 + k}
\end{equation}
Here, $a$ is the coefficient determining the direction and width of the parabola, and $(h,k)$ is the vertex of the parabola.

\end{document}

Output

Method 2: Using “shadow” package

The shadow package in LaTeX adds shadow effects to the boxes. The shadow package is typically included in standard LaTeX distributions, so you don’t need to install it separately. You can download it from the CTAN website if it is unavailable. You can load it in your LaTeX document by adding the following line to your preamble.

\usepackage{shadow}

The shadow package provides a command \shabox{} to create a box with a shadow effect around the content. Here’s a basic example:

\documentclass{article}
\usepackage{shadow}

\begin{document}

The standard form for a parabola that opens vertically is \shabox{$y = a(x - h)^2 + k$}. Here, $a$ is the coefficient determining the direction and width of the parabola, and $(h,k)$ is the vertex of the parabola.

\end{document}

Output

Let us take another example.

\documentclass{article}
\usepackage{shadow}

\begin{document}

The standard form for a parabola that opens vertically is
\begin{equation}
\shabox{$y = a(x - h)^2 + k$}
\end{equation}
Here, $a$ is the coefficient determining the direction and width of the parabola, and $(h,k)$ is the vertex of the parabola.

\end{document}

Output

It creates a shadow box around the equation.

Final Words

Effectively presenting mathematical expressions in boxed formats is essential for highlighting key equations, theorems, or proofs in scientific and academic documents. LaTeX provides various methods to achieve this, offering flexibility and customization options. Incorporating packages like amsmath and shadow, LaTeX users can seamlessly create visually distinct boxed equations with or without shadow effects.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.