3

MWE

\documentclass[a4paper,12pt]{book}

\usepackage[left=1.5cm,right=1cm,top=3cm,bottom=1.5cm,marginparwidth=5.5cm,marginparsep=1cm,outer=8cm]{geometry}

\usepackage{array} 
\usepackage{longtable} 
\usepackage{showframe} 
\usepackage{multicol}
\usepackage{multirow}

\begin{document}

textwidth = 2.1cm + 2.8cm + 2.8cm + 2cm = 9.7cm

\begin{longtable}{|p{2.1cm}| p{2.8cm} |p{2.8cm}|p{2cm}|}
\hline
\multicolumn{4}{|c|}{\textbf{Q CODES}} \\
\hline
\textbf{Q CODE} & \multicolumn{3}{c|}{\textbf{EXPLAIN}} \\
\hline
\multirow{6}{*}{QOD} & \multicolumn{3}{l|}{Short Sentence, No Problem ( 9.7cm )}\\
                 & \multicolumn{3}{l|}{Long Sentence, Long Sentence, Long Sentence Problem ( greater than 9.7cm )}\\
                 \cline{2-4}
                 & 0 Holland & 1 English & 2 France\\
                 & 3 Germany & 4 Greece & 5 Italia\\
                 & 6 Japan & 7 Norvia & 8 Russia\\
                 & 9 Espanol  & &\\ 
\hline
\end{longtable}
\end{document}

displaying, enter image description here.

My problem, long sentence in longtable in multirow down to not go next line. That is row is greater than \textwidth. What will I do for the row line equal to \textwidth ? (Maybe, the answer it be easy. But I don't find.)

3
  • Use \multicolumn{3}{p{7.6cm}|}{Long Sentence ...} instead of l column. 7.6cm is 2.8+2.8+2cm, sum of last three column widths.
    – user11232
    May 1, 2015 at 12:25
  • @HarishKumar - That should be 7.6cm+4\tabcolsep, right?
    – Mico
    May 1, 2015 at 12:29
  • @Mico Yes, I was typing from phone. It should be \multicolumn{3}{p{\dimexpr7.6cm+4\tabcolsep+2\arrayrulewidth\relax}|}{Long Sentence,...} to be exact. :-)
    – user11232
    May 1, 2015 at 12:33

1 Answer 1

2

use the parbox within multicolumn (adding 3 columns gives 7.6cm) like this:

 \documentclass[a4paper,12pt]{book}

 \usepackage[left=1.5cm,right=1cm,top=3cm,bottom=1.5cm,marginparwidth=5.5cm,marginparsep=1cm,outer=8cm]{geometry}

\usepackage{array} 
\usepackage{longtable} 
\usepackage{showframe} 
\usepackage{multicol}
\usepackage{multirow}

\begin{document}

textwidth = 2.1cm + 2.8cm + 2.8cm + 2cm = 9.7cm

\begin{longtable}{|p{2.1cm}| p{2.8cm} |p{2.8cm}|p{2cm}|}
\hline
\multicolumn{4}{|c|}{\textbf{Q CODES}} \\
\hline
\textbf{Q CODE} & \multicolumn{3}{c|}{\textbf{EXPLAIN}} \\
\hline
\multirow{6}{*}{QOD} & \multicolumn{3}{l|}{Short Sentence, No Problem ( 9.7cm )}\\
             & \multicolumn{3}{l|}{\parbox{7.6cm}{Long Sentence, Long     Sentence, Long Sentence Problem ( greater than 9.7cm )}}\\
             \cline{2-4}
             & 0 Holland & 1 English & 2 France\\
             & 3 Germany & 4 Greece & 5 Italia\\
             & 6 Japan & 7 Norvia & 8 Russia\\
             & 9 Espanol  & &\\ 
\hline
\end{longtable}
\end{document}

enter image description here

1
  • 2
    why use a parbox inside an l column instead of simply a p column? May 1, 2015 at 12:52

You must log in to answer this question.

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