Graphics, Figures & Tablescentering the last column of a table

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
dmuthu_cse
Posts: 97
Joined: Fri Sep 04, 2009 4:56 pm

centering the last column of a table

Post by dmuthu_cse »

Hello friends,

Can anyone tell me how to center the last column of the table, in which the last column is defined with the format "p{width}".

I tried using \centering before that column, which produces error saying "Misplaced \noalign"

Herewith i am enclosing the MWE,

Code: Select all

\documentclass[b5paper,11pt]{book}
\usepackage{fancybox,array,amsmath,ulem,amssymb}
\usepackage[centering,
  headheight=14pt,
  headsep=10pt,
  includehead,
  papersize={18cm,24cm},
  text={15.25cm,19.2cm},
  dvips=false,
  pdftex=false,
  vtex=false
]{geometry}
\usepackage[cam,a4,center,dvips]{crop}
\usepackage{graphicx,colortbl}
\usepackage{fancyhdr,setspace,rotate}
\usepackage{threeparttable,booktabs,multirow,lscape}
\begin{document}
\begin{table}[!ht]
\centering
\small
\begin{tabular}{p{0.7in}p{0.7in}p{1.3in}cc>{\centering}p{1in}}
\toprule 
\textbf{A} & \textbf{P} & \textbf{T} & \textbf{C} & \textbf{TC} & \textbf{S}\\ \midrule
- & 24 & 3900 & $24\times 375=9000$ & 12900 & -\\ \bottomrule
\end{tabular}
\end{table}
\end{document}

Expecting your suggestions.

Thanks and regards,
Muthu.
Last edited by dmuthu_cse on Sat May 22, 2010 6:34 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

centering the last column of a table

Post by localghost »

You can either use the \tabularnewline command instead of \\ or modify your table head as shown below.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[includeheadfoot,margin=2cm]{geometry}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{amsmath}
\usepackage{array,booktabs}

\begin{document}
  \begin{table}[!ht]
    \caption{Dummy table}\label{tab:dummy}
    \centering
    \small
    \begin{tabular}{p{0.7in}p{0.7in}p{1.3in}cc>{\centering\arraybackslash}p{1in}}\toprule
      \textbf{A} & \textbf{P} & \textbf{T} & \textbf{C} & \textbf{TC} & \textbf{S}\\ \midrule
      --- & 24 & 3900 & $\boldsymbol{24\times 375=9000}$ & 12900 & --- \\ \bottomrule
    \end{tabular}
  \end{table}
\end{document}

Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
Post Reply