3

I want to create a table similar to one shown below. I know how to create a table using tabular environment but I don't know

  1. how to put these red horizontal lines that eliminate few of the entries in this table.
  2. how to group these lines with table so that incase size of table needs some adjustment, the lines also get adjusted automatically.

enter image description here

5
  • The \usepackage{soul} provides a way for striking out the sentences in latex. Go through with it for more details.
    – M S
    Commented May 10, 2016 at 4:02
  • @Siba Mishra: Will it work through a table row?
    – Bernard
    Commented May 10, 2016 at 8:55
  • Could you post the code of what you've done so far?
    – Bernard
    Commented May 10, 2016 at 8:56
  • @Bernard you are right. I have heard about soul. But after writing the code, it's not perfectly working for a table. For striking out, every time, you have to use \st{} for each table cell. I am thinking how to define a macro for the same.
    – M S
    Commented May 10, 2016 at 10:30
  • 1
    This post was very helpful: tex.stackexchange.com/questions/231880/…
    – celia
    Commented Oct 11, 2016 at 3:45

1 Answer 1

2

Since you seem to want to have shadows, it might be easier to draw the whole thing in TikZ.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{calc,matrix,shadows.blur,decorations.pathreplacing}
\tikzset{shadowed/.style={decorate,decoration={
show path construction,
lineto code={
\draw[#1!50!gray,opacity=0.5] ([xshift=0.5ex,yshift=-0.25ex]\tikzinputsegmentfirst) -- ([xshift=0.5ex,yshift=-0.25ex]\tikzinputsegmentlast);
\draw[#1] (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast);
}}}}
\begin{document}
\begin{tikzpicture}[buffy/.style={circle,draw,inner sep=3pt,fill=#1,blur shadow}]
\matrix[matrix of nodes,nodes={align=center,anchor=center},row sep=4pt] (mat)
 {  $x_1$ & $x_2$ & $x_3$\\
   |[buffy=blue]| & |[buffy=blue]| & |[buffy=blue]|\\
   |[buffy=blue]| & |[buffy=blue]| & |[buffy=gray]|\\
   |[buffy=blue]| & |[buffy=gray]| & |[buffy=blue]|\\
   |[buffy=blue]| & |[buffy=gray]| & |[buffy=gray]|\\     
   |[buffy=gray]| & |[buffy=blue]| & |[buffy=blue]|\\   
   |[buffy=gray]| & |[buffy=blue]| & |[buffy=gray]|\\   
   |[buffy=gray]| & |[buffy=gray]| & |[buffy=blue]|\\   
   |[buffy=gray]| & |[buffy=gray]| & |[buffy=gray]|\\
    };
\path ($(mat-1-1.north east)!0.5!(mat-1-2.north west)$) coordinate (auxL)
 ($(mat-1-2.north east)!0.5!(mat-1-3.north west)$) coordinate (auxR)
 ($(mat-1-1.south west)!0.5!(mat-2-1.north west)$) coordinate (auxT);
\draw[shadowed=black] (auxL |- mat.north) -- (auxL |- mat.south)
(auxR |- mat.north) -- (auxR |- mat.south)
(auxT -| mat.west) -- (auxT -| mat.east);
\begin{scope}[thick]
\foreach \X in {5,7,8,9}
{\draw[shadowed=red] (mat-\X-1.center -| mat.west) -- (mat-\X-3.center -| mat.east);}
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

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