Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to align some specific cells inside a LaTeX table. I tried using center enviroment inside cell, but it didn't work-Error: Undefined Control Sequence \begin{center}. I also tried with \centering which produces no errors, however it doesn't do the job. My MWE is the following

\documentclass[11pt,a4paper]{article}
\usepackage[english,greek]{babel}
\usepackage[iso-8859-7]{inputenc}
\usepackage{kerkis}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{units}
\usepackage{array}
\begin{document}
\begin{table}[H]
\begin{center}
\begin{tabular}{l r r r}
\hline
{} & {\centering \textbf{Ενέργεια}} & {\centering \textbf{Ενέργεια}} & {\centering     \textbf{Μέσος Αριθμός}}\\
{\textbf{Αέριο}} & {\centering \textbf{Διέγερσης}} & {\centering \textbf{Ιονισμού}} &     {\centering \textbf{Παραγωγής Ζεύγους}}\\
{} & {\centering $[eV]$} & {\centering $[eV]$} & {}\\
\hline
{} & {} & {} & {} \\
{$Ar$} & {$11.6$} & {$15.8$} & {$26$} \\
{$CO_2$} & {$10.0$} & {$13.7$} & {$33$} \\
{$CH_4$} & {$12.6$} & {$14.5$} & {$28$} \\
{$Kr$} & {$10.0$} & {$14.0$} & {$24$} \\
{$Xe$} & {$8.4$} & {$12.1$} & {$22$} \\
\hline
\end{tabular}
\caption{Μέσος αριθμός παραγωγής ζεύγους για διάφορα αέρια}
\label{tab:Excitation-Ionization}
\end{center}
\end{table}
\end{document}
share|improve this question
1  
\multicolumn{1}{c}{\textbf{Ενέργεια}} for the first cell you want to treat in a special way and similarly for the others. You don't need braces around the cell contents. –  egreg Sep 19 '12 at 9:38
    
Thank you very much for your answer! As far as braces are concerned I am having a template, I pasted and I just forgot to delete them...! –  Thanos Sep 19 '12 at 11:11
add comment

1 Answer 1

up vote 4 down vote accepted

A single cell alignment can be changed with \multicolumn{1}{c}{...} (for centering it).

However I suggest you some improvements to your table:

\documentclass[11pt,a4paper]{article}

\usepackage[LGRx,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,greek]{babel}

\usepackage{kerkis}

\usepackage{array,booktabs}

\usepackage{siunitx}
\sisetup{unit-mode=math}

\begin{document}

\begin{table}
\centering
\begin{tabular}{>{\fontencoding{T1}\selectfont}l *{2}{S[table-format=2.1]}S[table-format=2]}
\toprule
\multicolumn{1}{l}{\textbf{Αέριο}} &
 \multicolumn{1}{c}{\textbf{Ενέργεια}} &
 \multicolumn{1}{c}{\textbf{Ενέργεια}} &
 \multicolumn{1}{c}{\textbf{Μέσος Αριθμός}} \\
 &
 \multicolumn{1}{c}{\textbf{Διέγερσης}} &
 \multicolumn{1}{c}{\textbf{Ιονισμού}} &
 \multicolumn{1}{c}{\textbf{Παραγωγής Ζεύγους}} \\
 &
 \multicolumn{1}{c}{(\si{\electronvolt})} &
 \multicolumn{1}{c}{(\si{eV})} & \\
\midrule
Ar & 11.6 & 15.8 & 26 \\
CO$_2$ & 10.0 & 13.7 & 33 \\
CH$_4$ & 12.6 & 14.5 & 28 \\
Kr & 10.0 & 14.0 & 24 \\
Xe & 8.4 & 12.1 & 22 \\
\bottomrule
\end{tabular}
\caption{Μέσος αριθμός παραγωγής ζεύγους για διάφορα αέρια}
\label{tab:Excitation-Ionization}
\end{table}

\end{document}

I'd prefer UTF-8 to ISO-8859-7, also if it requires some juggling for typesetting Latin text.

Element symbols should be upright, as units. With siunitx it's easy to get correct alignment of numbers. Note the two alternative ways to express the eV unit.

enter image description here

share|improve this answer
    
Thank you for your answer...I am afraid that your code isn't working on my system... I cannot use utf8 encoding let alone despite succesfully installing siunitx... –  Thanos Sep 19 '12 at 16:50
    
@Thanos The \multicolumn{1}{c}{...} bit is surely working, though. –  egreg Sep 19 '12 at 17:06
    
Yes, it does! But I think that siunitx is a great package...While I am trying to use it I get File 'exp13.sty' not found, despite having already installed package siunitx... –  Thanos Sep 20 '12 at 6:26
    
Quite frankly, though, your output is much better than mine!Realy cool!!! Is there a way to do it? I supose I really need siunitx... As far as the encoding is concerned, I have a hunch that utf8 may solve other issues like tex.stackexchange.com/questions/69780/change-bibtexs-language –  Thanos Sep 20 '12 at 6:35
1  
@Thanos You really need to upgrade your TeX distribution. –  egreg Sep 20 '12 at 9:37
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.