Generalplacing text in the center of the row

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
kostoglotov
Posts: 58
Joined: Sun Apr 27, 2008 12:50 pm

placing text in the center of the row

Post by kostoglotov »

Hi there,
I have created the table, where is the text in each row defaultly placed on the bottom. I need it in the middle. Any ide how?
cheers
a.k.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

placing text in the center of the row

Post by Stefan Kottwitz »

Hi,

you could use m-columns of the array package, like this example:

Code: Select all

\usepackage{array}
...
\begin{tabular}{m{1cm}m{1.5cm}}
  text & long text, two lines
\end{tabular}
Stefan
LaTeX.org admin
kostoglotov
Posts: 58
Joined: Sun Apr 27, 2008 12:50 pm

Re: placing text in the center of the row

Post by kostoglotov »

Cheers.
It works ok now. But how to center the columns now?
a.k.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Re: placing text in the center of the row

Post by Stefan Kottwitz »

Hi,

you wrote that you don't want the text at the bottom, you want it to be centered. So I understood you meant vertically centered.
Cells in m-columns are centered vertically. Table formatting is done by columns, not by rows.

Perhaps show us your table code to clarify. We will look then what we can change there.

Stefan
LaTeX.org admin
kostoglotov
Posts: 58
Joined: Sun Apr 27, 2008 12:50 pm

Re: placing text in the center of the row

Post by kostoglotov »

Before that I used {ccccc} - so the text was in the centre of the column but on the bottom of the row. I need it in the centre of both, bottom as well as row.
After applying what you have suggested I have text in the centre of the row but not column (it is now aligned to the left)
Here it is:
\begin{landscape}
\begin{table}[dp]
\centering
\begin{tabular}{m{1cm}m{6cm}m{6cm}m{2.2cm}m{2.2cm}}

\hline
& {\bf Fibre} & {\bf Laser spot} & {\bf Focus depth ($\mu$m)} & {\bf Peak position (nm)}\\
\hline\hline

a) & \includegraphics[scale=0.3]{DA} & \includegraphics[scale=0.3]{DB} & +20 & 647.485\\
b) & \includegraphics[scale=0.3]{BA} & \includegraphics[scale=0.3]{BB} & 0 & 647.514\\
c) & \includegraphics[scale=0.3]{CA} & \includegraphics[scale=0.3]{CB} & -20 & 647.542\\

\hline
\end{tabular}
\caption[Influence of focusing on the position of the 648 nm luminescence band.]{\textbf{Influence of focusing on the position of the 648 nm luminescence band.}}
\label{tab6-3}
\end{table}
\end{landscape}
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

placing text in the center of the row

Post by Stefan Kottwitz »

You could combine m and \centering. Let's create a new column type inside the preamble:

Code: Select all

\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
Later you can write:

Code: Select all

\begin{tabular}{M{1cm}M{6cm}M{6cm}M{2.2cm}M{2.2cm}}
Stefan
LaTeX.org admin
kostoglotov
Posts: 58
Joined: Sun Apr 27, 2008 12:50 pm

Re: placing text in the center of the row

Post by kostoglotov »

PERFECT! Thanks a lot.
a.k.
Post Reply