基于编写表格列的描述
\documentclass{article}
\usepackage{polski}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{figure}\label{fig:ieee754single}
\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}
\rm\caption{IEEE754 single}
\end{figure}
\end{document}
我如何才能强制使列宽相同。我喜欢 E 的宽度小于 23。
答案1
您只能使用段落p
列类型来设置列宽。为了获得居中效果,您需要\centering
在之前添加,通常在后面添加以\arraybackslash
恢复 的表格含义\\
。您可以使用包>{..}
提供的列说明符来执行此操作array
。它还允许您定义自己的自定义列类型。我建议您这样做:
\usepackage{array}
\newcolumntype{C}{>{\centering\arraybackslash}p{2ex}}
然后使用C
而不是c
。还有一种低级 TeX 方式可以做到这一点,我将其添加到下面。它会稍微降低文本,在我看来这样看起来更好。
\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}
另请注意我的其他更改(\label
之后\caption
、\rmfamily
而不是\rm
、..)。
答案2
这里您有 32 位和 64 位变量表示float
。double
如果您喜欢,±
那么Znak
这将是一个不错的选择。我认为是这样 ;)。您喜欢吗?
\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}