1

I am trying to gather some values in a Table, but the result is not as beautiful as I would like. Here's the Table I have

\begin{table}[!h]
\setlength\tabcolsep{0pt} % default: 6pt
\centering
\begin{tabularx}{\textwidth}{@{}c *{4}{C}}
\toprule
  \multicolumn{1}{c}{$w\lambda \in \CO_\lambda$}& \multicolumn{1}{@{}c}{\small$\pm(\lambda_1,\lambda_2)$} & \multicolumn{1}{@{}c}{\small$\pm (-\lambda_1,\lambda_1+\lambda_2)$} & \multicolumn{1}{@{}c}{\small$\pm (\lambda_1+2\lambda_2,-\lambda_2)$} & \multicolumn{1}{@{}c}{\small$\pm(\lambda_1 + 2\lambda_2,-\lambda_1-\lambda_2)$} \\
\midrule
$\sigma^{(0)}(w)$ & $1$ & $1$ & $1$ & $1$ \\[0.5ex]
$\sigma^{(1)}(w)$ & $1$ & $-1$ & $-1$ & $1$ \\[0.5ex]
$\sigma^{(2)}(w)$ & $1$ & $-1$ & $1$ & $-1$ \\[0.5ex]
$\sigma^{(3)}(w)$ & $1$ & $1$ & $-1$ & $-1$ \\
\bottomrule
\end{tabularx}
\vspace{0.1cm}
\caption{Sign weights $\sigma^{(j)}(w)$ of $e^{2 \pi i \inner{w\lambda}{z}}$ for elements in the orbit $\CO_{\lambda=(\lambda_1,\lambda_2)}$ of $C_2$.}
\label{signes de C2}
\end{table}

and here is the resulting Table:

enter image description here

But as you can see, in the first row, the elements are not spaced equally and I wonder why. I am aware that if I change the spacing in the first row it will change the spacing in the following row. I was aiming to make a Table that looks like this one:

enter image description here

5
  • Welcome to SE. Just a quick question: why are you using \multicolumn for cells that are just one-column wide?
    – Miyase
    Jun 2, 2022 at 17:51
  • Also, your LaTeX code is incomplete and non compilable. Please provide a Minimal Working Example, especially so we can see which packages you're using (at least the ones related to the question).
    – Miyase
    Jun 2, 2022 at 17:53
  • I would not use tabularx here, but no one can run your example as it uses undefined column types and is incomplete. Jun 2, 2022 at 17:55
  • 1
    your question is unclear as in the first image the four C columns appear to have equal width but you say "elements are not spaced equally" and then you say you want the second layout which has unequal column widths with column 2 a lot narrower than column 5 ?? You would get that with a standard tabular Jun 2, 2022 at 18:00
  • Thank you for your remarks and Davis is right, I confused myself and a simple tabular works properly!
    – LilGreg
    Jun 2, 2022 at 18:17

1 Answer 1

2

I suppose you're looking to use a tabular* rather than a tabularx environment. The widths of both environments are set to \textwidth in the following example. I suggest using the S column type (provided by the siunitx package) to typset the numbers in the four numerical columns.

enter image description here

\documentclass[12pt]{article} % or some other suitable document class
\usepackage[T1]{fontenc}
\usepackage[a4paper,margin=2.5cm]{geometry} % set page parameters suitably
\usepackage{booktabs}
\usepackage{tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}

\usepackage{amssymb}
\newcommand\CO{\mathcal{O}}
\usepackage{mathtools}
\DeclarePairedDelimiter\inner\langle\rangle

\usepackage{siunitx} % for 'S' col. type

\begin{document}

%% table 1 uses a 'tabularx' environment
\begin{table}[!t]
\setlength\tabcolsep{2pt} % default: 6pt
\begin{tabularx}{\textwidth}{@{} c *{4}{C} @{}}
\toprule
  $w\lambda \in \CO_\lambda$ & 
  \small$\pm(\lambda_1,\lambda_2)$ & 
  \small$\pm (-\lambda_1,\lambda_1+\lambda_2)$ & 
  \small$\pm (\lambda_1+2\lambda_2,-\lambda_2)$ & 
  \small$\pm(\lambda_1 + 2\lambda_2,-\lambda_1-\lambda_2)$ \\
\midrule
$\sigma^{(0)}(w)$ & $1$ &  $1$ &  $1$ &  $1$ \\[0.5ex]
$\sigma^{(1)}(w)$ & $1$ & $-1$ & $-1$ &  $1$ \\[0.5ex]
$\sigma^{(2)}(w)$ & $1$ & $-1$ &  $1$ & $-1$ \\[0.5ex]
$\sigma^{(3)}(w)$ & $1$ &  $1$ & $-1$ & $-1$ \\
\bottomrule
\end{tabularx}

\caption{Sign weights $\sigma^{(j)}(w)$ of $e^{2 \pi i 
\inner{w\lambda,z}}$ for elements in the orbit 
$\CO_{\lambda=(\lambda_1,\lambda_2)}$ of $C_2$.}
\label{signes de C2}
\end{table}


%% table 2 uses a 'tabular*' environment
\begin{table}[!h]
\setlength\tabcolsep{0pt} % default: 6pt
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} >{$}c<{$} *{4}{S[table-format=-1.0]}}
\toprule
  w\lambda \in \CO_\lambda & 
  {$\pm(\lambda_1,\lambda_2)$} & 
  {$\pm (-\lambda_1,\lambda_1+\lambda_2)$} & 
  {$\pm (\lambda_1+2\lambda_2,-\lambda_2)$} & 
  {$\pm(\lambda_1 + 2\lambda_2,-\lambda_1-\lambda_2)$} \\
\midrule
\sigma^{(0)}(w) & 1 &  1 &  1 &  1 \\
\sigma^{(1)}(w) & 1 & -1 & -1 &  1 \\
\sigma^{(2)}(w) & 1 & -1 &  1 & -1 \\
\sigma^{(3)}(w) & 1 &  1 & -1 & -1 \\
\bottomrule
\end{tabular*}

\caption{Same table as above, but with \texttt{tabular*} instead of \texttt{tabularx}}
\label{signes de C2 tabularstar}
\end{table}

\end{document}

You must log in to answer this question.

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