2

I want to ask how I can align this table so all the binary data are all exactly under the corresponding headers "x_i"?

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tabularx,ragged2e,booktabs,caption}
\newcolumntype{C}[1]{>{\Centering}m{#1}}
\renewcommand\tabularxcolumn[1]{C{#1}}
\begin{document}

\begin{table}
\caption{Table Title}‎
\centering
‎\begin{tabular}{||c c c||}
‎\hline‎
\text{$‎\mathcal{C}-x_1‎$‎‎}  &  \text{$‎\mathcal{C}^x_1‎$} & \text{$‎tail_{x_1}
(\mathcal{C})‎$}\\ [0.5ex]‎
‎\hline\hline‎
‎$‎x_2‎$ ‎‎$‎x_3‎$ ‎‎$‎x_4‎$‎   &    $‎x_2‎$ ‎‎$‎x_3‎$ ‎‎$‎x_4‎$  &    ‎$‎x_1$ $‎x_2‎$ ‎‎$‎x_3‎$ ‎‎$‎x_4‎$ \\ 
[0.5ex]‎
‎\hline\hline‎
‎0 0 0    &    0 0 0    &    0 1 0 1    \\ [0.5ex]‎
‎0 1 0    &    ‎0 1 0    &    ‎0 1 1 0    \\ [0.5ex]‎
‎0 1 1    &    ‎0 1 1    &    0 1 1 1    \\ [0.5ex]‎
1 0 0    &    1 0 0    &                  \\ [0.5ex]‎
‎1 0 1    &               &                  \\ [0.5ex]‎
1 1 0    &               &                  \\ [0.5ex]‎ 
1 1 1    &               &                  \\ [0.5ex]‎           
         &               &                   \\ [1ex]‎
‎\hline‎  ‎‎
\bottomrule[1.25pt]
\end {tabular}
\\[10pt]
\caption*{See This}
\end{table}‎ \vspace{0.5cm}‎ ‎

\end{document}
7
  • please, provide MWE!
    – Zarko
    Jul 28 '17 at 9:05
  • Excuse me, but I don't know what does "MWE" means!
    – Aref
    Jul 28 '17 at 9:44
  • Minimum Working Example Jul 28 '17 at 9:44
  • 1
    It means to provide code starting with \documentclass, and then list the relevant \usepackage calls and other initializations, continues with \begin{document} and a small bit of compileable code capable of demonstrating the issue, followed by \end{document}. Jul 28 '17 at 9:57
  • @Aref, sorry bit according to your reputation I (wrongly) assume, that you already familiar with MWE.
    – Zarko
    Jul 28 '17 at 10:04
3

In math testbed I compose code for following table:

enter image description here

MWE:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{amsmath, amssymb}
\usepackage{array, booktabs}
\newcommand\mcx[2]{\multicolumn{#1}{c}{$#2$}}

\usepackage[skip=1ex]{caption}

\begin{document}
    \begin{table}
\caption{Table title}
\label{tab:codetable}
    \centering
\setlength\tabcolsep{3pt}
\begin{tabular}{*{12}{>{\ttfamily}c}}
    \toprule
\mcx{3}{\mathcal{C} - x_1} &
    &   \mcx{3}{\mathcal{C}^x_1} &
        &  \mcx{4}{\text{tail}_{x_1}(\mathcal{C})}   \\
$x_2$ & $x_3$ & $x_4$ &
    & $x_2$ & $x_3$ & $x_4$ &
        & $x_1$ & $x_2$ & $x_3$ & $x_4$              \\
    \cmidrule{1-3}
    \cmidrule{5-7}
    \cmidrule{9-12}
0 & 0 & 0  &&  0 & 0 & 0   &&  0 & 1 & 0 & 1            \\
0 & 1 & 0  &&  0 & 1 & 0   &&  0 & 1 & 1 & 0            \\
0 & 1 & 1  &&  0 & 1 & 1   &&  0 & 1 & 1 & 1            \\
1 & 0 & 0  &&  1 & 0 & 0   &&    &   &   &              \\
1 & 0 & 1  &&    &   &     &&    &   &   &              \\
1 & 1 & 0  &&    &   &     &&    &   &   &              \\
1 & 1 & 1  &&    &   &     &&    &   &   &              \\
    \bottomrule
\end{tabular}
    \end{table}
\dots, see table \ref{tab:codetable}.
\end{document}

Edit: I had problems with your code. It seems that it contain hidden character or unknown coded characters which caused problems to my editor. That is main reason that I like to see preamble of your document. Now, hopefully I solve this problem (by retyping your code) :-)

2
  • C'mon, help us out. What is \mcx? Jul 28 '17 at 10:11
  • I have problems with OP code. it seems that (s)he use in editor a coding which is not compatible with my editor, so now I need to retype (collect) preamble from my "testbed". this will take some (short) time \newcommand\mcx[2]{\multicolumn{#1}{c}{$#2$}}
    – Zarko
    Jul 28 '17 at 10:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.