0

I've been trying to create a table that could go between two pages. I've looked at the longtable package but does not work well with twocolumn. So I decided to take a look at the xtabs package and seems to be the one for me.

I have a table with 4 columns (I'm doing one to list some costants). The first one contains the symbol, the second one the name, the third the value and the last one the unit of measure. My problem lies in the second and in the fourth one.

What I would like to have is a style of the columns that is a centered both vertically and horizontally. I'm using this style: c >{\centering}p{1.8cm} c p{1.5cm}. I'm not really achieving what I would like in any of them. The result As you can see, the first column is not centered vertically unless I'm using a \multirow call and the last column is not centered. If I try and replicate the style of the second one, I get error with several errors all saying Extra alignment tab has been changed to \cr. &

This is the "working" MWE

\documentclass[8pt, a4paper, twocolumn]{extarticle}

\usepackage{extsizes}
\usepackage[italian]{babel}
\usepackage{amsmath,amsfonts,amssymb,mathtools,calrsfs}
\usepackage[latin1]{inputenc}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{xtab, booktabs, array}

\everymath{\displaystyle}

\renewcommand*{\arraystretch}{2}

\begin{document}
\section{Costanti}

\tablefirsthead{\toprule Simbolo& Nome & Valore & Unità di misura \\ \midrule}
\tablehead{Simbolo& Nome & Valore & Unità di misura \\ \midrule}
\tablelasttail{\bottomrule}

\begin{center}
    \begin{xtabular}{c >{\centering}p{1.8cm} c p{1.5cm}}
            $g$ & Accelerazione gravitazionale & $9.81$ & $\frac{\text{m}}{\text{s}^2}$\\ \hline
            $G$ & Costante di Gravitazione Universale & $6.67\cdot10^{-11}$ & $\frac{\text{Nm}^2}{\text{kg}^2}$\\\hline
            \multirow{5}[1]{*}{$p_{atm}$} & \multirow{5}[1]{1.8cm}{Pressione atmosferica} & $1$ & $\text{atm}$\\
                        && $1.01\cdot10^{5}$ & $\text{Pa}$\\ 
                && $760$ & $\text{mm}\,\text{Hg}$\\
                && $1.01\cdot10^{5}$ & $\frac{\text{N}}{\text{m}^2}$\\
            $N_A$ & Numero di Avogadro & $6.02\cdot10^{23}$ & /\\ \hline
            $V_m$ & Volume occupato da Gas in STP & $22.4$ & $\text{l}$\\ \hline
            \multirow{2}[1]{*}{$R$} & \multirow{2}[1]{1.8cm}{Costante universale dei Gas} & $0.0821$ & $\frac{\text{l}\cdot\text{atm}}{\text{nK}}$\\
            && $8.31$ & $\frac{\text{J}}{\text{nK}}$\\ \hline
                && $1$ & $\text{bar}$\\ \hline
            \multirow{2}[1]{*}{$c_{H_2O}$} & \multirow{2}[1]{1.8cm}{Calore specifico dell'acqua} & $4.186\cdot10^3$ & $\frac{\text{C}}{\text{kg}\cdot\text{K}}$\\
                && $1$ & $\frac{\text{cal}}{\text{g}\cdot\text{K}}$\\\hline
            $\lambda_f$ & Calore di fusione dell'acqua & $3.335\cdot10^5$ & $\frac{\text{J}}{\text{Kg}}$\\\hline
            $\lambda_v$ & Calore di vaporizzazione dell'acqua & $2.257\cdot10^6$ & $\frac{\text{J}}{\text{Kg}}$\\\hline
    \end{xtabular}
\end{center}
\end{document}

The other one just changes the definition of the table to \begin{xtabular}{c >{\centering}p{1.8cm} c >{\centering}p{1.5cm}}

My question now is: how can I get the results I want while maintaining the twocolumn and the table that goes to the other page? I would like to have the columns centered both vertically and horizontally inside a table that can span multiple pages/columns.

Thanks for any answers.

4
  • 1
    eek don't do \everymath{\displaystyle} Sep 9, 2017 at 17:56
  • I'm quite sure that it is not the problem here. Is just an easier way for me to typeset the whole document (the actual one is much bigger) and I prefer using display style even inside text.
    – gjkf
    Sep 9, 2017 at 18:44
  • no it's unrelated to the table (for that you probably just want to use m rather than p and \centering\arraybackslash) but see tex.stackexchange.com/a/323375/1090 Sep 9, 2017 at 18:53
  • Oh I see. Thanks for the link. And yes! It worked! I had also to change a bit the multirow definition but I can manage. I'll add this as an answer for others to see.
    – gjkf
    Sep 9, 2017 at 19:00

1 Answer 1

2

Thanks to David Carlisle in the comments, I got it to work.

Basically just needed to change the definition of the table to \begin{xtabular}{c >{\centering\arraybackslash}m{1.8cm} c >{\centering\arraybackslash}m{1.5cm}}. That centered everything like I wanted.

I also added a \centering inside the multirow environment to make it all nice. This is the result Workin

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .