Total members 11889 |It is currently Thu Mar 28, 2024 4:54 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

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.
    \caption{Add your table caption here}: adds a caption to the table.
    \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.


It creates a table with 4 columns and 3 rows with headers: Type, Prop1, Prop2, Prop3, and rows with class1, class2, class3. In addition to what I've already mentioned, it's worth noting that the X, Y, and Z in the table rows likely represent some sort of data or information. The table can be used to organize and display this information in a clear and easy-to-read format. Also, the table has a caption "Add your table caption here" which should be replaced with a meaningful caption that describes the table and its contents. Also, the label "tab:LabelRef" is used to reference the table in the text. It can be used to refer to the table in the text or in any cross-reference. It is a basic table format. You can always customize and add more features to the table as per your requirement. It's worth noting that the table created by this code is a simple table, but LaTeX offers various options and packages to customize the table further. For example, you can adjust the column width, row height, font size, and text alignment. You can also add vertical and horizontal lines, color and shading, and even include images and graphics in the table. Also, you can use the package "booktabs" which provides additional commands and options for creating professional-looking tables. It is also possible to use the package "longtable" to create tables that span multiple pages.

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}
\caption{Add your table caption here }
\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}
}
\caption{Add your table caption here }
\label{tab:tableRef}
\end{table}




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


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

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



cron






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com