# How to draw a dotted rectangle around part of equation?

1,570

## Solution 1

The dashbox package can be tweaked to do what you want:

\documentclass{article}

\usepackage{dashbox}
\newcommand\emptydottedbox{%
\setlength{\dashlength}{1pt}%     % length of dash + gap
\setlength{\dashdash}{0.5pt}%     % length of dash
\setlength{\fboxrule}{0.5pt}%     % width of line
\setlength{\fboxsep}{0pt}%        % separation between box and inner content
\dbox{\ensuremath{\phantom{x}}}%
}

\begin{document}

$\int_{\emptydottedbox}^{\emptydottedbox} \emptydottedbox$

\end{document}


## Solution 2

With tikz you can draw these boxes:

\documentclass{article}
\usepackage{tikz}
\newcommand{\smallbox}{\begin{tikzpicture}
\draw[thick,dotted] (0,0) rectangle
(0.3, 0.3);
\end{tikzpicture}
}
\newcommand{\medbox}{\begin{tikzpicture}
\draw[thick,dotted] (0,0) rectangle
(0.5, 0.5);
\end{tikzpicture}
}
\begin{document}

$\int_{\smallbox}^{\smallbox} {\medbox}$
\end{document}


Maybe you need to fiddle a bit with the dimensions and/or the spacing.

Share:
1,570

Author by

### Denis Sletkov

Updated on November 18, 2020

• Denis Sletkov over 1 year

I need to produce a following image:

I found a \boxdot symbol in ams package but can not find any dotted box.

• John Kormylo over 5 years
\boxdot (from amssymb) is a box with a dot inside. The easiest way to create a dotted box of a given size is to use TikZ (or possibly graphicx if you have an image).
You might want some more %, try a\emptydottedbox b outside math mode.
You could generalize it, with e.g. \newcommand\DotBox[1][0.3]{\tikz\draw[thick,dotted] (0,0) rectangle (#1,#1);}. (And by the way, you also have a spurious space, add a % right after \end{tikzpicture}, or move the closing brace up.)