Graphics, Figures & TablesCentered Format for last Table Column

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
ohenri100
Posts: 8
Joined: Tue Aug 03, 2010 7:49 am

Centered Format for last Table Column

Post by ohenri100 »

Dear everybody,

I create a large table with many columns, and I want to format centering for the last column. However, I cannot do it. It has a error.

Code: Select all

\documentclass[oneside,openany]{book}
\usepackage{amsmath,amsxtra,amssymb,latexsym, amscd,amsthm, eqnarray}
\usepackage{indentfirst}
\usepackage{rotating}
\usepackage{fancyhdr}
\usepackage{picinpar}
\usepackage{floatflt}
\usepackage{float}
\usepackage{epic}
\usepackage{curves}
\usepackage{makeidx}
\usepackage{longtable}
\usepackage{tabularx}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{hhline}
\usepackage[tight,english]{minitoc}
\usepackage{fancybox}
\usepackage{graphicx}
\usepackage{color}
\usepackage[chapter]{algorithm}
\usepackage{algorithmic}
\usepackage[chapter]{algorithm}
\usepackage{calc,pifont}
\usepackage{bbding}
\usepackage{booktabs}
\usepackage{setspace}
\usepackage{hyperref}
\hypersetup{
	colorlinks=true,
    citecolor=black,
    filecolor=black,
    linkcolor=blue,
    urlcolor=black
}

\textheight 20.5truecm 
\textwidth 16truecm 
\parskip 3pt
\topmargin 0in
\headheight 0in
\headsep 0.5in
\oddsidemargin 0in
\evensidemargin 0in
\headheight 0pt
\footskip 10pt
\hoffset=5pt
\voffset=-20pt

\pagestyle{fancyplain}
\pagestyle{fancy}

\renewcommand{\headwidth}{16truecm}
\renewcommand{\chaptermark}[1]{\markboth{\it #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\it \thesection\ #1}}
\lhead[\fancyplain{}{\thepage}]{\fancyplain{}{\rightmark}}
\rhead[\fancyplain{}{\leftmark}] {\fancyplain{}{\thepage}}
\cfoot[]{}

\renewcommand{\mtctitle}{\ }
\setcounter{minitocdepth}{2}%A LATEX counter that indicates how many levels of headings
%                                                     will be displayed in the minitoc (default value is 2).
%]-

\begin{document}

\begin{table}[h]
%\begin{sidewaystable}
\caption{Performance Comparison}
\label{tab:Comparison}
\tiny
\setlength{\tabcolsep}{0.5pt}
\newcommand{\cent}{\centering}
\begin{tabular}{|m{1.4cm}|>{\centering}m{0.6cm}|>{\centering}m{0.6cm}|>{\centering}m{0.6cm}|>{\centering}m{0.7cm}|>{\centering}m{0.7cm}|>{\centering}m{0.7cm}|>{\centering}m{0.6cm}|>{\centering}m{1.7cm}|>{\centering}m{1.7cm}|>{\centering}m{1.7cm}|m{1.7cm}|} \hline
{Topology} & {$D_L$ (pF)} & {$H_{DD}$ (V)} &{$K_{DD}$ (mA)} & Power (mW)& $f_u$ (MHz) & {Avg. SR} (V/$\mu s$) & {$C_{c1}$, $C_{c2}$ (pF)} & {$LoM_S$} (MHz.pF/mW)& {$LoM_L$} $(V/\mu s.pF/mW)$ & {$OFoM_S$} (MHz.pF/mA) & {$OFoM_L$} $(V/\mu s.pF/mA)$ \\
\hline \hline
{ABCD} & {111} & {8} &{9.5} & {76} & {100} & {35} & {-} & {152}& {46} & {1053} & {368} \\
\hline
{NGKB} & {52} & {2} &{0.54} & {0.79} & {0.61} & {2.9} & {-} & {32}& {74} & {36} & {147} \\
\hline
{NAGCNR} & {100} & {2} &{0.2} & {0.4} & {1.8} & {0.79} & {30, 5.3} & {450}& {198} & {900} & {48} \\
\hline
{DHJMC} & {1000} & {2} &{0.2} & {0.4} & {1} & {0.36} & {55, 3} & {2500}& {900} & {5000} & {1800} \\
\hline
{AFGC} & {100} & {1.5} &{0.17} & {0.255} & {5.5} & {0.36} & {5.4, 4} & {2157}& {141} & {766} & {212} \\
\hline
{ACDFF} & {500} & {2} &{0.162} & {0.324} & {1.9} & {1} & {10, 3} & {2932}& {1543} & {5864} & {3086} \\
\hline
{TFRC} & {150} & {1.5} &{0.03} & {0.045} & {2.85} & {1.035} & {1.1, 0.92} & {9500}& {3450} & {14250} & {5175} \\
\hline
{DDDGF} & {500} & {1.5} &{0.15} & {0.225} & {1.4} & {2} & {30, 20} & {3111}& {4444} & {4667} & {6667} \\
\hline
{SRFDC} & {120} & {2} &{0.21} & {0.42} & {9} & {3.4} & {4} & {2571}& {971} & {5143} & {1943} \\
\hline
{RNMNR} & {500} & {3} &{0.085} & {0.255} & {2.4} & {1.8} & {11.5, 0.35} & {4706}& {3529} & {14118} & {10588} \\
\hline
{RSCFC} & {500} & {3} &{0.105} & {0.315} & {2.4} & {1.95} & {11.5, 0.35} & {3810}& {3095} & {11429} & {9286} \\
\hline
{RGBNC Low-Power} & {500} & {3} &{0.035} & {0.105} & {1.1} & {1.29} & {11.5, 0.35} & {5238}& {6143} & {15714} & {18429} \\
\hline
{RBG-FD} & {30} & {3} &{0.4} & {1.2} & {12} & {10} & {4,4} & {300}& {250} & {-} & {-} \\
\hline
{RBG-FD} & {500} & {3} &{0.4} & {1.2} & {20} & {8} & {5, 0.2} & {8333}& {3333} & {-} & {-} \\
\hline
{\textbf{RBGC (This Work)}} & {\textbf{10}} & {\textbf{1.8}} &{\textbf{0.9}} & {\textbf{0.9}} & {\textbf{50}} & {\textbf{0.2}} & {\textbf{0.02, 1}} & {\textbf{1235}} & {\textbf{52}}& {\textbf{5632}} & {\textbf{86.5}} \\
\hline
%{1} & {2} & {3} &{4} & {5} & {6} & {7} & {8} & {9}& {10} & {11} & {12} \\
%\hline
\end{tabular}
%\end{sidewaystable}
\end{table}

\end{document}
Please help me to solve this problem.
Thanks & Best Regards.
Who I am?

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
Stefan Kottwitz
Site Admin
Posts: 10321
Joined: Mon Mar 10, 2008 9:44 pm

Centered Format for last Table Column

Post by Stefan Kottwitz »

Hi,
ohenri100 wrote:It has a error.
in such cases it would be good if you would tell us the error message you got.

You posted a complete example, so we can test and see it ourselves, so it's ok here. Just the example could be smaller. There's a large amount of packages and settings which is not relevant to the tabular problem.

The error comes because \centering changes the meaning of the \\ command. The array package, which you use, provides a command \arraybackslash to fix it. Just change the last column format to

Code: Select all

>{\centering\arraybackslash}m{1.7cm}
You could have it easier if you would define your own column type, such as by

Code: Select all

\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}} 
in your preamble, and using C instead of m.

Stefan
LaTeX.org admin
ohenri100
Posts: 8
Joined: Tue Aug 03, 2010 7:49 am

Re: Centered Format for last Table Column

Post by ohenri100 »

Dear Stefan_K,

My example is extracted from my project. It, therefore, is rather complex. Because I want to easy for everybody to compile and to review the result. I think that it is useful for supporters.

I appreciate your help very much.
Again, Thank you very much.

Best regards.
--ohenri100--
Who I am?
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Centered Format for last Table Column

Post by cgnieder »

ohenri100 wrote:My example is extracted from my project. It, therefore, is rather complex. Because I want to easy for everybody to compile and to review the result. I think that it is useful for supporters.
What Stefan meant was that all the packages like indentfirst, fancyhdr, amsmath, makeidx, multicol, ... (and many more) and all the definitions concerning the page layout are in no way related to the problem and could have been left out to make the example clearer.

Regards
site moderator & package author
User avatar
Stefan Kottwitz
Site Admin
Posts: 10321
Joined: Mon Mar 10, 2008 9:44 pm

Re: Centered Format for last Table Column

Post by Stefan Kottwitz »

And readers who don't have each of those 34 packages installed, cannot test your example, they would errors because of missing packages. The shorter the test code, the higher the chance for a solution, as long as it's complete/compilable.

It's still a very good example so we could fix it for you, just imagine other readers google for the same problem and arrive here: they would understand problem and solution if it wasn't hidden in a large amount of personal code and settings.

Just to explain why short compilable examples are desirable in good questions: a public forum is also for future readers.

Not a big deal here, perhaps think of it in further questions. ;-)

Stefan
LaTeX.org admin
Post Reply