2

I have a wide table that I wish to center, caption and label.

\documentclass{amsart}
\usepackage{graphicx,amsmath,gensymb}
\usepackage[nobysame,lite,short-months]{amsrefs}
\begin{document}    
    \begin{table}
    \centering
    \begin{tabular}{*{6}{c|} c} 
        Polymer & $\sigma$(S/m) & 
        $\mathrm{T}_{\mathrm{eq}}$ $(\degree C)$ & Time Taken (s) & 
        Density $\rho$ (kg/$\mathrm{m}^3$) & $\mathrm{C}_{\mathrm{p}}$ (J/kgK)
        & K (W/mK) \\ \hline \hline
        & & & & & & \\[-.3cm]
        Kapton & $8.24 \times 10^{-11}$ & 435 & 556 & 1420 & 1090 & 
        $<1.4437, 1.4437, .1208>$ \\
        PEI & $5.44 \times 10^{-12}$ & 219 & 372 & 1270 & 1135 &
        $<1.5430,1.5430,.2215>$ \\
        FPE & $5.24 \times 10^{-11}$ & 361 & 955 & 1210 & 1729.41 &
        $<1.5232,1.5232,.2103>$ \\
        BCB-BNNS & $1.46 \times 10^{-12}$ & 204 & 349 & 1100 & 2300 & 
        $<1.8119,1.8119,3.1126>$
    \end{tabular}
\end{table}

\end{document}

However, when I run this code, the table is still too wide, and looks like the following.

Centering Issue

Is there any way to fix this inside the table environment?

Wei
  • 41
  • Welcome to TeX.SX! Your table is just too wide, apparently. It bleeds into margin, killing the centering mechanism –  Jun 12 '15 at 15:54
  • 1
  • 2
    You might also want to break some of your headers across two table rows. That way your "Time Taken (s)" and "Density etc." columns will be considerably narrower. – James Jun 12 '15 at 16:00
  • Welcome to TeX.SE. I also think you could narrow the top row cells by using more lines. – Alenanno Jun 12 '15 at 16:01
  • @Werner I read through that article once already, and I guess I interpreted it incorrectly; I had the makebox function around the table environment, instead of just the tabular. – Wei Jun 12 '15 at 16:04
  • @Werner I disagree about the duplicate: this is too wide a table, as it stands, to force centering with the \makebox method. – egreg Jun 12 '15 at 16:18
  • @egreg: The question requests centering of a too wide table, and the OP even posted an answer suggesting that \makebox worked. For me, still a clear duplicate. Your answer proposed an alternative suggestion to make the table less wide, but that wasn't part of the original question. – Werner Jun 12 '15 at 16:23
  • @Werner We're also interested in good typography. Simplistic solutions like \makebox[\textwidth]{...} can work for slightly oversized tables, not this one that had other typesetting issues. – egreg Jun 12 '15 at 17:27

5 Answers5

3

You can shrink the table to fit the textwidth provided you split the headers into two parts: main entry and unit.

I also abbreviated “Time Taken” into “Time”. This spares quite a bit.

I used booktabs, but you can add vertical rules if you really like them (I don't). More importantly, I used siunitx to get better appearance of the numbers and easier input.

\documentclass{amsart}
\usepackage{amsmath,siunitx,booktabs}
\begin{document}

\begin{table}
\centering
\addtolength{\tabcolsep}{-2.5pt}
\begin{tabular}{
 @{}l 
 S[table-format=1.2e-2]
 S[table-format=3.0]
 S[table-format=3.0]
 S[table-format=4.0]
 S[table-format=4.2]
 c@{}
}
\toprule
Polymer &
  {$\sigma$} &
  {$\mathrm{T}_{\mathrm{eq}}$} &
  {Time} & 
  {Density $\rho$} &
  {$\mathrm{C}_{\mathrm{p}}$} &
  {K}
\\
  &
  {(\si{S/m})} &
  {(\si{\celsius})} &
  {(\si{s})} &
  {(\si{kg/m^3})} &
  {(\si{J/kg.K})} &
  {(\si{W/m.K})}
\\ \midrule
Kapton   & 8.24e-11 & 435 & 556 & 1420 & 1090    & $\langle 1.4437, 1.4437, 0.1208\rangle$ \\
PEI      & 5.44e-12 & 219 & 372 & 1270 & 1135    & $\langle 1.5430, 1.5430, 0.2215\rangle$ \\
FPE      & 5.24e-11 & 361 & 955 & 1210 & 1729.41 & $\langle 1.5232, 1.5232, 0.2103\rangle$ \\
BCB-BNNS & 1.46e-12 & 204 & 349 & 1100 & 2300    & $\langle 1.8119, 1.8119, 3.1126\rangle$ \\
\bottomrule
\end{tabular}

\end{table}

\end{document}

enter image description here

egreg
  • 1,121,712
  • It's matter of taste, but if you use makecell`` package and join cells of column headers into\thead, then you have better overview over column headers. Of course, you need to manually broke headers into two lines, for example{\thead{Density $\rho$}\ (\si{kg/m^3})}}. – Zarko Jun 12 '15 at 16:34
0

it is centered, but too wide. Try

\documentclass{amsart}
\usepackage{graphicx,amsmath,gensymb}
\usepackage[nobysame,lite,short-months]{amsrefs}
\begin{document}    
    \begin{table}
    \centering
    \makebox[\textwidth]{%
    \begin{tabular}{*{6}{c|} c} 
        Polymer & $\sigma$(S/m) & 
        $\mathrm{T}_{\mathrm{eq}}$ $(\degree C)$ & Time Taken (s) & 
        Density $\rho$ (kg/$\mathrm{m}^3$) & $\mathrm{C}_{\mathrm{p}}$ (J/kgK)
        & K (W/mK) \\ \hline \hline
        & & & & & & \\[-.3cm]
        Kapton & $8.24 \times 10^{-11}$ & 435 & 556 & 1420 & 1090 & 
        $<1.4437, 1.4437, .1208>$ \\
        PEI & $5.44 \times 10^{-12}$ & 219 & 372 & 1270 & 1135 &
        $<1.5430,1.5430,.2215>$ \\
        FPE & $5.24 \times 10^{-11}$ & 361 & 955 & 1210 & 1729.41 &
        $<1.5232,1.5232,.2103>$ \\
        BCB-BNNS & $1.46 \times 10^{-12}$ & 204 & 349 & 1100 & 2300 & 
        $<1.8119,1.8119,3.1126>$
    \end{tabular}}
\end{table}

\end{document}

enter image description here

0

Thanks to Werner for the solution;

\begin{table}
\makebox[\textwidth][c]{
    \begin{tabular}{*{6}{c|} c} 
        Polymer & $\sigma$(S/m) & 
        $\mathrm{T}_{\mathrm{eq}}$ $(\degree C)$ & Time Taken (s) & 
        Density $\rho$ (kg/$\mathrm{m}^3$) & $\mathrm{C}_{\mathrm{p}}$ (J/kgK)
        & K (W/mK) \\ \hline \hline
        & & & & & & \\[-.3cm]
        Kapton & $8.24 \times 10^{-11}$ & 435 & 556 & 1420 & 1090 & 
        $<1.4437, 1.4437, .1208>$ \\
        PEI & $5.44 \times 10^{-12}$ & 219 & 372 & 1270 & 1135 &
        $<1.5430,1.5430,.2215>$ \\
        FPE & $5.24 \times 10^{-11}$ & 361 & 955 & 1210 & 1729.41 &
        $<1.5232,1.5232,.2103>$ \\
        BCB-BNNS & $1.46 \times 10^{-12}$ & 204 & 349 & 1100 & 2300 & 
        $<1.8119,1.8119,3.1126>$
    \end{tabular}}
\end{table}

What turned out to have happened was that I put the \makebox around the entire table, instead of just tabular.

Wei
  • 41
0

also you can wrap the tabular environment with the \adjustbox environment

\documentclass{amsart}
\usepackage{graphicx,amsmath,gensymb}
\usepackage[nobysame,lite,short-months]{amsrefs}
\usepackage{adjustbox}
\begin{document}    
\begin{table}
\centering
\begin{adjustbox}{max width=\textwidth}
\begin{tabular}{*{6}{c|} c} 
    Polymer & $\sigma$(S/m) & 
    $\mathrm{T}_{\mathrm{eq}}$ $(\degree C)$ & Time Taken (s) & 
    Density $\rho$ (kg/$\mathrm{m}^3$) & $\mathrm{C}_{\mathrm{p}}$ (J/kgK)
    & K (W/mK) \\ \hline \hline
    & & & & & & \\[-.3cm]
    Kapton & $8.24 \times 10^{-11}$ & 435 & 556 & 1420 & 1090 & 
    $<1.4437, 1.4437, .1208>$ \\
    PEI & $5.44 \times 10^{-12}$ & 219 & 372 & 1270 & 1135 &
    $<1.5430,1.5430,.2215>$ \\
    FPE & $5.24 \times 10^{-11}$ & 361 & 955 & 1210 & 1729.41 &
    $<1.5232,1.5232,.2103>$ \\
    BCB-BNNS & $1.46 \times 10^{-12}$ & 204 & 349 & 1100 & 2300 & 
    $<1.8119,1.8119,3.1126>$
\end{tabular}
\end{adjustbox}
\end{table}

\end{document}
Very23
  • 949
  • 1
  • 8
  • 19
0

Some improvements to @egreg's solution, and a simplification of code for column heads, with the makecell package:

\documentclass{amsart}
\usepackage{amsmath,siunitx, booktabs, tabularx, makecell}
\renewcommand\theadfont{\small}
\usepackage{showframe}

\begin{document}

\vspace*{3ex}
\begin{table}[!
h]
\centering\small\sisetup{inter-unit-product=\ensuremath {\cdot}}
\addtolength{\tabcolsep}{-2.5pt}
\begin{tabularx}{\linewidth}{
 @{}X
 S[table-format=1.2e-2]
 S[table-format=3.0]
 S[table-format=3.0]
 S[table-format=4.0]
 S[table-format=4.1]
 c@{}
}
\toprule
Polymer &
  {\thead{$\sigma$\\(\si{S/m})} } &
  {\thead{$\mathrm{T}_{\mathrm{eq}}$\\(\si{\celsius})}} &
  {\thead{Time\\(\si{s})}} &
  {\thead{Density $\rho$\\(\si{kg/m^3})}} &
 { \thead{$\mathrm{C}_{\mathrm{p}}$\\(\si{J/kg.K})}} &
  {\thead{K\\(\si{W/m.K})}}
\\ \midrule
Kapton & 8.24e-11 & 435 & 556 & 1420 & 1090 & $\langle 1.4437, 1.4437, 0.1208\rangle$ \\
\addlinespace[0.5ex]
PEI & 5.44e-12 & 219 & 372 & 1270 & 1135 & $\langle 1.5430, 1.5430, 0.2215\rangle$ \\
\addlinespace[0.5ex]
FPE & 5.24e-11 & 361 & 955 & 1210 & 1729.41 & $\langle 1.5232, 1.5232, 0.2103\rangle$ \\
\addlinespace[0.5ex]
BCB-BNNS & 1.46e-12 & 204 & 349 & 1100 & 2300 & $\langle 1.8119, 1.8119, 3.1126\rangle$ \\
\bottomrule
\end{tabularx}

\end{table}

\end{document} 

enter image description here

Bernard
  • 271,350