Monday, December 5, 2011

LaTeX series -- Table

Minna sann~..... genki desuka?!!

Jyaa~... kyou... oppss... tershashul pulop!!.... ari ni aku belajar Te-Form (て-Form) kat kelas... pening sket aar... bnyk sgt condition dia... basically apa yang aku faham....
verbs ます-Form boleh dipecahkan kepada 3 kelas... Group I, II & III.

Group II & III adalah mudah.... hanya perlu omit ますand replace with て. Untuk Group II, bunyi yang terakhir sebelum ます adalah "ee" (え). Perbezaan antara Group II & III hanyalah pada Noun+ます (Group II) dan Noun+します (Group III).... Sebagai contoh:-

Group II:-

みせます >> みせて
おしえます >> おしえて

Group III:-

べんきょうします >> べんきょうして
さんぽんします >> さんぽんして

Bagi Group I pula, agak sukar sedikit kerana banyak condition dimana ia bergantung kepada bunyi akhir sebelum ます. Eh.....!!

Macam silap entry je neh... huhuhuhu... ok ok... back to the topic...

Today, I've spent most of my time to figure out how to draw a nice table!!! It's quite challenging, especially for me who is very new to LaTeX... enough with talk... let's go straight to the point.. Alrite..

First thing, we need to determined how the table should be. For two column articles, would it be 1 column? span for 2 column? . Then, how many column would you like to have for the table etc... I'll only show what I've done today for my future reference :-)

\newcommand\T{\rule{0pt}{3.1ex}} % Adds a space between the text and the [T]op \hline
\newcommand\B{\rule[-1.7ex]{0pt}{0pt}} % Adds a space between the text and the [B]ottom \hline
\setlength{\doublerulesep}{\arrayrulewidth} %make \hline \hline as thick line

\begin{table*}[!t]  %span table for 2 column. Omit * if want to make table in 1 column
\caption{Title of the table}
\label{table_1}
\centering
%make 3 column, set alignment for column 1- left, column 2-right & column 3-center
\begin{tabular}{l r c} 
\hline \hline %bold horizontal line. Act as the table border


% \multicolumn{2}{c}-- meaning, span 2 column and centered
% \T \B -- meaning, add space for top and bottom
% \cline{2-3} -- meaning, make a line from column 2 until column 3
& \multicolumn{2}{c}{\textbf{Some Title}} \T \B \\ \cline{2-3}


% \multicolumn{1}{l} -- meaning, change alignment for column 1, from original right align to left align
% \hline -- meaning, make a horizontal line (thin)
\multicolumn{1}{l}{Some Parameters} & 2nd Parameter & 3rd Parameter \\ \hline 
& row1column2 & row1column3 \\ % "&" symbol at the beginning is used to skip 1 column
row2column1 \T \B & row2column2 & row2column3 \\ % end row 2
row3column1 \T &
% wrap long text using {minipage}. [t] is to set to the top align. {1.1in} is to set the length of minipage
\begin{minipage}[t]{1.1in} 
\begin{flushleft}a very long line for row3column2 a very long line for row3column2 a very long line for row3column2 a very long line for row3column2 \end{flushleft}%
\end{minipage} 
% wrap long text using \parbox. {1.3in} is the length of the \parbox. 
% {flushleft} -- meaning, to set the alignment to left
\parbox{1.3in}{\begin{flushleft}a very long line for row3column3 a very long line for row3column3 a very long line for row3column3 a very long line for row3column3 \end{flushleft}} \\
\hline \hline
\end{tabular}
\centering
\end{table*}

The output of above command as follow:-
From the table, you can see that the \parbox is quite difficult to handle. It's behavior is not as expected. Well, this is as far as I can do... for now..


Alrite.... I think it is enough for now.... we'll cont. some other time... I need to finish the unfinished business!!

じゃ。まった こんど

Update: Dec 8, 2011

Using \begin{flushleft} \end{flushleft} somehow leave unwanted vertical space in the cell and that is why \parbox is behaving wild. What I did was, use \usepackage{array} and change the setting my column to something like this:-


\begin{tabular}{l >{\raggedright}p{0.2\textwidth}  >{\raggedright\arraybackslash}p{0.3\textwidth}}
\toprule
row1column1 & row1column2 & row1column3 \\ \midrule
\bottomrule

\raggedright} is used to align the text to left.
\arraybackslash is required in order to make \\ works.
\toprule is required for \midrulerule\bottomrule and "" to works.



~see LaTeX

No comments: