3

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}
David Carlisle
  • 757,742
Thanos
  • 12,446
  • 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 09: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

1 Answers1

4

Update

Usage of the option LGRx is not needed any longer.


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

egreg
  • 1,121,712
  • 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 06: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 http://tex.stackexchange.com/questions/69780/change-bibtexs-language – Thanos Sep 20 '12 at 06:35
  • 1
    @Thanos You really need to upgrade your TeX distribution. – egreg Sep 20 '12 at 09:37
  • You really think so...?The thing is that I am on the middle of writing my thesis, so I would prefer not to risk it at the moment... – Thanos Sep 20 '12 at 09:49
  • @Thanos That's really a good justification; but then you have to bear with the limitations of your current TeX distribution. – egreg Sep 20 '12 at 10:01
  • That is a good point... I'll try to upgrade as soon as I will finish my thesis!Thank you!!! – Thanos Sep 20 '12 at 10:10