6

I have this strange problem while trying to render a table with tabu package from data gathered with datatool package. Here is a working example:

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[verbose=true]{datatool}
\usepackage{datatool-base}
\usepackage{tabu}
\usepackage{ifthen}
\usepackage{longtable}

\begin{document}

\DTLsetseparator{|}
\DTLloaddb[]{isa}{isa.csv}

\begin{table}
  \begin{center}
    \begin{tabu} to \textwidth {|ll|X[l]|}
      \hline
      \multicolumn{2}{|c|}{Mnemonic}   & Description %\\
      \DTLforeach*[\DTLiseq{\family}{Arithmetic} \and \DTLiseq{\subfamily}{0}]{isa}{
        \mnemonic=mnemonic,
        \args=args,
        \description=shortdescription,
        \family=family,
        \subfamily=subfamily} % Assign list
      { %
        \DTLiffirstrow{\\ \hline \hline}{\\} %
        \texttt{\mnemonic} & \texttt{\args} & \description
      } % End loop
      \DTLforeach*[\DTLiseq{\family}{Arithmetic} \and \DTLiseq{\subfamily}{1}]{isa}{
        \mnemonic=mnemonic,
        \args=args,
        \description=shortdescription,
        \family=family,
        \subfamily=subfamily} % Assign list
      { %
        \DTLiffirstrow{\\ \hline}{\\} %
        \texttt{\mnemonic} & \texttt{\args} & \description
      } % End loop
      \DTLforeach*[\DTLiseq{\family}{Arithmetic} \and \DTLiseq{\subfamily}{2}]{isa}{
        \mnemonic=mnemonic,
        \args=args,
        \description=shortdescription,
        \family=family,
        \subfamily=subfamily} % Assign list
      { %
        \DTLiffirstrow{\\ \hline}{\\} %
        \texttt{\mnemonic} & \texttt{\args} & \description
      } % End loop
    \DTLforeach*[\DTLiseq{\family}{Arithmetic} \and \DTLiseq{\subfamily}{3}]{isa}{
        \mnemonic=mnemonic,
        \args=args,
        \description=shortdescription,
        \family=family,
        \subfamily=subfamily} % Assign list
      { %
        \DTLiffirstrow{\\ \hline}{\\} %
        \texttt{\mnemonic} & \texttt{\args} & \description
      } % End loop
      \DTLforeach*[\DTLiseq{\family}{Arithmetic} \and \DTLiseq{\subfamily}{4}]{isa}{
        \mnemonic=mnemonic,
        \args=args,
        \description=shortdescription,
        \family=family,
        \subfamily=subfamily} % Assign list
     { %
       \DTLiffirstrow{\\ \hline}{\\} %
       \texttt{\mnemonic} & \texttt{\args} & \description
     } % End loop
     \DTLforeach*[\DTLiseq{\family}{Arithmetic} \and \DTLiseq{\subfamily}{5}]{isa}{
       \mnemonic=mnemonic,
       \args=args,
       \description=shortdescription,
       \family=family,
       \subfamily=subfamily} % Assign list
     { %
       \DTLiffirstrow{\\ \hline}{\\} %
       \texttt{\mnemonic} & \texttt{\args} & \description
     } % End loop 
     \DTLforeach*[\DTLiseq{\family}{Arithmetic} \and \DTLiseq{\subfamily}{6}]{isa}{
       \mnemonic=mnemonic,
       \args=args,
       \description=shortdescription,
       \family=family,
       \subfamily=subfamily} % Assign list
     { %
       \DTLiffirstrow{\\ \hline}{\\} %
       \texttt{\mnemonic} & \texttt{\args} & \description
     } % End loop
     \DTLforeach*[\DTLiseq{\family}{Arithmetic} \and \DTLiseq{\subfamily}{7}]{isa}{
       \mnemonic=mnemonic,
       \args=args,
       \description=shortdescription,
       \family=family,
       \subfamily=subfamily} % Assign list
     { %
       \DTLiffirstrow{\\ \hline}{\\} %
       \texttt{\mnemonic} & \texttt{\args} & \description
     } % End loop
     \DTLforeach*[\DTLiseq{\family}{Arithmetic} \and \DTLiseq{\subfamily}{8}]{isa}{
       \mnemonic=mnemonic,
       \args=args,
       \description=shortdescription,
       \family=family,
       \subfamily=subfamily} % Assign list
     { %
       \DTLiffirstrow{\\ \hline}{\\} %
       \texttt{\mnemonic} & \texttt{\args} & \description
     } % End loop
     \DTLforeach*[\DTLiseq{\family}{Arithmetic} \and \DTLiseq{\subfamily}{9}]{isa}{
       \mnemonic=mnemonic,
       \args=args,
       \description=shortdescription,
       \family=family,
       \subfamily=subfamily} % Assign list
     { %
       \DTLiffirstrow{\\ \hline}{\\} %
       \texttt{\mnemonic} & \texttt{\args} & \description
     } % End loop
     \DTLforeach*[\DTLiseq{\family}{Arithmetic} \and \DTLiseq{\subfamily}{10}]{isa}{
        \mnemonic=mnemonic,
        \args=args,
        \description=shortdescription,
        \family=family,
        \subfamily=subfamily} % Assign list
      { %
        \DTLiffirstrow{\\ \hline}{\\} %
        \texttt{\mnemonic} & \texttt{\args} & \description
      } % End loop
      \\ \hline
    \end{tabu}
  \caption{Arithmetic instructions}
  \label{tbl:a_instructions}
  \end{center}
\end{table}
\end{document}

Here's the CSV file used:

"mnemonic"|"args"|"shortdescription"|"family"|"subfamily"
"addi.w"|"rdst,rsrc,IMM"|"Add immediate"|"Arithmetic"|"0"
"addui.w"|"rdst,rsrc,IMM"|"Add unsigned immediate"|"Arithmetic"|"0"
"subi.w"|"rdst,rsrc,IMM"|"Substract immediate"|"Arithmetic"|"1"
"subui.w"|"rdst,rsrc,IMM"|"Substract unsigned immediate"|"Arithmetic"|"1"
"add.w"|"rdst,rsrc1,rsrc2"|"Add GPR's"|"Arithmetic"|"2"
"add.l"|"rdst,rsrc1,rsrc2"|"Add long GPR's"|"Arithmetic"|"2"
"add.f"|"fdst,fsrc1,fsrc2"|"Add FPR's"|"Arithmetic"|"2"
"add.d"|"fdst,fsrc1,fsrc2"|"Add double FPR's"|"Arithmetic"|"2"
"sub.w"|"rdst,rsrc1,rsrc2"|"Substract GPR's"|"Arithmetic"|"3"
"sub.l"|"rdst,rsrc1,rsrc2"|"Substract long GPR's"|"Arithmetic"|"3"
"sub.f"|"fdst,fsrc1,fsrc2"|"Substract FPR's"|"Arithmetic"|"3"
"sub.d"|"fdst,fsrc1,fsrc2"|"Substract double FPR's"|"Arithmetic"|"3"
"mult.w"|"rdst,rsrc1,rsrc2"|"Multiply GPR's"|"Arithmetic"|"4"
"mult.l"|"rdst,rsrc1,rsrc2"|"Multiply GPR's into long GPR"|"Arithmetic"|"4"
"mult.f"|"fdst,fsrc1,fsrc2"|"Multiply FPR's"|"Arithmetic"|"4"
"mult.d"|"fdst,fsrc1,fsrc2"|"Multiply double FPR's"|"Arithmetic"|"4"
"div.w"|"rdst,rsrc1,rsrc2"|"Divide GPR's"|"Arithmetic"|"5"
"div.l"|"rdst,rsrc1,rsrc2"|"Divide long GPR's"|"Arithmetic"|"5"
"div.f"|"fdst,fsrc1,fsrc2"|"Divide FPR's"|"Arithmetic"|"5"
"div.d"|"fdst,fsrc1,fsrc2"|"Divide double FPR's"|"Arithmetic"|"5"
"rem.w"|"rdst,rsrc1,rsrc2"|"Remainder of GPR's"|"Arithmetic"|"6"
"rem.l"|"rdst,rsrc1,rsrc2"|"Remainder of long GPR's"|"Arithmetic"|"6"
"rl.w"|"rdst,rsrc1,rsrc2"|"Rotate left GPR"|"Arithmetic"|"7"
"rl.l"|"rdst,rsrc1,rsrc2"|"Rotate left long GPR"|"Arithmetic"|"7"
"rr.w"|"rdst,rsrc1,rsrc2"|"Rotate right GPR"|"Arithmetic"|"8"
"rr.l"|"rdst,rsrc1,rsrc2"|"Rotate right long GPR"|"Arithmetic"|"8"
"sl.w"|"rdst,rsrc1,rsrc2"|"Shift left GPR"|"Arithmetic"|"9"
"sl.l"|"rdst,rsrc1,rsrc2"|"Shift left long GPR"|"Arithmetic"|"9"
"sra.w"|"rdst,rsrc1,rsrc2"|"Shift right arithmetical GPR"|"Arithmetic"|"10"
"sra.l"|"rdst,rsrc1,rsrc2"|"Shift right arithmetical long GPR"|"Arithmetic"|"10"

And the output produced: Output

Notice the extra spaces below some lines. Why are they produced???

0

1 Answer 1

1

The problem seems to be caused by spurious spaces in the code. Removing all unwanted space fixes it:

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[verbose=true]{datatool}
\usepackage{datatool-base}
\usepackage{tabu}
\usepackage{ifthen}
\usepackage{longtable}

\begin{document}

\DTLsetseparator{|}
\DTLloaddb[]{isa}{isa.csv}

\begin{table}
  \begin{center}
    \begin{tabu} to \textwidth {|ll|X[l]|}
      \hline
      \multicolumn{2}{|c|}{Mnemonic} & Description%
      \DTLforeach*[\DTLiseq{\family}{Arithmetic}\and\DTLiseq{\subfamily}{0}]{isa}{
        \mnemonic=mnemonic,
        \args=args,
        \description=shortdescription,
        \family=family,
        \subfamily=subfamily}% Assign list
      {%
        \DTLiffirstrow{\\\hline\hline}{\\}%
        \texttt{\mnemonic} & \texttt{\args} & \description
      }% End loop
      \DTLforeach*[\DTLiseq{\family}{Arithmetic}\and\DTLiseq{\subfamily}{1}]{isa}{%
        \mnemonic=mnemonic,
        \args=args,
        \description=shortdescription,
        \family=family,
        \subfamily=subfamily}% Assign list
      {%
        \DTLiffirstrow{\\\hline}{\\}%
        \texttt{\mnemonic} & \texttt{\args} & \description
      }% End loop
      \DTLforeach*[\DTLiseq{\family}{Arithmetic}\and\DTLiseq{\subfamily}{2}]{isa}{%
        \mnemonic=mnemonic,
        \args=args,
        \description=shortdescription,
        \family=family,
        \subfamily=subfamily}% Assign list
      {%
        \DTLiffirstrow{\\\hline}{\\}%
        \texttt{\mnemonic} & \texttt{\args} & \description
      }% End loop
    \DTLforeach*[\DTLiseq{\family}{Arithmetic}\and\DTLiseq{\subfamily}{3}]{isa}{%
        \mnemonic=mnemonic,
        \args=args,
        \description=shortdescription,
        \family=family,
        \subfamily=subfamily}% Assign list
      {%
        \DTLiffirstrow{\\\hline}{\\}%
        \texttt{\mnemonic} & \texttt{\args} & \description
      }% End loop
      \DTLforeach*[\DTLiseq{\family}{Arithmetic}\and\DTLiseq{\subfamily}{4}]{isa}{%
        \mnemonic=mnemonic,
        \args=args,
        \description=shortdescription,
        \family=family,
        \subfamily=subfamily}% Assign list
     {%
       \DTLiffirstrow{\\\hline}{\\}%
       \texttt{\mnemonic} & \texttt{\args} & \description
     }% End loop
     \DTLforeach*[\DTLiseq{\family}{Arithmetic}\and\DTLiseq{\subfamily}{5}]{isa}{%
       \mnemonic=mnemonic,
       \args=args,
       \description=shortdescription,
       \family=family,
       \subfamily=subfamily}% Assign list
     {%
       \DTLiffirstrow{\\\hline}{\\}%
       \texttt{\mnemonic} & \texttt{\args} & \description
     }% End loop 
     \DTLforeach*[\DTLiseq{\family}{Arithmetic}\and\DTLiseq{\subfamily}{6}]{isa}{%
       \mnemonic=mnemonic,
       \args=args,
       \description=shortdescription,
       \family=family,
       \subfamily=subfamily}% Assign list
     {%
       \DTLiffirstrow{\\\hline}{\\}%
       \texttt{\mnemonic} & \texttt{\args} & \description
     }% End loop
     \DTLforeach*[\DTLiseq{\family}{Arithmetic}\and\DTLiseq{\subfamily}{7}]{isa}{%
       \mnemonic=mnemonic,
       \args=args,
       \description=shortdescription,
       \family=family,
       \subfamily=subfamily}% Assign list
     {%
       \DTLiffirstrow{\\\hline}{\\}%
       \texttt{\mnemonic} & \texttt{\args} & \description
     }% End loop
     \DTLforeach*[\DTLiseq{\family}{Arithmetic}\and\DTLiseq{\subfamily}{8}]{isa}{%
       \mnemonic=mnemonic,
       \args=args,
       \description=shortdescription,
       \family=family,
       \subfamily=subfamily}% Assign list
     {%
       \DTLiffirstrow{\\\hline}{\\}%
       \texttt{\mnemonic} & \texttt{\args} & \description
     }% End loop
     \DTLforeach*[\DTLiseq{\family}{Arithmetic}\and\DTLiseq{\subfamily}{9}]{isa}{%
       \mnemonic=mnemonic,
       \args=args,
       \description=shortdescription,
       \family=family,
       \subfamily=subfamily} % Assign list
     {%
       \DTLiffirstrow{\\\hline}{\\}%
       \texttt{\mnemonic} & \texttt{\args} & \description
     }% End loop
     \DTLforeach*[\DTLiseq{\family}{Arithmetic}\and\DTLiseq{\subfamily}{10}]{isa}{%
        \mnemonic=mnemonic,
        \args=args,
        \description=shortdescription,
        \family=family,
        \subfamily=subfamily}% Assign list
      {%
        \DTLiffirstrow{\\\hline}{\\}%
        \texttt{\mnemonic} & \texttt{\args} & \description
      }% End loop
      \\\hline
    \end{tabu}
  \caption{Arithmetic instructions}
  \label{tbl:a_instructions}
  \end{center}
\end{table}
\end{document}

Result:

image of table with no unwanted blank rows

You must log in to answer this question.

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