# Latex table connect vertical line over two lines

I need to connect the vertical lines of a table (@ symbol,value,Gradient). Thought about multirow/multicolum but didn't manage to solve it.

\documentclass[a4paper,12pt,headsepline]{scrreprt}
\usepackage{longtable}
\usepackage{multicol}
\usepackage{multirow}
\begin{document}
\begin{center}
\begin{table}[H]
\captionabove{Caption}
\label{tab:TYPETURBSTREAM}
\begin{tabular}{|c|c|c|c|}
\hline
LONG TEXT TEXT TEXT TEXT \\/ NEXT LINE  &  Symbol & VALUE & GRADIENT \\ \hline
A & A1 & A2 & zeroGradient \\ \hline
B & B1 & B2 & B3 \\ \hline
C  & C1 & C2 & C3 \\ \hline
D & D1 & D2 & D3 \\ \hline
E & D1 & E2 & E3 \\ \hline
\end{tabular}
\end{table}
\end{center}
\end{document}


Even though I like Zarko's answer better, no one showed that the OP can do what he wants with \multirow and \multicolumn, also you can use pbox or nested tabular's (like in this answer by @egreg):

\documentclass[a4paper,12pt,headsepline]{scrreprt}
\usepackage{array,pbox, multirow}
\newcommand{\specialcell}[2][c]{% Command by @egreg (https://tex.stackexchange.com/a/19678/81905)
\begin{tabular}[#1]{@{}c@{}}#2\end{tabular}}
\newcommand{\tablecode}[2]{%
\begin{table}
\centering
\captionabove{#1}
\begin{tabular}{|c|c|c|c|}
\hline
#2  &  Symbol & VALUE & GRADIENT \\ \hline
A & A1 & A2 & zeroGradient \\ \hline
B & B1 & B2 & B3 \\ \hline
C  & C1 & C2 & C3 \\ \hline
D & D1 & D2 & D3 \\ \hline
E & D1 & E2 & E3 \\ \hline
\end{tabular}
\end{table}%
}
\begin{document}
\tablecode{Using fixed width column with \texttt{\textbackslash multicolumn}}%
{\multicolumn{1}{|>{\centering\arraybackslash}m{6.75cm}|}{LONG TEXT TEXT TEXT TEXT\newline / NEXT LINE}}

\tablecode{Using \texttt{pbox}}%
{\pbox{\textwidth}{\relax\ifvmode\centering\fi LONG TEXT TEXT TEXT TEXT \\ / NEXT LINE}}

\tablecode{Using nested \texttt{tabular}'s}%
{\specialcell{LONG TEXT TEXT TEXT TEXT \\ / NEXT LINE}}

\begin{table}
\centering
\captionabove{Using \texttt{\textbackslash multirow}}
\begin{tabular}{|c|c|c|c|}
\hline
LONG TEXT TEXT TEXT TEXT  &  \multirow{2}{*}{Symbol} & \multirow{2}{*}{VALUE} & \multirow{2}{*}{GRADIENT} \\
/ NEXT LINE & & & \\
\hline
A & A1 & A2 & zeroGradient \\ \hline
B & B1 & B2 & B3 \\ \hline
C  & C1 & C2 & C3 \\ \hline
D & D1 & D2 & D3 \\ \hline
E & D1 & E2 & E3 \\ \hline
\end{tabular}
\end{table}

\end{document}


• beside showed example you also can show solution with nested table (which gives similar result as \makecell) , etc. by the way, in the first solution (to my opinion only this has certain sense) the use of \newline for break of lines is surplus. anyway, to my opinion is better to use existed, proven and documented solution than "invent" own solution for which you need one line of (not documented) own code :) – Zarko Dec 14 '16 at 16:22
• @Zarko, \\  doesn't work inside \multicolumn, it's either \newline or a blank line. You're right, I'll add the nested tabular as another option, but my Intention was only to show that it could be done using the \multirow or \multicolumn, because it was in fact what the OP asked (If it were me, I'd use \makecell). – Guilherme Zanotelli Dec 14 '16 at 16:42

You just need to add the (empty) cells at the end of the first row, i.e. add &&& after LONG TEXT...

Also, having a table environment inside a center environment doesn't make much sense, and it will not center the table anyway. Better to remove the center environment and add \centering right after \begin{table}.

And if you really want to use [H] as the float specifier, you need \usepackage{float}, which is missing from your code.

\documentclass[a4paper,12pt,headsepline]{scrreprt}
\begin{document}
\begin{table}
\centering
\captionabove{Caption}
\label{tab:TYPETURBSTREAM}
\begin{tabular}{|c|c|c|c|}
\hline
LONG TEXT TEXT TEXT TEXT &&& \\
/ NEXT LINE  &  Symbol & VALUE & GRADIENT \\ \hline
A & A1 & A2 & zeroGradient \\ \hline
B & B1 & B2 & B3 \\ \hline
C  & C1 & C2 & C3 \\ \hline
D & D1 & D2 & D3 \\ \hline
E & D1 & E2 & E3 \\ \hline
\end{tabular}
\end{table}
\end{document}


The consistent and clear way to solve your problem offer macro makecell from package makecell, by which you can elegantly merge first two rows in table:

\documentclass[a4paper,12pt,headsepline]{scrreprt}
\usepackage{makecell}

\begin{document}
\begin{table}
\centering
\captionabove{Caption}
\label{tab:TYPETURBSTREAM}
\begin{tabular}{|c|c|c|c|}
\hline
\makecell[b]{LONG TEXT TEXT TEXT TEXT\\
/ NEXT LINE}
&  Symbol & VALUE & GRADIENT    \\ \hline
A   & A1 & A2 & zeroGradient        \\ \hline
B   & B1 & B2 & B3                  \\ \hline
C   & C1 & C2 & C3                  \\ \hline
D   & D1 & D2 & D3                  \\ \hline
E   & D1 & E2 & E3                  \\ \hline
\end{tabular}
\end{table}
\end{document}


Addendum: An atrctive alternative solution is use of column type which automathecaly broke cell text into more lines (as show Guilherme Zanotelli the first example in his answer). Let mi expand and simplify this example used possibilities offered by package array:

\documentclass[a4paper,12pt,headsepline]{scrreprt}
\usepackage{array}

\begin{document}
\begin{table}
\centering
\captionabove{Caption}
\label{tab:TYPETURBSTREAM}
\begin{tabular}{|>{\centering}p{6cm}|c|c|c|}% since this is not lst column, the use of \arraybackslash can be omitted ...
\hline
LONG TEXT TEXT TEXT NEXT IN MORE LINES
&  Symbol & VALUE & GRADIENT    \\ \hline
A   & A1 & A2 & zeroGradient        \\ \hline
B   & B1 & B2 & B3                  \\ \hline
\end{tabular}

\bigskip
\begin{tabular}{|>{\centering}m{6cm}|c|c|c|}
\hline
LONG TEXT TEXT TEXT NEXT IN MORE LINES
&  Symbol & VALUE & GRADIENT    \\ \hline
A   & A1 & A2 & zeroGradient        \\ \hline
B   & B1 & B2 & B3                  \\ \hline
\end{tabular}

\bigskip
\begin{tabular}{|>{\centering}b{6cm}|c|c|c|}
\hline
LONG TEXT TEXT TEXT NEXT IN MORE LINES
&  Symbol & VALUE & GRADIENT    \\ \hline
A   & A1 & A2 & zeroGradient        \\ \hline
B   & B1 & B2 & B3                  \\ \hline
\end{tabular}
\end{table}
\end{document}