Graphics, Figures & TablesStriking out rows and columns

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
dmuthu_cse
Posts: 97
Joined: Fri Sep 04, 2009 4:56 pm

Striking out rows and columns

Post by dmuthu_cse »

Hello friends,

I am creating a special kind of table with horizontal and vertical lines.

But in addition to the normal horizontal and vertical lines for sepearting items, i need some lines extra for striking out entire row or entire column.

To strike out entire row, i am using

Code: Select all

\makebox[0pt][l]{\rule[0.1cm]{0.11\textwidth}{0.7pt}}
But i don't have any idea of how to create it for vertical lines (for strikingout columns).

For better understanding, i have attached the table which i want to create. I will be thankful if you can code the table for me..

Please help.

Regards
Muthu
Attachments
Now draw Horizontal and vertical lines.pdf
(60.14 KiB) Downloaded 681 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Striking out rows and columns

Post by localghost »

I'm not aware of a solution with the tabular environment. But a matrix with pgf/tikZ might do the trick.

Code: Select all

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}
  \begin{tikzpicture}
    \matrix (magic) [%
      matrix of nodes,
      nodes=draw,
      text width=5mm,
      text badly centered
    ] {%
      0 & 6 & 11 \\
      0 & 3 & 4 \\
      0 & 0 & 0 \\
    };
    \draw[thick,red] (magic-1-1.north) -- (magic-3-1.south);
    \draw[thick,red] (magic-3-1.west) -- (magic-3-3.east);
  \end{tikzpicture}
\end{document}

Best regards
Thorsten
dmuthu_cse
Posts: 97
Joined: Fri Sep 04, 2009 4:56 pm

Re: Striking out rows and columns

Post by dmuthu_cse »

Hello Thorsten,

Thanks for the quick reply.

It is working fine in PDFlatex.

But my main tex file, includes eps figures, which is not executing with PDFLatex. So I normally perform,
i) Latex compilation and
ii) DVI to PDF conversion, as I am using LED editor, with MikTex 2.7 on Windows OS.

So, please let me know, how to tackle this..

Regards,
Muthu
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: Striking out rows and columns

Post by josephwright »

pgf code works with both PDF and DVI output: you should have no issues using the example with EPS graphics.
Joseph Wright
dmuthu_cse
Posts: 97
Joined: Fri Sep 04, 2009 4:56 pm

Striking out rows and columns

Post by dmuthu_cse »

Hello joseph,

It is working fine now.. I tried executing in PDFlatex with .pdf images instead of .eps images.

But the table has very thick lines, in the inner part. You can see the difference between the boundary lines and inner lines of table.

And the table gets disturbed when we use "--" as one of the table item.

I am enclosing the code,

Code: Select all

\documentclass{book}
\usepackage{tikz-inet}
\usepackage{graphicx}
\usetikzlibrary{matrix}

\begin{document}
\begin{center}
\small
      \begin{tikzpicture}

    \matrix (magic) [%
      matrix of nodes,
      nodes=draw,
      text width=4.1mm,
      text badly centered
    ] 
{%
0 & 40 & $-$ & 0\\
10 & 20 & 0 & 0\\
20 & 0 & 20 & $-$\\
10 & 0 & 40 & 40\\
    };
\draw[thin,black] (magic-1-2.north) -- (magic-4-2.south);
    \draw[thin,black] (magic-1-1.west) -- (magic-1-4.east);
    \draw[thin,black] (magic-2-1.west) -- (magic-2-4.east);
  \end{tikzpicture}
\end{center}
\end{document}
It will be nice if the innerlines of the table also looks the same as the outer boundary.

Thanking you,

Regards,
Muthu
Attachments
k.PDF
(9.25 KiB) Downloaded 553 times
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Striking out rows and columns

Post by gmedina »

Hi Muthu,

instead of drawing the lines with the draw option for the nodes, you can use \draw commands:

Code: Select all

\documentclass{book}
\usepackage{tikz-inet}
\usepackage{graphicx}
\usetikzlibrary{matrix}

\begin{document}
\begin{center}
\small
      \begin{tikzpicture}

    \matrix (magic) [%
      matrix of nodes,
      text width=4.1mm,text height=1mm,
      text badly centered
    ]
{%
0 & 40 & $-$ & 0\\
10 & 20 & 0 & 0\\
20 & 0 & 20 & $-$\\
10 & 0 & 40 & 40\\
    };
    % striking out lines
    \draw[thin,help lines] (magic-1-2.north) -- (magic-4-2.south);
    \draw[thin,help lines] (magic-1-1.west) -- (magic-1-4.east);
    \draw[thin,help lines] (magic-2-1.west) -- (magic-2-4.east);
    % horizontal lines of the table
    \foreach \i in {1,2,3,4}
      \draw[thin,black] (magic-\i-1.north west) -- (magic-\i-4.north east);
    \draw[thin,black] (magic-4-1.south west) -- (magic-4-4.south east);
    % vertical lines of the table
    \foreach \j in {1,2,3,4}
      \draw[thin,black] (magic-1-\j.north west) -- (magic-4-\j.south west);
    \draw[thin,black] (magic-1-4.north east) -- (magic-4-4.south east);
  \end{tikzpicture}
\end{center}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
dmuthu_cse
Posts: 97
Joined: Fri Sep 04, 2009 4:56 pm

Re: Striking out rows and columns

Post by dmuthu_cse »

Wow!!!!

Thanks gmedina... Its exactly what i am expectecting..

It is really easy for me to proceed..

Thanks for all the people who helped me...

Regards,
Muthu
dmuthu_cse
Posts: 97
Joined: Fri Sep 04, 2009 4:56 pm

Re: Striking out rows and columns

Post by dmuthu_cse »

Hello gmedina,

Please help in creating table, striked lines...

I tried with previous example by given by you, but the output is not so clear.. the table got messed up.. because all the columns in this table is not of even width, that is why may be..

I am attaching the pdf of table.. please suggest me a solution.

Regards
Muthu
Attachments
A.pdf
(14.37 KiB) Downloaded 654 times
Post Reply