# Tabular: set a line between each row in \newenvironment

I have created a particular table with 3 columns using \newenvironment. Now I want to put a line between each row and from the 2th to the 3th column. I know it is possible to add \cmidrule{2-3} at the end of each row, but I would write something in the environment that I've created to achieve the same result and then add only \\ at the end of each row.
Could you suggest me some command to add during the declaration of the environment?

EDIT 1: The problem is a little bit more complex. This is my environment:

\newenvironment{propRules}[2]{
\begin{longtable}{r{>{$\displaystyle}c<{$}}{>{$\displaystyle}l<{$}}}
\toprule
\multicolumn{2}{c}{\texttt{#1}} & \multicolumn{1}{c}{\texttt{#2}} \\
\midrule
\multicolumn{3}{l}{\footnotesize\itshape
Continue from previous page} \\
\toprule
\multicolumn{2}{c}{\texttt{#1}} & \multicolumn{1}{c}{\texttt{#2}} \\
\midrule
\midrule
\multicolumn{3}{r}{\footnotesize\itshape
Continue in the following page} \\
\endfoot
\bottomrule
\endlastfoot
}
{\end{longtable}}


I want to modify my environment in a such way that there will be a line between the table's rows: in particular that line must be only between the second and the third column. Moreover, since that table could be broken in more pages (longtable), the line at the end of the last row in a page must not be shown because there is already the \midrule line.

EDIT 2: I solved with \newcommand\tncr{\tabularnewline\cmidrule{2-3}} but I still have the problem of the line at the end of the last row in a page: it must not be shown because there is already the \midrule line.

Any suggestions?

EDIT 3: This is a MWE:

\documentclass[a4paper,10pt]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\usepackage{longtable}  % for table in more than one page
\usepackage{booktabs}   % top, mid, bottom rule in tabular
\usepackage{array}      % personalize column in tabular
\usepackage{multirow}   % multirow, multicolumn in tabular

% column with math env in display style
\newcolumntype{L}{>{$\displaystyle}l<{$}}
\newcolumntype{C}{>{$\displaystyle}c<{$}}
\newcolumntype{R}{>{$\displaystyle}r<{$}}

%%% LONGTABLE DECLARATION %%%%%%%%%
\newenvironment{tablebig}[2]{
\setlength\LTleft{0pt}  % to obtain {\textwidth}
\setlength\LTright{0pt} % to obtain {\textwidth}
\begin{longtable}{rCL}
\toprule
\multicolumn{2}{c}{\texttt{#1}} & \multicolumn{1}{c}{\texttt{#2}} \\
\midrule
\multicolumn{3}{l}{\footnotesize\itshape
Continue from previous page} \\
\toprule
\multicolumn{2}{c}{\texttt{#1}} & \multicolumn{1}{c}{\texttt{#2}} \\
\midrule
% end page foot
\midrule
\multicolumn{3}{r}{\footnotesize\itshape
Continue in the following page} \\
\endfoot
% final foot
\bottomrule
% \multicolumn{3}{r}{\footnotesize\itshape
% Conclusion from previous page} \\
\endlastfoot
% corpo della tabella
}
{\end{longtable}}

\begin{document}

\title{MWE}

\maketitle

\section{Section}
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text

Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text

Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text

Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text

Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text

Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text

% line between rows
\newcommand\tncm{\tabularnewline\cmidrule{2-3}}

\begin{tablebig}{First Column}{Second Column}
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test
\end{tablebig}

\end{document}


If you compile it you can note that at the end of the first page there are two lines: the line producted by \tncm and the line produced by \midrule. In other cases the double line is at the beginning of the second page. How can get around it?

• Can you please show the code which you have created so far so that we can play with it? This will help both you and us to help you more accurately. – user11232 May 24 '12 at 15:24
• You can expand \tabularnewline. – Marco Daniel May 24 '12 at 17:31
• You can adapt this solution: tex.stackexchange.com/a/45148/5239 – Marco Daniel May 25 '12 at 11:16
• I tried \noalign{\vskip-0pt}\midrule\endfoot but, though it compiles, it doesn't change anything on my document. I don't want change \midrule with \hline due to aesthetic reasons. Moreover, since \midrule is between all the column instead of \tncr in only between the second and the third one, the biggest and longest line must overlap the other and not vice versa! – escap May 25 '12 at 13:00
• @escap:You don't provide a MWE to test your example. – Marco Daniel May 25 '12 at 17:37

You can redefine cmidrule so that the page break always occurs after a \cmidrule:

\makeatletter
\def\cmidrule{\noalign{\ifnum0=}\fi
\penalty\@M%
\@ifnextchar[{\@cmidrule}{\@cmidrule[\cmidrulewidth]}}
\makeatother


Now you can adapt the solution of David Carlisle:

% end page foot
\noalign{\vskip-\cmidrulesep}
\midrule
\multicolumn{3}{r}{\footnotesize\itshape
Continue in the following page} \\
\endfoot


Here the complete MWE:

\documentclass[a4paper,10pt]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\usepackage{longtable}  % for table in more than one page
\usepackage{booktabs}   % top, mid, bottom rule in tabular
\usepackage{array}      % personalize column in tabular
\usepackage{multirow}   % multirow, multicolumn in tabular
\makeatletter
\def\cmidrule{\noalign{\ifnum0=}\fi
\penalty\@M%
\@ifnextchar[{\@cmidrule}{\@cmidrule[\cmidrulewidth]}}
\makeatother
% column with math env in display style
\newcolumntype{L}{>{$\displaystyle}l<{$}}
\newcolumntype{C}{>{$\displaystyle}c<{$}}
\newcolumntype{R}{>{$\displaystyle}r<{$}}

%%% LONGTABLE DECLARATION %%%%%%%%%
\newenvironment{tablebig}[2]{
\setlength\LTleft{0pt}  % to obtain {\textwidth}
\setlength\LTright{0pt} % to obtain {\textwidth}
\begin{longtable}{rCL}
\toprule
\multicolumn{2}{c}{\texttt{#1}} & \multicolumn{1}{c}{\texttt{#2}} \\
\midrule
\multicolumn{3}{l}{\footnotesize\itshape
Continue from previous page} \\
\toprule
\multicolumn{2}{c}{\texttt{#1}} & \multicolumn{1}{c}{\texttt{#2}} \\
\midrule
% end page foot
\noalign{\vskip-\cmidrulesep}
\midrule
\multicolumn{3}{r}{\footnotesize\itshape
Continue in the following page} \\
\endfoot
% final foot
\bottomrule
% \multicolumn{3}{r}{\footnotesize\itshape
% Conclusion from previous page} \\
\endlastfoot
% corpo della tabella
}
{\end{longtable}}

\begin{document}

\title{MWE}

\maketitle

\section{Section}
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text

Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text

Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text

Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text

Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text

Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text

% line between rows
\newcommand\tncm{\tabularnewline\cmidrule{2-3}}

\begin{tablebig}{First Column}{Second Column}
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test \tncm
test & test & test
\end{tablebig}

\end{document}