[Tex/LaTex] Change alignment locally inside a tabular cell

horizontal alignmenttables

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}

Best Answer

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

Related Question