Graphics, Figures & TablesAdjust Width of two Tables

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
0texel
Posts: 4
Joined: Mon Jun 11, 2012 11:13 am

Adjust Width of two Tables

Post by 0texel »

How can I get effect like this. I know this is a two tables but I need to fix the width of columns to expand it on width of page.

Code: Select all

\begin{center}
     \begin{tabular}{  l  c  c  r }
     \textbf{Rząd} & \textbf{Tradycyjna nazwa} & \textbf{Wzór} & \textbf{Błąd} \\
     \end{tabular}
\end{center}
\newpage
\begin{center}
     \begin{tabular}{  c  c  c  p{5cm} }
1 & wzór trapezów  & $\frac{h}{2}(f_{0}+f_{1})$ & $-\frac{h^3}{12}f^{(2)}(\xi)$  \\  
2 & wzór Simpsona & $\frac{h}{3}(f_0+4f_1+f_2)$ & $-\frac{h^5}{90}f^{(4)}(\xi)$  \\ 
3 & reguła 3/8 & $\frac{3h}{8}(f_0+3f_1+3f_2+f_3)$ & $-\frac{3h^5}{80}f^{(4)}(\xi)$ \\  
4 & wzór Boole'a często błędnie\footnotemark  & $\frac{2h}{45}(7f_0+32f_1+12f_2+32f_3+7f_4)$ & $-\frac{8h^7}{945}f^{(6)}(\xi)$ \\ 
  & nazywany wzorem Bode'a & & \\
     \end{tabular}
\end{center}
Attachments
tables-width.jpg
tables-width.jpg (54.39 KiB) Viewed 1521 times
Last edited by localghost on Wed Jun 13, 2012 5:22 pm, edited 1 time in total.

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

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

Adjust Width of two Tables

Post by localghost »

I would not allow a page break between header and body of this table (it's only one). So, why not use just one table and let if float?

To make the table occupy the complete text width use tabularx as shown below.

Code: Select all

\documentclass[11pt,a4paper,polish]{article}
\usepackage[T1]{fontenc}
\usepackage{selinput}
\SelectInputMappings{
  oacute={ó},
  lslash={ł},
}
\usepackage{babel}
\usepackage[margin=2cm]{geometry}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{tabularx}

\newcolumntype{C}{>{\centering\arraybackslash}X}

\begin{document}
  \begin{table}[!ht]
    \caption{A dummy table}
    \label{tab:dummy}
    \centering
    \begin{tabularx}{\linewidth}{cCCc}
     \textbf{Rząd} & \textbf{Tradycyjna nazwa} & \textbf{Wzór} & \textbf{Błąd} \\
      1 & wzór trapezów  & $\frac{h}{2}(f_{0}+f_{1})$ & $-\frac{h^3}{12}f^{(2)}(\xi)$  \\  
      2 & wzór Simpsona & $\frac{h}{3}(f_0+4f_1+f_2)$ & $-\frac{h^5}{90}f^{(4)}(\xi)$  \\
      3 & reguła 3/8 & $\frac{3h}{8}(f_0+3f_1+3f_2+f_3)$ & $-\frac{3h^5}{80}f^{(4)}(\xi)$ \\  
      4 & wzór Boole'a często błędnie\footnotemark  & $\frac{2h}{45}(7f_0+32f_1+12f_2+32f_3+7f_4)$ & $-\frac{8h^7}{945}f^{(6)}(\xi)$ \\
      & nazywany wzorem Bode'a & & \\
    \end{tabularx}
  \end{table}
\end{document}

Best regards and welcome to the board
Thorsten
Post Reply