2

I'm doing list of MAC addresses. I have used tables, but I don't know how to manage the space (before or after) the hexadecimal value.

For one device the different MAC addresses are not properly aligned from each other. There is a slight space that depends on the "size" of the hexadecimal value (I mean, a "11" value is thicker than a "DF"? Therefore the difference shows up if you check the column only).

Here is the code with three tests (from awful to almost good):

  
  \begin{table}[h!]
    \begin{center}
        
        \label{tab:table1}
        \begin{tabular}{l|l|l}
            \textbf{Item} & \textbf{Method} & \textbf{MAC \#}\\
            \hline
            Computer & RJ 1 & 54 B2 03 16 8F 34\\
                     & RJ 2 & 54 B2 03 16 8F 35\\
                     & WiFi & 1C 1B B5 34 07 6A\\
            \hline
            Phone & WiFi & 14 1F 78 35 93 A5\\
            \hline
            Pad & WiFi & D0 59 E4 21 B4 9C\\
            \hline
            Kindle & WiFi & 74 75 48 0D 0A 9C\\
            
        \end{tabular}
  
    \end{center}
  \end{table}

\section{Student 2}
  
  \begin{table}[h!]
    \begin{center}
        
        \label{tab:table2}
        \begin{tabular}{l|l|l@{:}l@{:}l@{:}l@{:}l@{:}l}
            \textbf{Item} & \textbf{Method} & \multicolumn{6}{l}{\textbf{MAC \#}}\\
            \hline
            Computer & RJ 1 & 54 & B2 & 03 & 16 & 8F & 34\\
                     & RJ 2 & 54 & B2 & 03 & 16 & 8F & 35\\
                     & WiFi & 1C & 1B & B5 & 34 & 07 & 6A\\
            \hline
            Phone & WiFi & 14 & 1F & 78 & 35 & 93 & A5\\
            \hline
            Pad & WiFi & D0 & 59 & E4 & 21 & B4 & 9C\\
            \hline
            Kindle & WiFi & 74 & 75 & 48 & 0D & 0A & 9C\\
            
        \end{tabular}
  
    \end{center}
  \end{table}
  
  
  \section{Student 3}
  
  \begin{table}[h!]
    \begin{center}
        
        \label{tab:table3}
        \begin{tabular}{l|l|l@{ : }l@{ : }l@{ : }l@{ : }l@{ : }l}
            \textbf{Item} & \textbf{Method} & \multicolumn{6}{l}{\textbf{MAC \#}}\\
            \hline
            Computer & RJ 1 & 54 & B2 & 03 & 16 & 8F & 34\\
                     & RJ 2 & 54 & B2 & 03 & 16 & 8F & 35\\
                     & WiFi & 1C & 1B & B5 & 34 & 07 & 6A\\
            \hline
            Phone & WiFi & 14 & 1F & 78 & 35 & 93 & A5\\
            \hline
            Pad & WiFi & D0 & 59 & E4 & 21 & B4 & 9C\\
            \hline
            Kindle & WiFi & 74 & 75 & 48 & 0D & 0A & 9C\\
            
        \end{tabular}
  
    \end{center}
  \end{table}

And here are the results:

Enter image description here

Enter image description here

Enter image description here

1
  • Please note, that an extra space appears after letters only. I think this is due to different \spacefactor for gigits and letters. try \, which is thin space.
    – ElGatoGris
    Aug 13, 2021 at 14:21

2 Answers 2

3

I think most of your formatting issues will be resolved automatically if you use a monospaced (aka "teletype") font for the MAC addresses. I would further suggest that you use thinspace rather than "regular" interword space to surround the : column dividers.

enter image description here

\documentclass{article}
\usepackage{array} % for "\newcolumntype" macro
\newcolumntype{L}{>{\ttfamily}l}
\begin{document}

\subsection*{No colons, use interword spaces}
\begin{center}
        \begin{tabular}{@{} l|l|L @{}}
            \textbf{Item} & \textbf{Method} & \multicolumn{1}{l}{\textbf{MAC \#}@{}}\\
            \hline
            Computer & RJ 1 & 54 B2 03 16 8F 34\\
                     & RJ 2 & 54 B2 03 16 8F 35\\
                     & WiFi & 1C 1B B5 34 07 6A\\
            \hline
            Phone & WiFi & 14 1F 78 35 93 A5\\
            \hline
            Pad & WiFi & D0 59 E4 21 B4 9C\\
            \hline
            Kindle & WiFi & 74 75 48 0D 0A 9C\\          
        \end{tabular}
\end{center}

\subsection*{No whitespace around colons}

\begin{center}
        \begin{tabular}{@{} l|l|L@{:}L@{:}L@{:}L@{:}L@{:}L @{}}
            \textbf{Item} & \textbf{Method} & \multicolumn{6}{l}{\textbf{MAC \#}}\\
            \hline
            Computer & RJ 1 & 54 & B2 & 03 & 16 & 8F & 34\\
                     & RJ 2 & 54 & B2 & 03 & 16 & 8F & 35\\
                     & WiFi & 1C & 1B & B5 & 34 & 07 & 6A\\
            \hline
            Phone    & WiFi & 14 & 1F & 78 & 35 & 93 & A5\\
            \hline
            Pad      & WiFi & D0 & 59 & E4 & 21 & B4 & 9C\\
            \hline
            Kindle   & WiFi & 74 & 75 & 48 & 0D & 0A & 9C\\          
        \end{tabular}
\end{center}

  
  
\subsection*{Interword spaces around colons}
  
\begin{center}
        \begin{tabular}{@{} l|l|L@{ : }L@{ : }L@{ : }L@{ : }L@{ : }L @{}}
            \textbf{Item} & \textbf{Method} & \multicolumn{6}{l}{\textbf{MAC \#}}\\
            \hline
            Computer & RJ 1 & 54 & B2 & 03 & 16 & 8F & 34\\
                     & RJ 2 & 54 & B2 & 03 & 16 & 8F & 35\\
                     & WiFi & 1C & 1B & B5 & 34 & 07 & 6A\\
            \hline
            Phone    & WiFi & 14 & 1F & 78 & 35 & 93 & A5\\
            \hline
            Pad      & WiFi & D0 & 59 & E4 & 21 & B4 & 9C\\
            \hline
            Kindle   & WiFi & 74 & 75 & 48 & 0D & 0A & 9C\\           
        \end{tabular}
\end{center}


\subsection*{Thinspaces around colons}
  
\begin{center}
        \begin{tabular}{@{} l|l|L@{\,:\,}L@{\,:\,}L@{\,:\,}L@{\,:\,}L@{\,:\,}L @{}}
            \textbf{Item} & \textbf{Method} & \multicolumn{6}{l}{\textbf{MAC \#}}\\
            \hline
            Computer & RJ 1 & 54 & B2 & 03 & 16 & 8F & 34\\
                     & RJ 2 & 54 & B2 & 03 & 16 & 8F & 35\\
                     & WiFi & 1C & 1B & B5 & 34 & 07 & 6A\\
            \hline
            Phone    & WiFi & 14 & 1F & 78 & 35 & 93 & A5\\
            \hline
            Pad      & WiFi & D0 & 59 & E4 & 21 & B4 & 9C\\
            \hline
            Kindle   & WiFi & 74 & 75 & 48 & 0D & 0A & 9C\\       
        \end{tabular}
\end{center}

\end{document}
1
  • Thank you for the multiple answers ! Nice idea about the font - more computer-look-alike :)
    – Fanny Mae
    Aug 13, 2021 at 15:58
3

Like this?

Unrelated: don't use the center environment within table: it adds unwanted vertical spacing. Use \centering instead.

\documentclass{article}
\usepackage{array}
\newlength{\cellwd}
\settowidth{\cellwd}{B5}

\begin{document}

\section{Student 3}

\begin{table}[h!]
\centering

    \label{tab:table3}
    \begin{tabular}{l|l|l*{5}{!{:}wc{\cellwd}}}
        \textbf{Item} & \textbf{Method} & \multicolumn{6}{l}{\textbf{MAC \#}}\\
        \hline
        Computer & RJ 1 & 54 & B2 & 03 & 16 & 8F & 34\\
                 & RJ 2 & 54 & B2 & 03 & 16 & 8F & 35\\
                 & WiFi & 1C & 1B & B5 & 34 & 07 & 6A\\
        \hline
        Phone & WiFi & 14 & 1F & 78 & 35 & 93 & A5\\
        \hline
        Pad & WiFi & D0 & 59 & E4 & 21 & B4 & 9C\\
        \hline
        Kindle & WiFi & 74 & 75 & 48 & 0D & 0A & 9C\\

    \end{tabular}
\end{table}

\end{document} 

enter image description here

1
  • Thank you for the answers. Both Bernard and Mico gave me solutions and even better than what I might have thought :-) tyvm.
    – Fanny Mae
    Aug 13, 2021 at 15:55

You must log in to answer this question.

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