TeXworksHow to center a cell among several columns?

Information and discussion about TeXworks, an integrated LaTeX environment for several platforms
Post Reply
yaozhao
Posts: 57
Joined: Sat Oct 27, 2018 10:38 pm

How to center a cell among several columns?

Post by yaozhao »

Code: Select all

\begin{tabular}{l|ccc}
 & Year \\
\cline{2-4}
City & 2006 & 2007 & 2008 \\
\hline
London & 45789 & 46551 & 51298 \\
Berlin & 34549 & 32543 & 29870 \\
Paris & 49835 & 51009 & 51970 \\
\end{tabular}
This is a practical practice from a tutorial. There is only one difference. Now I want "Year" to be centered among 2-4 columns. How to do that?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics
User avatar
Stefan Kottwitz
Site Admin
Posts: 10266
Joined: Mon Mar 10, 2008 9:44 pm

How to center a cell among several columns?

Post by Stefan Kottwitz »

No problem, just write

\multicolumn{3}{c}{Year}

Here are three parameters (arguments):

3 is the number of columns to span
c is the formatting I chose here (like a column formatting specifier)
then the actual content of the big cell

Stefan
LaTeX.org admin
yaozhao
Posts: 57
Joined: Sat Oct 27, 2018 10:38 pm

How to center a cell among several columns?

Post by yaozhao »

Great, thanks!
I guess c here denotes center?
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

How to center a cell among several columns?

Post by Johannes_B »

Yes. C is for center.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply