Total members 11873 |It is currently Wed Mar 22, 2023 1:17 pm Login / Join Codemiles

### Weka

Add tables using latex is done using table tags, is very easy , following is a simple example for adding a table:

This code creates a table using the LaTeX package. It includes the following components:

\begin{table}: starts the table environment.
\centering: centers the table on the page.
\begin{tabular}{lcccc}: starts a tabular environment, with columns specified by the letters l, c, and r, which stand for left-aligned, centered, and right-aligned, respectively.
\hline: creates a horizontal line.
\textbf{Type}, \textbf{Prop1}, \textbf{Prop2}, \textbf{Prop3}: are the headers of the table, they are typeset in boldface.
\textbf{class1}, \textbf{class2}, \textbf{class3}: are the rows of the table, they are also typeset in boldface.
\hline: creates a horizontal line.
\label{tab:LabelRef}: assigns a label to the table, which can be used to reference the table in the text..
\end{tabular}: ends the tabular environment.
\end{table}: ends the table environment.

Finally, it's worth noting that this code uses the basic tabular environment, but LaTeX also has other table-making environments such as the tabularx and tabulary environments, the array environment and the tabular* environment. Each has its own features and is more suitable for specific use cases.

Code:
\begin{table}
\centering

\begin{tabular}{lcccc}
\hline
\textbf{Type} & \textbf{Prop1} & \textbf{Prop2} & \textbf{Prop3} \\
\hline
\textbf{class1} & X &  Y & Z \\
\textbf{class2} & X &  Y & Z    \\
\textbf{class3} & X &  Y &  Z    \\
\hline
\end{tabular}
\label{tab:LabelRef}
\end{table}

To add border to this table you will change the following part:

Code:
\begin{tabular}{lcccc}

into this part :

Code:
\begin{tabular}{|l|c|c|c|c|}

There are some cases you may need to change the size of the table while keeping the number of columns and rows as it is, in such case you use the \resizebox tag which takes one parameter:
Code:
\begin{table}
\centering
\resizebox{14cm}{!}{
\begin{tabular}{|l|c|c|c|c|}
\hline
\textbf{class1} & X &  Y & Z \\
\textbf{class2} & X &  Y & Z    \\
\textbf{class3} & X &  Y &  Z    \\
\hline
\end{tabular}
}
\label{tab:tableRef}
\end{table}

_________________
M. S. Rakha, Ph.D.
Queen's University

 Tweet
Author:
 Posts: 2715Have thanks: 74 time
 Page 1 of 1 [ 1 post ]

Related Posts  to : Using table in latex
table creation     -
row highlight of table     -
table row hover     -
Creating table using div tag     -
Div Table with css row span     -
Full scrollable table     -
Select odd rows from table     -
Table with colored background     -
separate table per subclass     -
lowercase table content     -