3

I am trying to create these number bonds with squares for the numbers but I am not sure how to move the box towards the middle.

enter image description here

\documentclass{article}
\usepackage{enumitem,multicol,xcolor}
\fboxsep=4mm \fboxrule=0.5mm % set these parameters globally

\begin{document}
\begin{multicols}{3}

\begin{enumerate}[label=(\alph*)]
\item $2 + \fcolorbox{black}{white}{\null} = 5$
\item $\fcolorbox{black}{white}{\null} + 2 = 5$

\item $1 + \fcolorbox{black}{white}{\null} = 5$
\item $\fcolorbox{black}{white}{\null} + 1 = 5$

\item $3 + \fcolorbox{black}{white}{\null} = 5$
\item $\fcolorbox{black}{white}{\null} + 3 = 5$
\end{enumerate}

\end{multicols}
\end{document}
2
  • I've taken the liberty of adding instructions to make your code minimally compilable. Feel free to revert.
    – Mico
    Sep 27 at 5:42
  • While it's (of course!) ok to upvote helpful answers immediately, site guidelines explicitly discourage users from "accepting" the first answer that comes along more or less immediately. For by waiting several hours or, ideally, a day or two, before accepting the most helpful answer, you don't discourage other would-be answer providers from posting additional, and possibly even more helpful, answers.
    – Mico
    Sep 27 at 5:57

3 Answers 3

5

Don't use \null as it doesn't have any height. Instead, set a \phantom number; it'll allow you to have a box that roughly matches the size of the contents. Also, define a command that can do all of the adjustments for you; this will make global changes much more easy.

enter image description here

\documentclass{article}

\usepackage{multicol,enumitem}

\newcommand{\boxnum}[1]{{%
  \setlength{\fboxsep}{4mm}%
  \setlength{\fboxrule}{0.5mm}%
  \fbox{\phantom{#1}}%
}}

\begin{document}

\begin{multicols}{3}
  \begin{enumerate}[label=(\alph*)]
    \item $2 + \boxnum{3} = 5$
    \item $\boxnum{3} + 2 = 5$

    \item $1 + \boxnum{4} = 5$
    \item $\boxnum{4} + 1 = 5$

    \item $3 + \boxnum{2} = 5$
    \item $\boxnum{2} + 3 = 5$
  \end{enumerate}
\end{multicols}

\end{document}
2
  • This is great! Thank you so much!
    – user292225
    Sep 27 at 5:54
  • This approach ends up enlarging the frameboxes relative to the OP's setup. Is there a way of avoiding enlarging the frameboxes?
    – Mico
    Sep 27 at 5:55
2

I will assume that by "move the box towards the middle", you want the boxes to be vertically centered on the math axis. (Aside: The math axis is an invisible horizontal line that bisects symbols such as -, =, and +.) Moreover, I will assume that you'd like to achieve this goal without enlarging the frameboxes.

If these assumptions are correct, I suggest you encase the frameboxes in \vcenter{\hbox{...}} wrappers; \vcenter is a command that centers its argument vertically on the math axis.

By the way, I think it's easier to write \boxed{} than \fcolorbox{black}{white}{\null}.

enter image description here

\documentclass{article}
\usepackage{enumitem,multicol,xcolor,amsmath}
\fboxsep=4mm \fboxrule=0.5mm
\newcommand\mybox{%
   \vcenter{\hbox{$\boxed{}$}}} % feel free to come up with a snazzier name
\begin{document}

\noindent \textcolor{red}{Before}
\begin{multicols}{3}
\begin{enumerate}[label=(\alph*)]
\item $2 + \boxed{} = 5$
\item $\boxed{} + 2 = 5$

\item $1 + \boxed{} = 5$
\item $\boxed{} + 1 = 5$

\item $3 + \boxed{} = 5$
\item $\boxed{} + 3 = 5$
\end{enumerate}
\end{multicols}

\bigskip
\noindent \textcolor{red}{After}
\begin{multicols}{3}
\begin{enumerate}[label=(\alph*)]
\item $2 + \mybox = 5$
\item $\mybox + 2 = 5$

\item $1 + \mybox = 5$
\item $\mybox + 1 = 5$

\item $3 + \mybox = 5$
\item $\mybox + 3 = 5$
\end{enumerate}
\end{multicols}

\end{document}
1

Use a phantom of a symbol that's centered along the math axis, such as \sum and, to get a square, measure its height plus depth. Finally, decide about the value of \fboxsep to get the desired width of the square.

\documentclass{article}
\usepackage{enumitem,multicol}

\fboxsep=4mm \fboxrule=0.5mm % set these parameters globally

\newcommand{\fillnumber}{%
  \begingroup
  \setlength{\fboxrule}{0.5mm}%
  \setlength{\fboxsep}{1mm}%
  \sbox0{$\sum$}%
  \fbox{$\vphantom{\sum}$\hspace{\dimeval{\ht0+\dp0}}}%
  \endgroup
}

\begin{document}
\begin{multicols}{3}

\begin{enumerate}[label=(\alph*)]
\item $2 + \fillnumber = 5$
\item $\fillnumber + 2 = 5$

\item $1 + \fillnumber = 5$
\item $\fillnumber + 1 = 5$

\item $3 + \fillnumber = 5$
\item $\fillnumber + 3 = 5$
\end{enumerate}

\end{multicols}
\end{document}

enter image description here

Using tasks is, in my opinion, better than multicols.

\documentclass{article}
\usepackage{tasks}

\fboxsep=4mm \fboxrule=0.5mm % set these parameters globally

\newcommand{\fillnumber}{%
  \begingroup
  \setlength{\fboxrule}{0.5mm}%
  \setlength{\fboxsep}{1mm}%
  \sbox0{$\sum$}%
  \fbox{$\vphantom{\sum}$\hspace{\dimeval{\ht0+\dp0}}}%
  \endgroup
}

\begin{document}

\begin{tasks}(3)
\task $2 + \fillnumber = 5$
\task $\fillnumber + 2 = 5$
\task $1 + \fillnumber = 5$
\task $\fillnumber + 1 = 5$
\task $3 + \fillnumber = 5$
\task $\fillnumber + 3 = 5$
\end{tasks}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .