1

This question already has an answer here:

Que: I am making a bunch of tables in which i want to remove three vertical lines from last table.

MWE:

\documentclass[12pt]{article}
\usepackage[a4paper,
            vmargin=0.7in, hmargin=0.7in,
            headheight=14.5pt,]{geometry}
\usepackage[misc]{ifsym}
\usepackage{mathtools}  
\usepackage{amssymb}    
\usepackage{forest}
\usepackage{tikz}
\usepackage{parskip}
\usetikzlibrary{intersections}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}
\large
\setlength\extrarowheight{5pt}
    \begin{tabular}{|c|c|}
    \hline
    Que.               & Ans.               \\ \hline
    $1$                &                 \\\hline
    $2$                &                 \\\hline
    $3$                &                 \\\hline
    $4$                &                 \\\hline
    \end{tabular}
\hspace{1cm}
\setlength\extrarowheight{5pt}
\begin{tabular}{|c|c|}
    \hline
    Que.               & Ans.               \\ \hline
    $5$                &                 \\\hline
    $6$                &                 \\\hline
    $7$                &                 \\\hline
    $8$                &                 \\\hline
\end{tabular}
\hspace{1cm}
\setlength\extrarowheight{5pt}
\begin{tabular}{|c|c|}
    \hline
    Que.               & Ans.               \\ \hline
    $9$                &                 \\\hline
    $10$                &                \\\hline
    $11$                &                 \\\hline
    $12$                &                \\\hline
\end{tabular}
\hspace{1cm}
\setlength\extrarowheight{5pt}
\begin{tabular}{|c|c|}
    \hline
    Que.               & Ans.               \\ \hline
    $13$                &                 \\\hline
    $14$                &                 \\\hline
    $15$                &                 \\\hline
    $16$                &                 \\\hline
\end{tabular}

\vspace{1cm}
\setlength\extrarowheight{5pt}
\begin{tabular}{|c|c|}
    \hline
    Que.               & Ans.               \\ \hline
    $17$                &                 \\\hline
    $18$                &                 \\\hline
    $19$                &                 \\\hline
    $20$                &                 \\\hline
\end{tabular}
\hspace{1cm}
\setlength\extrarowheight{5pt}
\begin{tabular}{|c|c|}
    \hline
    Que.               & Ans.               \\ \hline
    $21$                &                 \\\hline
    $22$                &                 \\\hline
    $23$                &                 \\\hline
    $24$                &                \\\hline
\end{tabular}
\hspace{1cm}
\setlength\extrarowheight{5pt}
\begin{tabular}{|c|c|}
    \hline
    Que.               & Ans.               \\ \hline
    $25$                &                 \\\hline
    $26$                &                 \\\hline
    $27$                &                 \\\hline
    $28$                &                 \\\hline
\end{tabular}
\hspace{1cm}
\setlength\extrarowheight{5pt}
\begin{tabular}{|c|c|}
    \hline
    Que.                & Ans.               \\ \hline
    $29$                &                 \\\hline
    $30$                &                 \\\hline    
                        &                    \\
                        &                     
    \end{tabular}

\end{document}

marked as duplicate by Sveinung, Raaja, BambOo, schtandard, Stefan Pinnow Sep 11 at 11:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

The simplest trick is to use \begin{tabular}[t]{|c|c|} throughout, with the last one being just a three row table.

\documentclass[12pt]{article}
\usepackage[a4paper,
            vmargin=0.7in, hmargin=0.7in,
            headheight=14.5pt,]{geometry}
\usepackage[misc]{ifsym}
\usepackage{mathtools}  
\usepackage{amssymb}    
\usepackage{forest}
\usepackage{tikz}
\usepackage{parskip}
\usetikzlibrary{intersections}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}
\large
\setlength\extrarowheight{5pt}
    \begin{tabular}[t]{|c|c|}
    \hline
    Que.               & Ans.               \\ \hline
    $1$                &                 \\\hline
    $2$                &                 \\\hline
    $3$                &                 \\\hline
    $4$                &                 \\\hline
    \end{tabular}
\hspace{1cm}
\setlength\extrarowheight{5pt}
\begin{tabular}[t]{|c|c|}
    \hline
    Que.               & Ans.               \\ \hline
    $5$                &                 \\\hline
    $6$                &                 \\\hline
    $7$                &                 \\\hline
    $8$                &                 \\\hline
\end{tabular}
\hspace{1cm}
\setlength\extrarowheight{5pt}
\begin{tabular}[t]{|c|c|}
    \hline
    Que.               & Ans.               \\ \hline
    $9$                &                 \\\hline
    $10$                &                \\\hline
    $11$                &                 \\\hline
    $12$                &                \\\hline
\end{tabular}
\hspace{1cm}
\setlength\extrarowheight{5pt}
\begin{tabular}[t]{|c|c|}
    \hline
    Que.               & Ans.               \\ \hline
    $13$                &                 \\\hline
    $14$                &                 \\\hline
    $15$                &                 \\\hline
    $16$                &                 \\\hline
\end{tabular}

\vspace{1cm}
\setlength\extrarowheight{5pt}
\begin{tabular}[t]{|c|c|}
    \hline
    Que.               & Ans.               \\ \hline
    $17$                &                 \\\hline
    $18$                &                 \\\hline
    $19$                &                 \\\hline
    $20$                &                 \\\hline
\end{tabular}
\hspace{1cm}
\setlength\extrarowheight{5pt}
\begin{tabular}[t]{|c|c|}
    \hline
    Que.               & Ans.               \\ \hline
    $21$                &                 \\\hline
    $22$                &                 \\\hline
    $23$                &                 \\\hline
    $24$                &                \\\hline
\end{tabular}
\hspace{1cm}
\setlength\extrarowheight{5pt}
\begin{tabular}[t]{|c|c|}
    \hline
    Que.               & Ans.               \\ \hline
    $25$                &                 \\\hline
    $26$                &                 \\\hline
    $27$                &                 \\\hline
    $28$                &                 \\\hline
\end{tabular}
\hspace{1cm}
\setlength\extrarowheight{5pt}
\begin{tabular}[t]{|c|c|}
    \hline
    Que.                & Ans.               \\ \hline
    $29$                &                 \\\hline
    $30$                &                 \\\hline    
    \end{tabular}

\end{document}

enter image description here

I left the useless \setlength\extrarowheight{5pt} instructions (the first one suffices) just to keep the spaces as in the original.

You may appreciate this seemingly complicated code, which however allows you to just say

\youranswers{30}

or

\youranswers[5]{30}

The optional argument (default 4) specifies the (maximum) number of answers in each group.

\documentclass[12pt]{article}
\usepackage{xparse,array}

\ExplSyntaxOn
\NewDocumentCommand{\youranswers}{O{4}m}
 {
  \par
  \group_begin:
  \setlength{\extrarowheight}{5pt}
  \setlength{\lineskip}{1cm}
  \raggedright\large
  \mathsforsandy_answers:nn { #1 } { #2 }
  \par
  \group_end:
 }

\cs_new_protected:Nn \mathsforsandy_answers:nn
 {
  \int_zero:N \l_tmpa_int
  \prg_replicate:nn { \fp_eval:n { ceil(#2/#1,0) } } { \__mathsforsandy_table:nn { #1 } { #2 } }
 }

\cs_new_protected:Nn \__mathsforsandy_table:nn
 {
  \tl_clear:N \l_tmpa_tl 
  \prg_replicate:nn { #1 }
   {
    \int_incr:N \l_tmpa_int
    \int_compare:nF { \l_tmpa_int > #2 }
     {
      \tl_put_right:Nx \l_tmpa_tl { \int_to_arabic:n { \l_tmpa_int } }
      \tl_put_right:Nn \l_tmpa_tl { & \\ \hline }
     }
   }
  \begin{tabular}[t]{|c|c|}\hline Que. & Ans. \\ \hline
  \tl_use:N \l_tmpa_tl
  \end{tabular}
  \hspace{1cm}
 }

\ExplSyntaxOff

\begin{document}

\youranswers{30}

\clearpage

\youranswers[5]{30}

\end{document}

The idea is to compute the needed number of tables (ceiling of #2/#1) and then build them one by one by increasing a counter.

enter image description here

  • It's really simple. Thanks a lot – Maths4Sandy Sep 11 at 8:21
1

Your code is not working, you forgot an extra Backslash after every new row.

The vertical lines are nserted through the | between the cs in the column specification. (In your case: |c|c|). To leave out vertical lines just leave out the |.

EDIT: I think I got your Question right now, its a bit unclear. To remove the vertical lines of empty rows just leave out the last line of your code & \\ & so it will be like:

\documentclass[12pt]{article} 
\usepackage[a4paper, vmargin=0.7in, hmargin=0.7in, headheight=14.5pt,]{geometry}
\begin{document} 

\begin{tabular}{|c|c|} \hline 
Que. & Ans. \\ \hline 
$29$ & \\\hline 
$30$ & \\\hline
\end{tabular}

\end{document}

enter image description here

  • in this solution last table drag just below automatically. – Maths4Sandy Sep 11 at 6:37
  • 1
    yes, but whats the problem with this? Do you only want to remove the column-separating line in the middle? – Felix Exner Sep 11 at 7:14
  • Yes just i want to erase these lines by keep table on the top. – Maths4Sandy Sep 11 at 7:46

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