so, basically how do i specify p{width} and "c" at the same time for a
given column ? any help appreciated. see sample below what i have now.
\begin{table}[htb]
\caption{Material Properties}
\label{tab:prop1}
\begin{center}
\begin{tabular}{|p{2in}|c|}
\hline E$_1$ & 140 GPa \\\hline E$_2$ & 10 GPa \\\hline G$_{12}$ & 6.9
GPa \\\hline v$_{12}$ & 0.3 \\\hline
\end{tabular}
\end{center}
\end{table}
\usepackage{array}
\begin{table}[htb]
\caption{Material Properties}
\label{tab:prop1}
\centering
\begin{tabular}{>{\centering}p{2in}c}
E$_1$ & 140 GPa \\
E$_2$ & 10 GPa \\
G$_{12}$ & 6.9 GPa \\
v$_{12}$ & 0.3
\end{tabular}
\end{table}
Don't use vertical or horizontal lines, they spoil every table.
Have a look at the documentation of the package booktabs.
The same trick doesn't work as is for the /last/ column; for that
the correct way is to add >{\centering\arraybackslash} in front of
the p specifier.
Ciao
Enrico
Is there anyway to do it with vertical and horizontal lines specified ?
Its kinda requirement for the template here, so hard to get by with. if
i just add >{\centering} in front of the p specifier in my code, it
gives error and does not compile.
> > \begin{table}[htb]
> > \caption{Material Properties}
> > \label{tab:prop1}
> > \centering
> > \begin{tabular}{>{\centering}p{2in}c}
> > E$_1$ & 140 GPa \\
> > E$_2$ & 10 GPa \\
> > G$_{12}$ & 6.9 GPa \\
> > v$_{12}$ & 0.3
> > \end{tabular}
> > \end{table}
> >
> > Don't use vertical or horizontal lines, they spoil every table.
> > Have a look at the documentation of the package booktabs.
> >
> > The same trick doesn't work as is for the /last/ column; for that
> > the correct way is to add >{\centering\arraybackslash} in front of
> > the p specifier.
>
> Is there anyway to do it with vertical and horizontal lines specified ?
> Its kinda requirement for the template here, so hard to get by with. if
> i just add >{\centering} in front of the p specifier in my code, it
> gives error and does not compile.
If you really need lines, then put them in:
\begin{tabular}{|>{\centering}p{2in}|c|}
Ciao
Enrico
because you left out \usepackage{array}, i expect.
--
Robin Fairbairns, Cambridge
Ok, I think I am doing something wrong here. But it would be great if
someone can explain me whats the advantage of using table as an array
rather than without array ?
Array is giving me problem when i put \hline and gives error.
without array, i can use >{centering} , but i can use /hline, which i need.
so, basically, if I dont want to center align while using p{wd} , I can
just use :
\begin{table}[htb]
\caption{Material Properties}
\label{tab:prop1}
\begin{center}
\begin{tabular}{|p{2in}|c|}
\hline E$_1$ & 140 GPa \\\hline E$_2$ & 10 GPa \\\hline G$_{12}$ & 6.9
GPa \\\hline v$_{12}$ & 0.3 \\\hline
\end{tabular}
\end{center}
\end{table}
No array, nothing. simple table format that I use ALL the time. Now
just to center align, I have go through array ? isn't there any other
way to center align column in above table ?
huh, array is just the name of the package, it enables you to add special things
to arrays and tabulars etc.
I cannot see what the problem is with
>{\centering}p{2in}
(>{\centering\arraybackslash}p{in} if it's the last column)
--
/daleif (remove RTFSIGNATURE from email address)
LaTeX FAQ: http://www.tex.ac.uk/faq
LaTeX book: http://www.imf.au.dk/system/latex/bog/ (in Danish)
Remember to post minimal examples, see URL below
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=minxampl
Where do you find these advanced table formatting guidelines ? I have
looked all over the internet and found only basic table formatting in
literatures. Any recommened book or links ?
Thanks.
the latex companion edition 2 covers most things like this -- i would
be surprised if it didn't cover these ways to use array.sty. not
cheap, though -- definitely not a "pocket" book.
the faq covers some things in the area, but i'm not sure it does this,
precisely: since to first order i do all the writing myself, it
requires a coincidence of me having free time and inclination, and
actually realising that a particular question needs answering.
i bet there are other pages around that discuss it, but i don't know
any detail.
--
Robin Fairbairns, Cambridge