Forcing exactly the same column widths in table

You can set the column width only with the paragraph p column type. In order to get centering you need to add \centering before, usually followed by \arraybackslash to restore the tabular meaning of \\. You can do so using the >{..} column specifier provided by the array package. It also allows you to define you own custom column types. I would suggest you do:

\usepackage{array}
\newcolumntype{C}{>{\centering\arraybackslash}p{2ex}}

and then use C instead of c. There is also a lower-level TeX way to do it, which I added below. It lowers the text a little, which looks better IMHO.

\documentclass{article}
%\usepackage{polski}
\usepackage[utf8]{inputenc}
\usepackage{array}

% Normal LaTeX way: \newcolumntype{C}{>{\centering\arraybackslash}p{2ex}}
% Using lower-level TeX commands:
\newcolumntype{C}{>{\lower.2ex\hbox to 2ex\bgroup\hss}c<{\hss\egroup}}
\begin{document}
\begin{figure}
\centering\sf\setlength{\tabcolsep}{1.45pt}
\begin{tabular}{|*{32}{C|}}
\multicolumn{32}{|l}{\small  Bit}\\
\multicolumn{1}{|c}{\footnotesize  31}&\multicolumn{6}{c}{}&\multicolumn{1}{c|}{\footnotesize  24}&
\multicolumn{1}{c}{\footnotesize  23}&\multicolumn{6}{c}{}&\multicolumn{1}{c|}{\footnotesize  16}&
\multicolumn{1}{c}{\footnotesize  15}&\multicolumn{6}{c}{}&\multicolumn{1}{c|}{\footnotesize  8}&
\multicolumn{1}{c}{\footnotesize  7}&\multicolumn{6}{c}{}&\multicolumn{1}{c|}{\footnotesize  0}\\
\hline
S &
E & E & E & E & E & E & E & E &
M & M & M & M & M & M & M & M &
M & M & M & M & M & M & M & M &
M & M & M & M & M & M & M \\
\hline
\multicolumn{1}{|c|}{}&
\multicolumn{8}{c|}{Wykładnik} &
\multicolumn{23}{c|}{Mantysa} \\
\cline{2-32}
\multicolumn{5}{|c}{\raisebox{-0.3ex}{Znak}} & \multicolumn{27}{c}{}\\
\cline{1-5}
\end{tabular}
\rmfamily
\caption{IEEE754 single}
\label{fig:ieee754single}
\end{figure}
\end{document}

Please also note my other changes (\label after \caption, \rmfamily instead of \rm, ..).

Result


Here you have 32- and 64-bit representation of float and double variable. If you like ± instead of Znak it will be good one. I think so ;). Do you like it?

\documentclass{article}
%\usepackage{polski}
\usepackage[utf8]{inputenc}
\usepackage{array}

% Normal LaTeX way: \newcolumntype{C}{>{\centering\arraybackslash}p{2ex}}
% Using lower-level TeX commands:
\newcolumntype{C}{>{\lower.2ex\hbox to 2ex\bgroup\hss}c<{\hss\egroup}}
\begin{document}
\begin{figure}
\centering\sffamily\setlength{\tabcolsep}{1.45pt}
\begin{tabular}{|*{32}{C|}}
\multicolumn{32}{l}{\raisebox{-0.3ex}{\small Bit}}\\
\multicolumn{1}{|c}{\footnotesize  31}&\multicolumn{6}{c}{}&\multicolumn{1}{c|}{\footnotesize  24}&
\multicolumn{1}{c}{\footnotesize  23}&\multicolumn{6}{c}{}&\multicolumn{1}{c|}{\footnotesize  16}&
\multicolumn{1}{c}{\footnotesize  15}&\multicolumn{6}{c}{}&\multicolumn{1}{c|}{\footnotesize  8}&
\multicolumn{1}{c}{\footnotesize  7}&\multicolumn{6}{c}{}&\multicolumn{1}{c|}{\footnotesize  0}\\
\hline
S &
E & E & E & E & E & E & E & E &
M & M & M & M & M & M & M & M &
M & M & M & M & M & M & M & M &
M & M & M & M & M & M & M \\
\hline
\multicolumn{1}{|c|}{\raisebox{-0.2ex}{$\pm$}}&
\multicolumn{8}{c|}{\raisebox{-0.2ex}{\small Wykładnik}} &
\multicolumn{23}{c|}{\raisebox{-0.2ex}{\small Mantysa}} \\
\hline
\end{tabular}
\rmfamily
\caption{IEEE754 single}
\label{fig:ieee754single}
\end{figure}

\begin{figure}
\centering\sffamily\setlength{\tabcolsep}{1.45pt}
\begin{tabular}{|*{32}{C|}}
\multicolumn{32}{l}{\raisebox{-0.3ex}{\small Bit}}\\
\multicolumn{1}{|c}{\footnotesize  63}&\multicolumn{6}{c}{}&\multicolumn{1}{c|}{\footnotesize  56}&
\multicolumn{1}{c}{\footnotesize  55}&\multicolumn{6}{c}{}&\multicolumn{1}{c|}{\footnotesize  48}&
\multicolumn{1}{c}{\footnotesize  47}&\multicolumn{6}{c}{}&\multicolumn{1}{c|}{\footnotesize  40}&
\multicolumn{1}{c}{\footnotesize  39}&\multicolumn{6}{c}{}&\multicolumn{1}{c|}{\footnotesize  32}\\
\hline
S &
E & E & E & E & E & E & E & E &
E & E & E &
M & M & M & M & M & M & M & M &
M & M & M & M & M & M & M & M &
M & M & M & M\\
\hline
\multicolumn{1}{|c|}{\raisebox{-0.2ex}{$\pm$}}&
\multicolumn{11}{c|}{\raisebox{-0.2ex}{\small Wykładnik}} &
\multicolumn{20}{c|}{\raisebox{-0.2ex}{\small Mantysa}} \\
\hline
\multicolumn{32}{c}{}\\[-1.2ex]
\multicolumn{1}{|c}{\footnotesize  31}&\multicolumn{6}{c}{}&\multicolumn{1}{c|}{\footnotesize  24}&
\multicolumn{1}{c}{\footnotesize  23}&\multicolumn{6}{c}{}&\multicolumn{1}{c|}{\footnotesize  16}&
\multicolumn{1}{c}{\footnotesize  15}&\multicolumn{6}{c}{}&\multicolumn{1}{c|}{\footnotesize  8}&
\multicolumn{1}{c}{\footnotesize  7}&\multicolumn{6}{c}{}&\multicolumn{1}{c|}{\footnotesize  0}\\
\hline
M & M & M & M & M & M & M & M &
M & M & M & M & M & M & M & M &
M & M & M & M & M & M & M & M &
M & M & M & M & M & M & M & M\\
\hline
\multicolumn{32}{|c|}{\raisebox{-0.2ex}{\small Mantysa}} \\
\hline
\end{tabular}
\rmfamily
\caption{IEEE754 double}
\label{fig:ieee754double}
\end{figure}
\end{document}

enter image description here

Tags:

Tables