8

enter image description here

\begin{center}
\begin{tabular}{ c c c c c}
 $0$ & $c_2$ & $c_3$ & \ldots & $c_M$ \\ 
 $e_2$ & $c_2+e_2$ & $c_3+e_2$ & \ldots& $c_M+e_2$ \\  
 $e_3$ & $c_2+e_3$ & $c_3+e_3$ & \ldots& $c_M+e_3$ \\    
 $e_4$ & $c_2+e_4$ & $c_3+e_4$ & \ldots& $c_M+e_4$ \\  
 \vdots & \vdots & \vdots &  $\ddots$ &\vdots \\  
 $e_N$ & $c_2+e_N$ & $c_3+e_N$ & \ldots& $c_M+e_N$ \\ 
\end{tabular}

\end{center}

I have tried this code. But I how I can add those lines in the table?

2
  • 4
    welcome to tex.se! should table be rotated (as is shown in image in qeustion)?
    – Zarko
    Commented May 10, 2019 at 13:49
  • why would any one have a table at an angle like this? It makes it hard to read, no?
    – Nasser
    Commented May 13, 2019 at 4:08

4 Answers 4

17
\documentclass{article}
\begin{document}
\begin{center}
\begin{tabular}{|c|c c c c|}
\hline
 $0$ & $c_2$ & $c_3$ & \ldots & $c_M$ \\ \hline
 $e_2$ & $c_2+e_2$ & $c_3+e_2$ & \ldots& $c_M+e_2$ \\  
 $e_3$ & $c_2+e_3$ & $c_3+e_3$ & \ldots& $c_M+e_3$ \\    
 $e_4$ & $c_2+e_4$ & $c_3+e_4$ & \ldots& $c_M+e_4$ \\  
 \vdots & \vdots & \vdots &  $\ddots$ &\vdots \\  
 $e_N$ & $c_2+e_N$ & $c_3+e_N$ & \ldots& $c_M+e_N$ \\ \hline
\end{tabular}
\end{center}
\end{document}

enter image description here


This is the rotated solution: just use the amazing yslant in a TikZ node :) M. Al Jumaily's solution is excellent, but there is absolutely no need of such a complicated code.

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\node[yslant=-.1] {%
\begin{tabular}{|c|c c c c|}
\hline
 $0$ & $c_2$ & $c_3$ & \ldots & $c_M$ \\ \hline
 $e_2$ & $c_2+e_2$ & $c_3+e_2$ & \ldots& $c_M+e_2$ \\  
 $e_3$ & $c_2+e_3$ & $c_3+e_3$ & \ldots& $c_M+e_3$ \\    
 $e_4$ & $c_2+e_4$ & $c_3+e_4$ & \ldots& $c_M+e_4$ \\  
 \vdots & \vdots & \vdots &  $\ddots$ &\vdots \\  
 $e_N$ & $c_2+e_N$ & $c_3+e_N$ & \ldots& $c_M+e_N$ \\ \hline
\end{tabular}};
\end{tikzpicture}
\end{document}

enter image description here

Perfect parallelogram: even the baselines are now slanted :)

I am sure this is a perfect parallelogram. This is a proof, which is funny for extraordinary users :)

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\node[yslant=-1] {%
\begin{tabular}{|c|c c c c|}
\hline
 $0$ & $c_2$ & $c_3$ & \ldots & $c_M$ \\ \hline
 $e_2$ & $c_2+e_2$ & $c_3+e_2$ & \ldots& $c_M+e_2$ \\  
 $e_3$ & $c_2+e_3$ & $c_3+e_3$ & \ldots& $c_M+e_3$ \\    
 $e_4$ & $c_2+e_4$ & $c_3+e_4$ & \ldots& $c_M+e_4$ \\  
 \vdots & \vdots & \vdots &  $\ddots$ &\vdots \\  
 $e_N$ & $c_2+e_N$ & $c_3+e_N$ & \ldots& $c_M+e_N$ \\ \hline
\end{tabular}};
\end{tikzpicture}
\end{document}

enter image description here

The plus signs almost become some slanted X's.

6
  • 2
    Maybe you could use the array environment to get rid of all of the $s.
    – leandriis
    Commented May 10, 2019 at 14:12
  • @leandriis I just add some letters to the code given by the OP. Using array or tabular is his choice; maybe he has some intentions?
    – user156344
    Commented May 10, 2019 at 14:14
  • 1
    @L.F. :(( I edited my answer. Hope I am not downvoted anymore :))
    – user156344
    Commented May 12, 2019 at 17:25
  • 1
    Wow! I didn't know about the yslant option. Well done :) Commented May 12, 2019 at 19:05
  • 1
    @M.AlJumaily Thanks! Actually I also just accidentally learned it when I examined the "TikZ" and "PGF" nodes in the cover page of the manual :)) The "parallelogram-ness" of the table reminded me of those nodes.
    – user156344
    Commented May 13, 2019 at 1:56
11

from image in your question can be concluded, that you like to have rotated table ... :-)

enter image description here

\documentclass{article}
\usepackage{graphicx}

\usepackage{lipsum}
\begin{document}
\lipsum[1]
    \begin{center}
\rotatebox[origin=c]{-15}{
$
\begin{array}{|c|c c c c|}
    \hline
0       & c_2       & c_3       & \ldots & c_M      \\
    \hline
e_2     & c_2+e_2   & c_3+e_2   & \ldots & c_M+e_2  \\
e_3     & c_2+e_3   & c_3+e_3   & \ldots & c_M+e_3  \\
e_4     & c_2+e_4   & c_3+e_4   & \ldots & c_M+e_4  \\
\vdots  & \vdots    & \vdots    & \ddots & \vdots   \\
e_N     & c_2+e_N   & c_3+e_N   & \ldots & c_M+e_N  \\
    \hline
\end{array}
$}
    \end{center}
\lipsum[2]
\end{document}

... just for joy ...

2
  • 7
    The op's table is a parallelogram. :-) Commented May 10, 2019 at 17:45
  • 2
    @ArtificialOdorlessArmpit, you might be right. i draw only simple aproximation for it. write as parallelogram is clallenge, which can be solved with some drawing program ...
    – Zarko
    Commented May 10, 2019 at 18:11
6

Here's a solution which employs an array environment instead of a tabular environment. Note the absence of 42 [!] $ symbols.

enter image description here

\documentclass{article}
\begin{document}
\[
\begin{array}{ |c|c c c c|}
\hline
  0       & c_2     & c_3     & \ldots & c_M \\
\hline
  e_2     & c_2+e_2 & c_3+e_2 & \ldots & c_M+e_2 \\  
  e_3     & c_2+e_3 & c_3+e_3 & \ldots & c_M+e_3 \\    
  e_4     & c_2+e_4 & c_3+e_4 & \ldots & c_M+e_4 \\  
  \vdots  & \vdots  & \vdots  & \ddots & \vdots  \\  
  e_N     & c_2+e_N & c_3+e_N & \ldots & c_M+e_N \\ 
\hline
\end{array}
\]
\end{document}
5

Here is a Tikz solution:

Output

\documentclass[margin=1cm, tikz]{standalone}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture}
        %NOTE! Everyting is zero-based
        \def\ourInfo{{
            {0,"$c_2$","$c_3$", "$\cdots$", "$c_M$"},                     % Row 0
            {"$e_2$", "$c_2+e_2$", "$c_3+e_2$", "$\cdots$", "$c_M+e_2$"},   % Row 1
            {"$e_3$", "$c_2+e_3$", "$c_3+e_3$", "$\cdots$", "$c_M+e_3$"},   % Row 2
            {"$e_4$", "$c_2+e_4$", "$c_3+e_4$", "$\cdots$", "$c_M+e_4$"},   % Row 3
            {"$\cdot$", "$\cdot$", "$\cdot$", "$\cdots$", "$\cdot$"},       % Row 4
            {"$\cdot$", "$\cdot$", "$\cdot$", "$\cdots$", "$\cdot$"},       % Row 5
            {"$\cdot$", "$\cdot$", "$\cdot$", "$\cdots$", "$\cdot$"},       % Row 6
            {"$e_N$", "$c_2+e_N$", "$c_3+e_N$", "$\cdots$", "$c_M+e_N$"},   % Row 7
        }}
        \pgfmathsetmacro{\length}{7}% Zero based.
        % Loop through the 2D array, get a row, iterate through its cells,
        % print them and go to the next row.
        \foreach \i in {0, ..., \length}{% Rows
            \foreach \j in {0, ..., 4}{% Columns
            \pgfmathsetmacro{\data}{\ourInfo[\i][\j]};% Read the cell
             \node[rotate = -2, below] at (\j +\j/2 , -\i/2 -\j*0.1) {\data};
            }
        }
        % Drawing the lines
        \draw[thick, rotate = -4] (-0.2,0)--(6.75,0){};% Top horizontal
        \draw[thick, rotate = -4] (-0.2,-0.45)--(6.78,-0.45){};% Center horizontal
        \draw[thick, rotate = -4] (-0.06,-4)--(7.01,-4){};% Bottom horizontal
        \draw[thick, rotate = -4] (-0.215,0.01)--(-0.05,-4){};% Left vertical
        \draw[thick, rotate = -4] (0.6,0.01)--(0.75,-4){};% Center vertical
        \draw[thick, rotate = -4] (6.75,0.01)--(7,-4){};% Right vertical
    \end{tikzpicture}
\end{document}
0

You must log in to answer this question.

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