[Tex/LaTex] How to make box in a row of a table

tables

I want to make a box in second row. That is on 1 & 3 & 24 & 42 & 43.
Also on part of forth row 5 & 16 & 26 & 34.

 \begin{tabular}{| c | c  c  c  c | } 
      \hline
      Location & \multicolumn{4}{c|}{Rounds}\\ 
       \hline
        0 &  2 &  23 &  41 &  42\\
    1 &  3 &  24 &  42 &  43\\
    2 &  4 &  25 &  43 &  44\\
    3 &  5 &  16 &  26 &  34\\
    4 &  6 &  17 &  27 &  35\\
    \hline
   \end{tabular}

Best Answer

There are better ways, as Werner alludes to, but here is a quick way, if you don't need to use it often (since the box width must be tailored to the content).

I have stuffed it into a macro \boxit{<width>}.

\documentclass{article}
\def\boxit#1{%
  \smash{\fboxsep=0pt\llap{\rlap{\fbox{\strut\makebox[#1]{}}}~}}\ignorespaces
}
\begin{document}
 \begin{tabular}{| c | c  c  c  c | } 
      \hline
      Location & \multicolumn{4}{c|}{Rounds}\\ 
       \hline
        0 &  2 &  23 &  41 &  42\\
    \boxit{1.52in} 1 &  3 &  24 &  42 &  43\\
    2 &  4 &  25 &  43 &  44\\
    3 &  5 &  \boxit{0.81in} 16 &  26 &  34\\
    4 &  6 &  17 &  27 &  35\\
    \hline
   \end{tabular}
\end{document}

enter image description here

If your tabular data is purely numeric, one could trim the height of the box to be symmetric about the numerals (the above solution uses a \strut which allows extra depth for descenders). I also make the box in red, with a thicker (1pt) rule.

\documentclass{article}
\usepackage{xcolor}
\def\boxit#1{%
  \smash{\color{red}\fboxrule=1pt\relax\fboxsep=2pt\relax%
  \llap{\rlap{\fbox{\vphantom{0}\makebox[#1]{}}}~}}\ignorespaces
}
\begin{document}
 \begin{tabular}{| c | c  c  c  c | } 
      \hline
      Location & \multicolumn{4}{c|}{Rounds}\\ 
       \hline
        0 &  2 &  23 &  41 &  42\\
    \boxit{1.47in} 1 &  3 &  24 &  42 &  43\\
    2 &  4 &  25 &  43 &  44\\
    3 &  5 &  \boxit{0.77in} 16 &  26 &  34\\
    4 &  6 &  17 &  27 &  35\\
    \hline
   \end{tabular}
\end{document}

enter image description here