Graphics, Figures & Tables ⇒ How can I specify column width and then centering text?
-
- Posts: 17
- Joined: Sat Oct 10, 2009 9:28 pm
How can I specify column width and then centering text?
Hi all.
How can I specify column width and then centering text in tables? I tried p{2cm},however, the text will left aligned.
How can I specify column width and then centering text in tables? I tried p{2cm},however, the text will left aligned.
- localghost
- Site Moderator
- Posts: 9201
- Joined: Fri Feb 02, 2007 12:06 pm
How can I specify column width and then centering text?
Take a look at the array package. Beside other features it lets you specify which commands are active in a column.
In this context you may also look at tabularx and ragged2e.
Best regards
Thorsten
Code: Select all
\begin{tabular}{>{\centering}p{10cm}}
% contents
\end{tabular}
Best regards
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]
¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
Board Rules
Avoidable Mistakes[/size]
¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
- Stefan Kottwitz
- Site Admin
- Posts: 10290
- Joined: Mon Mar 10, 2008 9:44 pm
How can I specify column width and then centering text?
Hi,
use \centering and the array package:
Stefan
use \centering and the array package:
Code: Select all
\usepackage{array}
...
\begin{tabular}{>{\centering\arraybackslash}p{2cm}...}
LaTeX.org admin
-
- Posts: 17
- Joined: Sat Oct 10, 2009 9:28 pm
Re: How can I specify column width and then centering text?
Thank you so much guys. That was really quick replies!
-
- Posts: 17
- Joined: Sat Oct 10, 2009 9:28 pm
Re: How can I specify column width and then centering text?
By the way, how can i centering the whole table?
- localghost
- Site Moderator
- Posts: 9201
- Joined: Fri Feb 02, 2007 12:06 pm
How can I specify column width and then centering text?
That's best done within a table environment.
Code: Select all
\begin{table}[!ht]
\caption{Dummy table}\label{tab:dummy}
\centering
\begin{tabular}{>{\centering}p{10cm}}
% contents
\end{tabular}
\end{table}
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]
¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
Board Rules
Avoidable Mistakes[/size]
¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
- Stefan Kottwitz
- Site Admin
- Posts: 10290
- Joined: Mon Mar 10, 2008 9:44 pm
How can I specify column width and then centering text?
Use the center environment:
or, if you want to use a table environment, use \centering instead, for instance:
Stefan
Code: Select all
\begin{center}
\begin{tabular}
...
\end{tabular}
\end{center}
Code: Select all
\begin{table}[htbp]
\centering
\begin{tabular}
...
\end{tabular}
\end{table}
LaTeX.org admin
-
- Posts: 17
- Joined: Sat Oct 10, 2009 9:28 pm
Re: How can I specify column width and then centering text?
It's working! Thank you sooo much.