3

I want to make the center of \fbox{$1+4=5$} be horizontally aligned with the \uparrow. However, it seems that the following code does not work (see the figure below). BTW, is it possible to replace *{3}{c@{\quad\quad}} with *{3}{c@{\enspace}} and still make the center of \fbox{$1+4=5$} be horizontally aligned with the \uparrow? I would appreciate your help with this situation.

\documentclass[a5paper,12pt]{book}
\usepackage{amsmath,amssymb}
\usepackage{array}

\begin{document}

\begin{equation*}
\begin{array}{c@{\quad} *{3}{c@{\quad\quad}}}
        &   & 3         & 6     \\
\times  &   &           & 7     \\ \hline
        & 2 & 5         & 2     \\
        &   & \uparrow  &       \\
        & \multicolumn{3}{c}{\fbox{$1+4=5$}} 
\end{array}
\end{equation*}

\end{document}

enter image description here

4
  • wouldn't it be simpler to put it in the same column as 5 and the arrow, \framebox[0pt]{$1+4=5$} ? and not use multicolumn at all? (otherwise just use the same @{..} as in the main tabular specification. Commented Feb 7, 2021 at 13:02
  • @DavidCarlisle: Doesn't this screw up the frame of the framebox?
    – leandriis
    Commented Feb 7, 2021 at 13:04
  • Although this slightly alters the spaces between the columns as compared to the original, the following should center the framebox correctly: \begin{equation*} \setlength{\arraycolsep}{1em} \begin{array}{*{4}{c}} & & 3 & 6 \\ \times & & & 7 \\ \hline & 2 & 5 & 2 \\ & & \uparrow & \\ & \multicolumn{3}{c}{\fbox{$1+4=5$}} \end{array} \end{equation*}
    – leandriis
    Commented Feb 7, 2021 at 13:05
  • 1
    @leandriis er perhaps makebox[0pt] around an fbox Commented Feb 7, 2021 at 14:09

2 Answers 2

4

You're forgetting that the template has c@{\quad\quad}

\documentclass[a5paper,12pt]{book}
\usepackage{amsmath,amssymb}
\usepackage{array}

\begin{document}

\begin{equation*}
\begin{array}{c@{\quad} *{3}{c@{\quad\quad}}}
        &   & 3         & 6     \\
\times  &   &           & 7     \\ \hline
        & 2 & 5         & 2     \\
        &   & \uparrow  &       \\
        & \multicolumn{3}{c@{\quad\quad}}{\boxed{1+4=5}} 
\end{array}
\end{equation*}

\end{document}

enter image description here

Actually, the centering is not perfect, due to the asymmetry in column spacing and you can fix it by adding some negative space to compensate:

\documentclass[a5paper,12pt]{book}
\usepackage{amsmath,amssymb}
\usepackage{array}

\begin{document}

\begin{equation*}
\begin{array}{c@{\quad} *{3}{c@{\quad\quad}}}
        &   & 3         & 6     \\
\times  &   &           & 7     \\ \hline
        & 2 & 5         & 2     \\
        &   & \uparrow  &       \\
        & \multicolumn{3}{c@{\quad\quad}}{\hspace{-0.5em}\boxed{1+4=5}} 
\end{array}
\end{equation*}

\end{document}

enter image description here

However, the simplest way is to center it with a zero width box:

\documentclass[a5paper,12pt]{book}
\usepackage{amsmath,amssymb}
\usepackage{array}

\begin{document}

\begin{equation*}
\begin{array}{c@{\quad} *{3}{c@{\quad\quad}}}
        &   & 3         & 6     \\
\times  &   &           & 7     \\ \hline
        & 2 & 5         & 2     \\
        &   & \uparrow  &       \\
        &   & \makebox[0pt]{$\boxed{1+4=5}$} 
\end{array}
\end{equation*}

\end{document}

enter image description here

5

With use of the w{c}{2em} for the last three columns:

\documentclass[a5paper,12pt]{book}
%\usepackage{amsmath,amssymb}
\usepackage{array}

\begin{document}
    \[
\begin{array}{c *{3}{w{c}{2em}} }
        &   & 3         & 6     \\
\times  &   &           & 7     \\ \hline
        & 2 & 5         & 2     \\
        &   & \uparrow  &   \\
        & \multicolumn{3}{@{} c @{}}{\fbox{$1+4=5$}}
\end{array}
    \]
\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 .