Posted by: smallonely | May 5, 2008

Latex Tabel Space Control

為了要畫一個 WiMAX Message Format 的圖, 花了我一整個下午&半個晚上的時間研究…

很難耶!! 要怎麼把上面的數字和下面的表格對齊?
LaTeX 要怎麼平均分配欄寬?
要怎麼畫線? 要怎麼下面表格畫線上面不畫線但仍然可以對齊?
要怎麼分配最後的 3bit : 5bit 的欄寬? (tabular in tabular 嗎?)
(總不能寫 \begin{tabular}{ccccccccccccccccccccccccccccccc} 吧 Orz )

試了很久 還把問題複雜化 XDDDD,
終於弄好了😀
雖然是拿 \textwidth 硬幹, 不過好像也只有這個辦法
並且記得所有的欄位要置中~
(有沒有更好的方法!! 煩請指教!)

\begin{table}
\caption{WiMAX Message Format} \label{tab:WiMAX} \noindent
\begin{tabular} {p{0.23\textwidth}p{0.23\textwidth}p{0.23\textwidth} p{0.08625\textwidth}p{0.14375\textwidth}}
0&8&16&24&27 \hfill 31
\end{tabular}

\noindent
\begin{tabular} {|p{0.23\textwidth}|p{0.23\textwidth}|p{0.23\textwidth}| p{0.08625\textwidth}|p{0.14375\textwidth}|}
\hline \centerline{Version} & \centerline{Flags} &
\centerline{Function Type} & \centerline{OpID} &
\centerline{Message Type} \\
\hline \multicolumn{2}{|c|}{Length} &
\multicolumn{3}{|c|}{MSID}
\\ \hline \multicolumn{5}{|c|}{MSID} \\ \hline
\multicolumn{5}{|c|}{Reserved}
\\ \hline \multicolumn{2}{|c|}{Transaction ID} & \multicolumn{3}{|c|}{Reserved}
\\ \hline \multicolumn{5}{|c|}{TLVs} \\ \hline
\end{tabular}
\end{table}

得到的結果如下:
可是他第一個row好像特別寬, 要怎麼修正呢…..


Responses

  1. WiMAX…

    is a dream or a bubble ?

    要靠國內科學家的努力了!

    找找Killer Applicatino吧~

  2. 這樣寫可修正第一個row太高的問題:
    \begin{table}
    \caption{WiMAX Message Format} \label{tab:WiMAX} \noindent
    \begin{tabular} {p{0.23\textwidth}p{0.23\textwidth}p{0.23\textwidth} p{0.08625\textwidth}p{0.14375\textwidth}}
    0&8&16&24&27 \hfill 31
    \end{tabular}

    \noindent
    \begin{tabular} {|c|c|c|c|c|}
    \hline
    \makebox[.23\textwidth]{\centering Version} & \makebox[.23\textwidth]{\centering Flags} &
    \makebox[.23\textwidth]{\centering Function Type} & \makebox[.08625\textwidth]{\centering OpID} &
    \makebox[.14375\textwidth]{\centering Message Type} \\
    \hline \multicolumn{2}{|c|}{Length} &
    \multicolumn{3}{|c|}{MSID}
    \\ \hline \multicolumn{5}{|c|}{MSID} \\ \hline
    \multicolumn{5}{|c|}{Reserved}
    \\ \hline \multicolumn{2}{|c|}{Transaction ID} & \multicolumn{3}{|c|}{Reserved}
    \\ \hline \multicolumn{5}{|c|}{TLVs} \\ \hline
    \end{tabular}
    \end{table}

  3. to wcliu,
    對耶, 你好棒!!!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: