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}

enter image description here

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.

enter image description here

Share:
1,570

Related videos on Youtube

Denis Sletkov
Author by

Denis Sletkov

Updated on November 18, 2020

Comments

  • Denis Sletkov
    Denis Sletkov over 1 year

    I need to produce a following image:

    equation

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

    • John Kormylo
      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).
    • shadowtalker
      shadowtalker over 5 years
      So that's how Microsoft Word makes those boxes in the equation editor!
  • Torbjørn T.
    Torbjørn T. over 5 years
    You might want some more %, try a\emptydottedbox b outside math mode.
  • Torbjørn T.
    Torbjørn T. over 5 years
    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.)
  • Robert Seifert
    Robert Seifert over 5 years
    @TorbjørnT. you're right, thanks. Though it probably won't be used outsite math mode.