TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to add one \hline to the macro expansion of this code, that is minimally modified version of David Carlisle's answer to Generating LaTeX tabular code during compilation.

Compiling this with latexmk -pdf main.tex gives a nice tabular. I was able to add \hline to the macro expansion of the macro that generates most of the rows by adding \def\hardline{\hline} and \expandafter\hardline in \def\xlistbody in g_orig_dest_tabular1_def.tex. I was also able to add \hline in the beginning of the code by adding \noexpand\hline in \def\tablestart in the same file. But I was not able to find out how I could generate \hline between first and second row of this tabular array. It must be in \def\listheadings or in \def\xlistheadings in g_orig_dest_tabular1_def.tex. So how \hline could be added to the macro expansion that is used to create the first row of this tabular array?

Thank you :)










% hardline.

% listheadings.

% xlistheadings.

% listbody.

% xlistbody.

% xlistdata.
&\csname CONNorig\thisrow dest#1\endcsname

% preamble.

% tablestart.



    } % end scalebox
    \caption{Caption goes here.}
        \item Item number one. 
        \item Item number two.


\def\CONNorigABCdestABC{ NA }
\def\CONNorigABCdestDEF{ from ABC to DEF }
\def\CONNorigABCdestGHI{ from ABC to GHI }

\def\CONNorigDEFdestABC{ from DEF to ABC }
\def\CONNorigDEFdestDEF{ NA }
\def\CONNorigDEFdestGHI{ from DEF to GHI }

\def\CONNorigGHIdestABC{ from GHI to ABC }
\def\CONNorigGHIdestDEF{ from GHI to DEF }
\def\CONNorigGHIdestGHI{ NA }
share|improve this question
maybe I don't understand, but don't you just want \hline after the call to \listheadings as in the original answer? – David Carlisle Apr 20 '12 at 11:35
Does the following definition do the job: \def\xlistheadings#1,{% \ifx\relax#1% \expandafter\\\hline \else &\textbf{#1}% \expandafter\xlistheadings \fi} – Marco Daniel Apr 20 '12 at 13:06
@David Carlisle: Yes, but then as I have to create several different tabular arrays using slightly modified versions of this code, I thought that it would be easier to use, modify and maintain if all the code to create a tabular array of this kind was created by using only \tablestart \listheadings \listbody. – nrz Apr 20 '12 at 14:12
@Marco Daniel: It is exactly what I was looking for. Thank you. – nrz Apr 20 '12 at 14:14
well if all your arrays need a line after the heading just add \hline as the last thing in the definition of \listheadings – David Carlisle Apr 20 '12 at 14:16
up vote 2 down vote accepted

To get a hline you can change the command \xlistheadings or \listheadings

The modification of \xlistheadings:

 \else &\textbf{#1}%

The modification of \listheadings


Take your preferred way.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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