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

user15964
  • 865
  • 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. – David Carlisle Dec 01 '15 at 07: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 01 '15 at 08: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) http://tex.stackexchange.com/questions/232245/how-to-implement-common-layouts-instead-of-misusing-tabular-environments/232268#232268 – David Carlisle Dec 01 '15 at 09: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. – David Carlisle Dec 01 '15 at 09: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 01 '15 at 10:16
  • @DavidCarlisle Thank you for your link. I read all the links, forgive me, I am still getting nowhere. The information is just too dispersive, we question poster can't form a conclusion from these posts within a reasonable time. It seems that you are suggesting me to abandon table in this case, but this is not going to be, because this is the format request ! And I don't understand "Splitting a table mid-row is just massively under-specified". I have add an image of MS word, could you please give me an answer on whether this can be done? I think it can be done, because word can, but how? – user15964 Dec 01 '15 at 10:23
  • @murugan Thank you for comment, murugan. But I am in trouble with understanding process you mentioned in your comment. Would you like to make it an answer? – user15964 Dec 01 '15 at 10:40
  • No it can not be done using a table, tables only split between rows. To split mid row you can of course do it "by hand" by ending the list and the table row and the starting a new table row with the rest of the list. To do it automatically use a list at the outer level not a table. – David Carlisle Dec 01 '15 at 10:41
  • @DavidCarlisle If I end list, how can those leading number continued? – user15964 Dec 01 '15 at 10:50
  • just set \setcounter{enumi}{6} after the \begin{enumerate} or the enumitem package gives the environment a resume option to make it carry on from the previous. – David Carlisle Dec 01 '15 at 10:54
  • @DavidCarlisle A technical question, I always thought latex as a general typesetting programming language, so I think the feature I mentioned should able be realized, but just currently not available, right? – user15964 Dec 01 '15 at 12:31
  • The feature is not, in general, possible (in any system) but some simple cases could be accommodated, but in almost all those cases the input would be better marked as a list, so it is a rather low priority. – David Carlisle Dec 01 '15 at 13:02
  • @DavidCarlisle Ok, but how to use list mimic the appearance and properties of table? I am not seeing a comprehensive answer on this. Fischer has already provide a workaround using list and tcolorbox, but his answer is not complete. for exmaple, I am still struggling with wrapping of items, don't know how to do it. And what about more than two columns, Fischer didn't give – user15964 Dec 01 '15 at 13:09
  • Sorry I'm just repeating myself (so will stop here). Ulrike's answer is the answer for the example you gave. she is accurate as ever:-) For multi-column tables there is no general reason to believe that you can split all columns at the same point, so there is no general solution, you have to look at each example individually. – David Carlisle Dec 01 '15 at 13:22
  • @DavidCarlisle Thank you! I know I am annoying now. But I can't help asking more, I am just eager to know something. It is up to you to answer this or not when you are convenient : ) What does " For multi-column tables there is no general reason to believe that you can split all columns at the same point" mean? Do you mean split horizontally? I think there is always a column contains more contents than others and runs longest, we just split at that point. Why is this a problem? The real problem is how to make multicolumn list? – user15964 Dec 01 '15 at 13:59
  • @DavidCarlisle I think if table is not suitable for this task, and in really life, we really need this kind of format. We'd better make a single answer gather all the information on "How to use list to mimic longtabu in as every aspect as possible to solve problems such as long text in a single row, multicolum, width of column, wrapping" instead of the link you have provide. All people seeing your link will take a long time to gather all the information scattered in different post and still probably getting nowhere just like me. – user15964 Dec 01 '15 at 14:00
  • @DavidCarlisle So compressing the dispersive information we effectively increased the information bandwidth, saving time for all people who encountered this problem. – user15964 Dec 01 '15 at 14:00

1 Answers1

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

Ulrike Fischer
  • 327,261
  • 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 01 '15 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. – Ulrike Fischer Dec 01 '15 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 01 '15 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. – Ulrike Fischer Dec 01 '15 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 01 '15 at 15:27
  • I opened a new question here http://tex.stackexchange.com/q/281014/32004 welcome to leave comment – user15964 Dec 01 '15 at 16:56