## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ Centered Format for last Table Column Topic is solved

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

### Centered Format for last Table Column

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.

1. \documentclass[oneside,openany]{book}
2. \usepackage{amsmath,amsxtra,amssymb,latexsym, amscd,amsthm, eqnarray}
3. \usepackage{indentfirst}
4. \usepackage{rotating}
5. \usepackage{fancyhdr}
6. \usepackage{picinpar}
7. \usepackage{floatflt}
8. \usepackage{float}
9. \usepackage{epic}
10. \usepackage{curves}
11. \usepackage{makeidx}
12. \usepackage{longtable}
13. \usepackage{tabularx}
14. \usepackage{multicol}
15. \usepackage{multirow}
16. \usepackage{hhline}
17. \usepackage[tight,english]{minitoc}
18. \usepackage{fancybox}
19. \usepackage{graphicx}
20. \usepackage{color}
21. \usepackage[chapter]{algorithm}
22. \usepackage{algorithmic}
23. \usepackage[chapter]{algorithm}
24. \usepackage{calc,pifont}
25. \usepackage{bbding}
26. \usepackage{booktabs}
27. \usepackage{setspace}
28. \usepackage{hyperref}
29. \hypersetup{
31. citecolor=black,
32. filecolor=black,
34. urlcolor=black
35. }
36.
37. \textheight 20.5truecm
38. \textwidth 16truecm
39. \parskip 3pt
40. \topmargin 0in
43. \oddsidemargin 0in
44. \evensidemargin 0in
46. \footskip 10pt
47. \hoffset=5pt
48. \voffset=-20pt
49.
50. \pagestyle{fancyplain}
51. \pagestyle{fancy}
52.
54. \renewcommand{\chaptermark}[1]{\markboth{\it #1}{}}
55. \renewcommand{\sectionmark}[1]{\markright{\it \thesection\ #1}}
58. \cfoot[]{}
59.
60. \renewcommand{\mtctitle}{\ }
61. \setcounter{minitocdepth}{2}%A LATEX counter that indicates how many levels of headings
62. % will be displayed in the minitoc (default value is 2).
63. %]-
64.
65. \begin{document}
66.
67. \begin{table}[h]
68. %\begin{sidewaystable}
69. \caption{Performance Comparison}
70. \label{tab:Comparison}
71. \tiny
72. \setlength{\tabcolsep}{0.5pt}
73. \newcommand{\cent}{\centering}
74. \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
75. {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)$ \\
76. \hline \hline
77. {ABCD} & {111} & {8} &{9.5} & {76} & {100} & {35} & {-} & {152}& {46} & {1053} & {368} \\
78. \hline
79. {NGKB} & {52} & {2} &{0.54} & {0.79} & {0.61} & {2.9} & {-} & {32}& {74} & {36} & {147} \\
80. \hline
81. {NAGCNR} & {100} & {2} &{0.2} & {0.4} & {1.8} & {0.79} & {30, 5.3} & {450}& {198} & {900} & {48} \\
82. \hline
83. {DHJMC} & {1000} & {2} &{0.2} & {0.4} & {1} & {0.36} & {55, 3} & {2500}& {900} & {5000} & {1800} \\
84. \hline
85. {AFGC} & {100} & {1.5} &{0.17} & {0.255} & {5.5} & {0.36} & {5.4, 4} & {2157}& {141} & {766} & {212} \\
86. \hline
87. {ACDFF} & {500} & {2} &{0.162} & {0.324} & {1.9} & {1} & {10, 3} & {2932}& {1543} & {5864} & {3086} \\
88. \hline
89. {TFRC} & {150} & {1.5} &{0.03} & {0.045} & {2.85} & {1.035} & {1.1, 0.92} & {9500}& {3450} & {14250} & {5175} \\
90. \hline
91. {DDDGF} & {500} & {1.5} &{0.15} & {0.225} & {1.4} & {2} & {30, 20} & {3111}& {4444} & {4667} & {6667} \\
92. \hline
93. {SRFDC} & {120} & {2} &{0.21} & {0.42} & {9} & {3.4} & {4} & {2571}& {971} & {5143} & {1943} \\
94. \hline
95. {RNMNR} & {500} & {3} &{0.085} & {0.255} & {2.4} & {1.8} & {11.5, 0.35} & {4706}& {3529} & {14118} & {10588} \\
96. \hline
97. {RSCFC} & {500} & {3} &{0.105} & {0.315} & {2.4} & {1.95} & {11.5, 0.35} & {3810}& {3095} & {11429} & {9286} \\
98. \hline
99. {RGBNC Low-Power} & {500} & {3} &{0.035} & {0.105} & {1.1} & {1.29} & {11.5, 0.35} & {5238}& {6143} & {15714} & {18429} \\
100. \hline
101. {RBG-FD} & {30} & {3} &{0.4} & {1.2} & {12} & {10} & {4,4} & {300}& {250} & {-} & {-} \\
102. \hline
103. {RBG-FD} & {500} & {3} &{0.4} & {1.2} & {20} & {8} & {5, 0.2} & {8333}& {3333} & {-} & {-} \\
104. \hline
105. {\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}} \\
106. \hline
107. %{1} & {2} & {3} &{4} & {5} & {6} & {7} & {8} & {9}& {10} & {11} & {12} \\
108. %\hline
109. \end{tabular}
110. %\end{sidewaystable}
111. \end{table}
112.
113. \end{document}

Thanks & Best Regards.
Who I am?

Tags:

Stefan Kottwitz
Posts: 8077
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:
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

1. >{\centering\arraybackslash}m{1.7cm}

You could have it easier if you would define your own column type, such as by

1. \newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}

Stefan

ohenri100
Posts: 8
Joined: Tue Aug 03, 2010 7:49 am
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?

cgnieder
Site Moderator
Posts: 1955
Joined: Sat Apr 16, 2011 7:27 pm
Location: Germany
Contact:
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
Clemens
------------------------------

Stefan Kottwitz
Posts: 8077
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:
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