我正在做清单MAC 地址。我已经使用过表格,但我不知道如何管理十六进制值的空格(之前或之后)。
对于一个设备,不同的 MAC 地址彼此之间没有正确对齐。存在一个微小的间隙,这取决于十六进制值的“大小”(我的意思是,“11”值比“DF”值大?因此,如果仅检查列,就会发现差异)。
下面是包含三个测试的代码(从非常糟糕到几乎很好):
\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}
结果如下:
答案1
我认为,如果您使用等宽字体(又称“电传打字机”)来显示 MAC 地址,您的大多数格式问题都会自动得到解决。我还建议您使用细间距而不是“常规”字间间距来围绕列:
分隔符。
\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}
答案2
像这样?
无关:不要使用center
内的环境table
:它会增加不必要的垂直间距。请使用\centering
。
\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}