# Writing descriptions of columns of table

How do you do table like this?

I don't need coloured background and blue borders.

This is what I have. Looks terrible. And doesn't even fit on page.

\documentclass{article}
\usepackage{polski}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{figure}
\begin{tabular}{c | c | c | c | c | c | c | c | c | c | c | c | c | c | c | c | c | c | c | c | c | c | c | c | c | c | c | c | c | c | c | c |}

Bit\\
31 &&&&&&& 24&23 &&&&&&& 16&15 &&&&&&& 8&7 &&&&&& 1&0\\
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 \\

\end{tabular}
\caption{IEEE754}
\end{figure}

\listoffigures
\listoftables
\end{document}

-
Hi @papciuch and welcome to TeX.sx. In its current form, your question might not receive many answers. Please take a look at the How to Ask-page and try to improve your question according to the guidance found there. This may require you to show some effort on your part in terms of attempting a solution. If you have questions about what to do or if you don't quite understand what this means, please ask for clarification using the add comment function. –  Dror May 8 '12 at 7:36
Have also a look at the register package, which is for diagrams/tables like this. It might however not be able to create a table just like this. –  Martin Scharrer May 8 '12 at 18:26
@MartinScharrer, I don't need table that looks exactly the same. I just need to show the idea. –  papciuch May 8 '12 at 18:35
@papciuch: Then you should definitely have a look at the register package. –  Martin Scharrer May 8 '12 at 18:43
@papciuch I've modified my answer so that it can be more as you'd like it. –  egreg May 8 '12 at 19:57

A solutions that, without too much code, does what's requested; the main trick is to reduce the \tabcolsep (and the font size):

\begin{figure}
\centering\small\setlength{\tabcolsep}{1.45pt}
\begin{tabular}{|*{32}{c|}}
\multicolumn{32}{l}{Bit}\\
\multicolumn{8}{|c|}{\tiny 31\hfill 24}&
\multicolumn{8}{c|}{\tiny 23\hfill 16}&
\multicolumn{8}{c|}{\tiny 15\hfill 8}&
\multicolumn{8}{c|}{\tiny 7\hfill 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{23}{c|}{Mantysa} \\
\cline{2-32}
\multicolumn{5}{|c}{Znak} & \multicolumn{27}{c}{}\\
\cline{1-5}
\end{tabular}
\caption{IEEE754}
\end{figure}


If cells are desired to have the same width, then I suggest some changes.

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

\begin{document}

\begin{figure}
\centering\small
{\sffamily
\newlength{\bitwidth}\settowidth{\bitwidth}{M}
\newcommand{\bitname}[1]{\makebox[\bitwidth]{#1}}
\newcommand{\bitrule}{\vrule height 6pt}
\setlength{\extrarowheight}{2pt}
\setlength{\tabcolsep}{1.1pt}
\begin{tabular}{|*{32}{c|}}
\multicolumn{32}{l}{Bit}\\
\multicolumn{8}{@{\bitrule}c@{\bitrule}}{\tiny\,31\hfill 24\,}&
\multicolumn{8}{@{}c@{\bitrule}}{\tiny\,23\hfill 16\,}&
\multicolumn{8}{@{}c@{\bitrule}}{\tiny\,15\hfill 8\,}&
\multicolumn{8}{@{}c@{\bitrule}}{\tiny\,7\hfill 0\,} \\
\hline
\bitname{S} &
\bitname{E} & \bitname{E} & \bitname{E} & \bitname{E} &
\bitname{E} & \bitname{E} & \bitname{E} & \bitname{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{23}{c|}{Mantysa} \\
\cline{2-32}
\multicolumn{5}{|c}{Znak} & \multicolumn{27}{c}{}\\
\cline{1-5}
\end{tabular}}
\caption{IEEE754}
\end{figure}
\end{document}


Since "M" is usually the widest character in a font, setting the "S" and the "E" so that they occupy as much space as an "M" is easy. I've modified slightly other aspects as indicated in comments.

-
echoing a comment in the answer by Harish Kumar, "Znak" looks too high in its box. but if you look at the original example, all the rows are more "airy" at the top. the tabular format provides a fixed vertical dimension that is suitable for a glyph with maximum height and depth for the current font, say, a parenthesis. in this case, it's probably easiest to insert a custom "strut" (zero-width vrule) at the beginning of each line; in the original, the line with "S", "E" and "M" is more open than the next two, so the dimensions wouldn't be the same. –  barbara beeton May 8 '12 at 12:48
@barbarabeeton If you use the package tabu (tug.ctan.org/pkg/tabu) or maybe tabularhtfrom the Oberdiek bundle (tug.ctan.org/pkg/tabularht), you may have more air above the letters, and keep the vertical lines correctly connected. –  Sveinung May 8 '12 at 17:59

If you need colors, you may use colortbl or table from xcolor and more preferably tikz. But this is a simple way with ordinary tabular:

\documentclass{article}
\usepackage{polski,array,fullpage}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{table}[htb]
\centering
\begin{tabular}{|*{32}{@{}>{\centering\arraybackslash}p{.4cm}@{}|} }

\multicolumn{32}{@{}l}{Bit}\\
\multicolumn{1}{|@{}c@{}}{31} &\multicolumn{6}{@{}r@{}}{}&\multicolumn{1}{@{}c@{}|}{24}&\multicolumn{1}{@{}c@{}}{23} &\multicolumn{6}{@{}r@{}}{}&\multicolumn{1}{@{}c@{}|}{16}&\multicolumn{1}{@{}c@{}}{15} &\multicolumn{6}{@{}r@{}}{}&\multicolumn{1}{@{}c@{}|}{8}&\multicolumn{1}{@{}c@{}}{7} &\multicolumn{5}{@{}r@{}}{}&\multicolumn{1}{@{}c@{}|}{1}&\multicolumn{1}{@{}c@{}|}{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{6}{|c}{Znak} & \multicolumn{26}{c}{}\\ \cline{1-6}
\end{tabular}
\caption{IEEE754}
\end{table}

\listoffigures
\listoftables
\end{document}


-
What is purpose of fullpage? I want this table to appear on list of figures so I'll keep \begin{figure} ;) –  papciuch May 8 '12 at 9:25
@papciuch: It will aloow you to make use of full page. (LaTeX leaves large margins by default). Alternatively you can use geometry package to adjust the paper size, margins etc. PS. Remove fullpage and see the difference. –  Harish Kumar May 8 '12 at 9:28
@HarishKumar Using fullpage may not be what the OP wants. –  egreg May 8 '12 at 9:29
@HarishKumar One can't be forced to change layout in order to fit a table: it's the other way around. –  egreg May 8 '12 at 9:35
@papciuch: use \multicolumn{5}{|c}{\raisebox{-0.3ex}{Znak}} . –  Harish Kumar May 8 '12 at 10:12