Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I need a longtable like this table shown in HTML:

enter image description here

but when I use \multirow, the data inside the \multirow is continued inside the next cell. I have tried with the following

\begin{longtable}{|>{\bfseries}p{0.18\textwidth}|>{\bfseries}p{0.1\textwidth}|p{0.18\textwidth}|p{0.18\textwidth}|p{0.18\textwidth}|p{0.18\textwidth}|}
   \hline
   \multicolumn{2}{|l|}{}  &  \textbf{QR Codes}  &  \textbf{PDF417}  &  \textbf{DataMatrix}  & \textbf{Maxi Code}   \\
   \hline
   \multirow{3}{*}{Datacapacity}  &  Numeric  &  7.089  &   2.710  &    3.116  &    138  \\ \cline{2-6}
                                  &  Alphanumeric  &  4.269  &  1.850  &  2.355  &  93  \\ \cline{2-6}
                                  &  Bytes  &  2.953  &  1.018  &   1.556  &  \\
   \hline
   \multicolumn{2}{|l|}{Pros}     &  \parbox{\columnwidth}{Great capacity \\ High read}  &  Great capacity  &  Little size  & High read  \\
   \hline
\end{longtable}

I hope somebody in here can help me, and if you can help with the \parbox-problem too, it could be great.

UPDATE Now I only have the problem with what I previously named the \parbox-problem, as you can see on the last row in this picture:

enter image description here

Now my LaTeX looks like this

\begin{longtable}{|>{\bfseries}l|>{\bfseries}l|*{4}{p{0.14\textwidth}|}}
   \hline
   \multicolumn{2}{|l|}{}  & \textbf{QR Koder}  & \textbf{PDF417}  & \textbf{Data\-Matrix}  & \textbf{Maxi Code}  \\
   \hline
   ...
   Data-  & Numerisk  & 7.089  & 2.710  & 3.116  & 138  \\  \cline{2-6}
   \multirow{2}{*}{kapacitet}  & Alfa-  & 4.269  &  1.850  & 2.355  & 93  \\
        & numerisk  &  &  &  &  \\  \cline{2-6}
        & Bytes  & 2.953  & 1.018  & 1.556  &  \\
   \hline
   \multicolumn{2}{|l|}{Hovedtræk}  & \begin{tabular}[t]{@{}l@{}}Stor kapacitet \\ Lille udskriftsstørrelse \\ Høj læsehastighed \end{tabular}  & Stor kapacitet  & Lille udskriftsstørrelse  & Høj læsehastighed  \\
   \hline
\end{longtable}

Does anybody in here have an idea how to solve this?

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

The following achieves what you're after (and is possible even without multirow):

enter image description here

\documentclass{article}
\usepackage{array,longtable,multirow}% http://ctan.org/pkg/{array,longtable,multirow}
\begin{document}
\begin{longtable}{|>{\bfseries}l|>{\bfseries}l|*{4}{l|}}
  \hline
  \multicolumn{2}{|l|}{} & \textbf{QR Codes} & \textbf{PDF417} & \textbf{DataMatrix} & \textbf{Maxi Code}  \\
  \hline
  \multirow{3}{*}{Datacapacity} & Numeric        & 7.089          & 2.710       & 3.116     & 138  \\ \cline{2-6}
                                & Alphanumeric   & 4.269          & 1.850       & 2.355     & 93   \\ \cline{2-6}
                                & Bytes          & 2.953          & 1.018       & 1.556     & \\
  \hline
  \multicolumn{2}{|l|}{Pros}    & Great capacity & Great capacity & Little size & High read  \\
  \multicolumn{2}{|l|}{}        & High read      &                &             &  \\
  \hline
\end{longtable}
\end{document}
  • I've avoided \parbox and inserted an additional row. You could use a nested tabular if you want lines broken inside the cell. For example,

    \begin{tabular}[t]{@{}l@{}}
      Great capacity \\
      High read
    \end{tabular}
    

    The use of [t] aligns the tabular at the top, while @{} removes any column padding, on both sides.

  • For ease of use, the column specification of *{4}{l|} repeats l| 4 times.
  • You could use p-columns, but then you need to specify the widths in such a way that the table fits within the text block (horizontally). Your code snippet already has 5 columns of width .18\textwidth, and then a single column of width .1\textwidth, totalling \textwidth. However, there is still padding around each column (roughly 2\tabcolsep+\arrayrulewidth).

Without more detail on the size of your text block (or page orientation), it's difficult discussing alternatives to your table.

Finally, table representations are sprinkled with fairy dust if you consider the booktabs package. Moreover, there's little use in a longtable when your table is not that long...

share|improve this answer
    
The problem is, that the last 4 rows are too big, so I need to use p –  The87Boy Dec 15 '12 at 20:16
add comment

Your Answer

 
discard

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.