Graphics, Figures & TablesHow to fixed table into margin ??

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
thundeng
Posts: 2
Joined: Wed Jan 21, 2009 8:03 pm

How to fixed table into margin ??

Post by thundeng »

I have a table that spread and acroos
My table is fixed in the left margin, but spread and through at the right margin.
I use standart LaTeX article template.
Please, Help me. How to fixed the table at the left and right margin AUTOMATICALLY.

This my tables code

Code: Select all

\documentclass[11pt, a4paper]{article}
\usepackage{mhchem}
\begin{document}

\begin{table}
\begin{tabular}{clll}
\hline
No. & Nama Reaksi & Persamaan Reaksi & $K_{p,j}$\\ \hline
1 &Pembakaran &$\ce{Biomassa + pO_2 -> $x$CO_2 + $y/2$H_2O}$ &-\\
2 &Boudard   &$\ce{C + CO_2->2CO}$ &$K_{p,B}$\\
3		&Heterogenous water shift&$\ce{C + 2H_2O -> CO_2 + 2H_2}$				&$K_{p,W}$\\
4		&Homogenous water shift&$\ce{CO + H_2O -> CO_2 + H_2O}$					&$K_{p,S}$\\
5		&Metanasi&		$\ce{C + 2H_2 -> CH_4}$											&$K_{p,M}$\\
\hline
\end{tabular}
\end{table}



Best Regard...

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

How to fixed table into margin ??

Post by localghost »

There are two possible solutions. The first one is changing the page geometry with the geometry package.

Code: Select all

\usepackage[centering,includeheadfoot,margin=2cm]{geometry}
The second one is building the table with the tabularx package and fix the width of some columns.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage[centering,includeheadfoot,margin=2cm]{geometry}
\usepackage{booktabs,tabularx}
\usepackage[font=small,labelfont=bf]{caption}
\usepackage[version=3]{mhchem}
\usepackage{lmodern}

\begin{document}
  \begin{table}[!ht]
    \centering
    \caption{A Table}\label{tab:table}
    \begin{tabularx}{\textwidth}{cXXc} \toprule
      No. & Nama Reaksi & Persamaan Reaksi & $K_{p,j}$ \\ \midrule[0.8pt]
      1 & Pembakaran & $\ce{Biomassa + pO_2 -> $x$CO_2 + $y/2$H_2O}$ & --- \\
      2 & Boudard & $\ce{C + CO_2 -> 2CO}$ & $K_{p,B}$ \\
      3 & Heterogenous water shift&$\ce{C + 2H_2O -> CO_2 + 2H_2}$ & $K_{p,W}$ \\
      4 & Homogenous water shift & $\ce{CO + H_2O -> CO_2 + H_2O}$ & $K_{p,S}$ \\
      5 & Metanasi & $\ce{C + 2H_2 -> CH_4}$ & $K_{p,M}$ \\ \bottomrule
    \end{tabularx}
  \end{table}
\end{document}
Note that this is only an example. The choice of suitable means is up to you, especially which column of the table is to be fixed. An alternative could be to fix width of a column by using a p{5cm} column type instead.


Best regards
Thorsten¹
murph636
Posts: 22
Joined: Sun Mar 15, 2009 3:54 am

How to fixed table into margin ??

Post by murph636 »

Hello~

I am having a similar problem but with a rotated table, so fixing the column widths would help in this case. Any other ideas?

Code: Select all

\newpage
\clearpage
\section{Tables}
\bigskip\bigskip
\begin{sideways}
\begin{minipage}{0.9\textheight}
\centering
\captionof{table}{Error matrix from 2001 NLCD classification of Level 1 classes.}\label{tab:NLCDLevel1Table}
\begin{tabular}[!h]{m{1in}rrrrrrrr}
\toprule
           &    \multicolumn{ 6}{c}{2005 Aerial Photo Interpretation Reference Data} &            &            \\ [1ex]           
\cline{2-7} 
 &      &       &       &       &       &       &            &            \\ 
 NLCD 2001 & Agriculture &     Forest &  Grassland &      Urban &      Water &    Wetland &     Totals & User's  \\ 
 Classified Data &  &      &   &       &       &     &      & Accuracy (\%) \\ [1ex]
\hline
 &      &       &       &       &       &       &            &            \\ 
Agriculture &       161 &          7 &          6 &         13 &          0 &          0 &        187 &      86.1 \\[1ex]
    Forest &          7 &         25 &          6 &          8 &          2 &         10 &         58 &      43.1 \\[1ex]
 Grassland &         36 &         16 &         21 &         14 &          1 &          1 &         89 &      23.6 \\[1ex]
     Urban &         12 &          8 &          8 &         94 &          1 &          3 &        126 &      74.6 \\[1ex]
     Water &          1 &          3 &          2 &          1 &         17 &          2 &         26 &      65.4 \\[1ex]
   Wetland &          1 &          1 &          2 &          1 &          1 &          8 &         14 &      57.1 \\[1ex]
    Totals &        218 &         30 &         45 &        131 &         22 &         24 &        500 &            \\[1ex]
Producer's &      &       &       &       &       &       &            &            \\ 
Accuracy (\%) &      73.9 &      41.7 &      46.7 &      71.8 &      77.3 &      33.3 &            &            \\[1ex]
\hline 
 &      &       &       &       &       &       &            &            \\ 
\multicolumn{ 9}{l}{Overall accuracy = 65.2$\%$; Overall Kappa coefficient = 0.53; Overall Kappa Z Statistic = 19.5$^*$} \\
\bottomrule
\label{NLCDLevel1Table}
\end{tabular}
\end{minipage}
\end{sideways}

Post Reply