2

The following is the problematic example:

\documentclass[12pt]{article}
\usepackage{longtable}
\usepackage{tabu}
\usepackage{array}
\usepackage{lipsum}

\begin{document}
{\setlength{\tabulinesep}{3pt}  
\begin{longtabu}to \textwidth { | m{2cm} | X[c] | }
        \hline
        Item & item \\
        \hline
        Item & 
        \begin{enumerate}
            \item \lipsum[1]
            \item \lipsum[2]
            \item \lipsum[3]
            \item \lipsum[4]
        \end{enumerate}\\
        \hline
\end{longtabu}
\end{document}

It generates two pages

enter image description here enter image description here

There are two problems:

  1. The enumerate list is split with first row, leaving the first row in the first page lonely.
  2. The enumerate list is directly running out of the second page. How to solve this in longtabu?

Can't latex just achieve the effect of MS word? In MS word, you just keep typing with list like, and they automatically across the page like this

enter image description here

17
  • table rows can not split. Such a layout would be better set as a list than a table, then it could naturally split within an item. Dec 1, 2015 at 7:57
  • @DavidCarlisle Hi, David. Thank you for comment. But I really don't know why you mark this as duplicate, after I read your link. I am still getting nowhere. And your comment seems telling me that Latex can't do thing that MS word can do easily. I can't believe it.
    – user15964
    Dec 1, 2015 at 8:56
  • I think it's a duplicate of this one (or any of the ones referenced), but I removed the close vote to give others to vote (so as not to over-use my gold badge immediate-close) tex.stackexchange.com/questions/232245/… Dec 1, 2015 at 9:04
  • Latex can split nested lists, which is what your document needs, but it can only (easily) split a table between rows. Splitting a table mid-row is just massively under-specified, it looks easy in your picture (because it is a list) but imagine a real table with data (or even images) in every column, there is no way in general to find a break point that will break every column at the same place. Dec 1, 2015 at 9:06
  • Use the same longtabu environment twice with only two items in enumerate environment as you can split the list item wise. Now header row and two items will appear in the first page. use '\clearpage' command and use again longtabu environment to get the desired result with the remaining two items
    – murugan
    Dec 1, 2015 at 10:16

1 Answer 1

6

Avoid tables for this type of layout. In most cases you can achieve similar effects by nesting normal lists, and if you really need a frame you can use tcolorbox:

\documentclass[12pt]{article}
\usepackage{lipsum,enumitem}
\usepackage[many]{tcolorbox}

\begin{document}
\begin{tcolorbox}[breakable,sharp corners,
                  colback=white,
                  overlay={\draw[dashed] ([xshift=1.7cm]interior.north west)--([xshift=1.7cm]interior.south west);}]
\begin{description}[leftmargin=1.5cm,labelwidth=!]
\item[item] item 
\item[item] 
        \begin{enumerate}
            \item \lipsum[1]
            \item \lipsum[2]
            \item \lipsum[3]
            \item \lipsum[4]
        \end{enumerate}
\end{description}        
\end{tcolorbox}
\end{document}

enter image description here

6
  • Thank you so much, I have to lookup for tcolorbox. But some quick questions: how to add horizontal line? Is this method support more than two columns? Can each columns' width be specified?
    – user15964
    Dec 1, 2015 at 11:12
  • 1
    You can add horizontal line with \tcbline or by using the full power of tikz. You can adapt the width by changing the list parameters. Three columns can be done, but only one column should contain long text (and so naturally be quite large). But don't try to press everything in a table layout and don't add lines everywhere - most word tables are quite horrible. Dec 1, 2015 at 11:57
  • Oh, god! I resign. I was trying to figure out how to set the wrap for fixed width \item[longtext], after reading doc of enumitem, I still don't know how to do it. Would you help me?
    – user15964
    Dec 1, 2015 at 15:01
  • You can use \begin{description}[leftmargin=1.5cm,labelwidth=!,style=multiline] to get multiline items. You can also use e.g. marginnote to put text in the margin. If you have more problems you should better open a new question. And I really wished people would check my gender instead of simply assuming that everyone who gives a sensible answer must be a man. Dec 1, 2015 at 15:12
  • Thank you so much! I do have new problem now. I will open a question, and hope you would help me. I am really sorry for not checking your gender. I am not familiar with western name, but now I try to read your name again, it is really a beautiful name : ) Forgive me
    – user15964
    Dec 1, 2015 at 15:27

You must log in to answer this question.

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