# how to make a line between two rows in table? (when no space between strings)

I use longtabu package to build table, when I use \\ to separate every line, it is ok, see below

\begin{center}

\begin{longtabu} to \textwidth {|X[1 , p ] |X[1 , p ] | X[2 , p ]| X[2 , p ]|X[1 , p ]|X[1 , p ]|}

\caption{A simple longtabu example}\\

\hline

\textbf{A} & \textbf{B} & \textbf{C} & \textbf{D} & \textbf{E} & \textbf{F}  \\

\hline

\multicolumn{6}{c}%

{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\

\hline

\textbf{A} & \textbf{B} & \textbf{C} & \textbf{D} & \textbf{E} & \textbf{F}  \\

\hline

\hline \multicolumn{6}{r}{\textit{Continued on next page}} \\

\endfoot

\hline

\endlastfoot

ab&cd&ef&gh&ij&kq\\ab&cd&ef&gh&ij&kq\\ab&cd&ef&gh&ij&kq\\\end{longtabu}\end{center}\end{document}

But if i use \hline or \hline\, like below, the complie always show error

ab&cd&ef&gh&ij&kq\hline\ab&cd&ef&gh&ij&kq\hline\ab&cd&ef&gh&ij&kq\hline\\end{longtabu}\end{center}\end{document}

OR

ab&cd&ef&gh&ij&kq\hlineab&cd&ef&gh&ij&kq\hlineab&cd&ef&gh&ij&kq\hline\end{longtabu}\end{center}\end{document}

OR \\\hline

ab&cd&ef&gh&ij&kq\\\hlineab&cd&ef&gh&ij&kq\\\hlineab&cd&ef&gh&ij&kq\\\hline\end{longtabu}\end{center}\end{document}

looks like this

The reason I write them together without any space is, I have a program to create table, the program use strings to create table.

I want to have a line between each row in the table, how to do it? either \hline or \hline\ doesnot work, for example \hline maybe read as \hlineab...

• You must use  \\  before a \hline command can be written! (or better, use \tabularnewline, if available!) – user31729 Aug 7 '14 at 22:38
• Off-topic comment: There is a question by you, having two answers, which both seem to fit your request - consider accepting one of them, before piling up other questions ;-) tex.stackexchange.com/questions/194517/… – user31729 Aug 7 '14 at 22:56
• The question could be solved by comments – user31729 Aug 7 '14 at 23:13
• It is not off-topic someone needs to write an answer. Please don't close all questions, this place started to look like SO – percusse Aug 7 '14 at 23:42
• Simply you could play around this by inserting two braces after \hline as follows: \documentclass[12pt,a4paper]{article} \usepackage{array} \usepackage{tabu} \usepackage{longtable} \begin{document} \begin{longtabu}{cccccc}\hline{}ab&cd&ef&gh&ij&kq\\\hline{}ab&cd&ef&gh&ij&kq\\\hline{}ab&cd&ef&gh&ij&kq\\\hline{}\end{longtabu}\end{document} – AboAmmar Aug 7 '14 at 23:58

When building tables, the \hline command at the very beginning of a row: this means just after the \begin{tabular}{<column-spec>} line to come before the first row or immediately after \\ for the other rows.

(La)TeX commands are made up of the escape character (\), a series of letters up to the first non-letter or the escape character (\) followed by one non-letter. Following these rules, \hlineab is a separate command name from \hline: both are made up of the escape sequence followed by letters. Thus your system for building your table needs to include something after \hline to separate it from ab. The usual case would simply to be to include a space here

\\ \hline ab

If for some reason that is not possible, adding an empty group will also do the job

\\ \hline{}ab

(This latter trick is also used to stop TeX skipping spaces after a command: not relevant here but does show up for example when writing for example \LaTeX{} is a document preparation system: try without the braces and see the effect.)

• I already answered this in my comment above. Why don't I see up-votes? – AboAmmar Aug 8 '14 at 12:37
• @AboAmmar I don't follow. I'm happy to remove my answer if you want to post one instead, but comments don't have the same 'status' as answers for the StackExchange back-end. So while a comment can get votes, you don't get any 'reputation' for it and it doesn't mark the question as having an answer. – Joseph Wright Aug 8 '14 at 12:41
• No, you shouldn't remove it since more readers can see the answer rather than comments. We aim at the benefit of the site users. – AboAmmar Aug 8 '14 at 12:59