0

A table is created with \usepackage{longtable}. All the cells are simple cells with the exception of the last cell in each row. This cell contains another tabular environment. It contains few lines of text and a list. No matter what I do, I can not get rid of the empty line after the list (see 'second row'). But, there is one exception. If I put a line of text after the list, I do not get empty line. Please, see 'first row'.

QUESTION: What is the magic command which will remove the empty line after the 'list' ?

\documentclass[letterpaper]{article}

\usepackage{longtable}
\usepackage{enumitem}

\begin{document}
\begin{longtable}{@{}lcccl@{}}
  \caption{INPUT ports definition.} \label{tab:signal_definition_input} \\
  \hline
  \textbf{COL 1} & \textbf{COL 2} & \textbf{COL 3} 
          & \textbf{COL 4}& \textbf{DESCRIPTION}  \\
  \hline
  \endfirsthead

  \multicolumn{5}{c}%
  {{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\    
  \hline
  \textbf{COL 1} & \textbf{COL 2} & \textbf{col 3}  
  & \textbf{COL 4}& \textbf{DESCRIPTION}  \\
  \hline
  \endhead

  \hline
  \multicolumn{5}{@{}r@{}}{{Continued\ldots}} \\
  \hline
  \endfoot

  \hline 
  \endlastfoot

  first row  & 1 & IN &  0  & \begin{tabular}{p{8cm}}
                               forces exit from the passthrough mode  \\
                               SOURCE main digital
                               \begin{description}[noitemsep,topsep=0pt]  
                                  \item[0 =]do nothing This is pdfTeX,
                                              Version 3.14159265-2.6-1.40.17 
                                  \item[1 =] force some text and more of the 
                                             same text some text and more 
                                                  of the same text
                                                  within the 'list'
                               \end{description}
                               EXTRA line of text after 'list' is needed
                               to prevent empty line                 \\
                               \end{tabular}                         \\ 
  \hline %-----------------------------------------------  
  second row & 1 & IN &  0  & \begin{tabular}{p{8cm}}
                               forces exit from the passthrough mode  \\
                               SOURCE main digital
                               \begin{description}[noitemsep,topsep=2pt]  
                                  \item[0 =]do nothing This is pdfTeX,
                                            Version 3.14159265-2.6-1.40.17  
                                  \item[1 =] force some text and more of the 
                                             same text some text and more 
                                             of the same text
                                             within the 'list' 
                              \end{description}
                              \end{tabular}                   \\
  \hline %------------------------------------------------
\end{longtable}

\end{document}

list within tabular environment  within cell

  • 1
    Ad hoc (and temporary) workaround: try adding \vspace*{-\baselineskip} after \end{description}. – jon Sep 9 '16 at 6:24
  • yes... this is the magic command .... it did the trick TNX++ – Igor Sep 9 '16 at 6:39
1

There is more than one way to do hanging indentation. Note that \baselineskip does not apply to the first or last line of a \parbox, so I like to start and end with a \strut.

\documentclass[letterpaper]{article}

\usepackage{longtable}
\usepackage{enumitem}

\newcommand{\desc}[2]% %1 = label, #2 = description
{\bgroup
  \sbox0{#1\hspace{\itemsep}}%
  \usebox0\parbox[t]{\dimexpr \linewidth-\wd0}{\strut #2\strut}%
\egroup}

\begin{document}
\begin{longtable}{@{}lcccl@{}}
  \caption{INPUT ports definition.} \label{tab:signal_definition_input} \\
  \hline
  \textbf{COL 1} & \textbf{COL 2} & \textbf{COL 3} 
          & \textbf{COL 4}& \textbf{DESCRIPTION}  \\
  \hline
  \endfirsthead

  \multicolumn{5}{c}%
  {{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\    
  \hline
  \textbf{COL 1} & \textbf{COL 2} & \textbf{col 3}  
  & \textbf{COL 4}& \textbf{DESCRIPTION}  \\
  \hline
  \endhead

  \hline
  \multicolumn{5}{@{}r@{}}{{Continued\ldots}} \\
  \hline
  \endfoot

  \hline 
  \endlastfoot

  first row  & 1 & IN &  0  & \parbox{8cm}{\strut
                               forces exit from the passthrough mode  \\
                               SOURCE main digital\\
                               \desc{0 =}{do nothing This is pdfTeX,
                                              Version 3.14159265-2.6-1.40.17}\\
                               \desc{1 =}{force some text and more of the 
                                             same text some text and more 
                                                  of the same text
                                                  within the 'list'}%
                               \strut}\\ 
  \hline %-----------------------------------------------  
  second row & 1 & IN &  0  & \parbox{8cm}{\strut
                               forces exit from the passthrough mode  \\
                               SOURCE main digital\\
                               \desc{0 =}{do nothing This is pdfTeX,
                                            Version 3.14159265-2.6-1.40.17}\\
                               \desc{1 =}{force some text and more of the 
                                             same text some text and more 
                                             of the same text
                                             within the 'list'}%
                              \strut}\\
  \hline %------------------------------------------------
\end{longtable}

\end{document}

demo

  • As presented, the solution works. What is puzzling to me is the % after the within the 'list'}%. I thought that % is the delimiter where the comment starts ... so ... it should be irrelevant if it is there or not. But, If I remove it or just move it one character to the right like within the 'list'} %, the empty line after the last text line appears. Is there any explanation why the % has an impact on rendering ? – Igor Sep 10 '16 at 19:34
  • Almost every line which ends with } will add a space. Putting % immediately after } prevents this. – John Kormylo Sep 11 '16 at 14:59
0

just add to te last item line this command : \vspace{-\baselineskip}\mbox{} Edit : add it before the \end{description} like that :

                      \begin{description}[noitemsep,topsep=0pt]  
                          \item[0 =]do 
                          \item[1 =]   within the 'list''\vspace{-\baselineskip}\mbox{}
                       \end{description}
  • I tried your suggestion. It does not work. I added to the last item line the \vspace{-\baselineskip}\mbox{}. So, the line looks like this \item[1 =] force some text and more of the same text some text and more of the same text within the 'list' \vspace{-\baselineskip}\mbox{} The suggestion from @jon (see above) works. – Igor Sep 9 '16 at 6:56
  • both work, for my propose you need to put before the end description like : within the 'list''\vspace{-\baselineskip}\mbox{} \end{description} – user3284261 Sep 9 '16 at 7:05
  • I\item[1 =] force some text and more of the same text some text and more of the same text within the 'list' \vspace{-\baselineskip}\mbox{} or \item[1 =] force some text and more of the same text some text and more of the tsame text within the 'list' \vspace{-\baselineskip}\mbox{} it does not work \item[1 =] force some text and more of the ame text some text and more of the same text within the 'list' \vspace{-\baselineskip}\mbox{} or \item[1 =] force some text and more of the ttsame text some text and more of the same text within the 'list' \vspace{-\baselineskip}\mbox{} it does work. – Igor Sep 9 '16 at 8:00
  • the difference is in the length of the text. Look for word same or ame or tsame or ttsame . In other words, longer or shorter text works. Suggestion from @jon works in all cases. – Igor Sep 9 '16 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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