[Tex/LaTex] How to use table in multicols env. with paragraphs p{} and \multicolumn as well

multicolmulticolumntablestabularx

updated question

I am going to start all over. Will make the question very simple and direct. Will leave the original question below.

I simply want to see an example of using \multicolumn in a table (any table env. will do) where the whole env. is typeset in a multicols.

Here is a MWE

\documentclass[english]{article}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{multirow}
\usepackage{array}
\usepackage{multicol}
\usepackage{babel}
\usepackage[pangram]{blindtext}
\usepackage{tabularx}

%see similar question asked before
%https://groups.google.com/forum/#!topic/comp.text.tex/66SUHWPeqZY

\begin{document}
\begin{multicols}{2}

\Blindtext[2][3]
\begin{tabularx}{.9\linewidth}{@{}|X|X|@{}}\hline
%\multicolumn{2}{c} \Blindtext[1][3]\\    %%  PROBLEM AREA HERE ******
\Blindtext[1][3]&\Blindtext[1][3]\\\hline
\end{tabularx}

\Blindtext[2][3]

\end{multicols}
\end{document}

If I un-comment the \multicolumn above, then the table does not typeset correctly.
I need to use \multicolumn in the above. What do I need to do?

old question

I'd like to use \multicols{3}, where 3 can be changed another value, without having to change the Latex code for setting up table in the code below that.

I'd like to use a table (tabular or tabular* or tabularx, whatever works). But use paragraph for columns of the table (or X if it works), since I want to put text that wraps automatically, or use enumeration lists and such, so it has to be paragraph, and I also want to use \multicolumn inside the table since I want to span one row over more than one column.

I found(*) that tabularx does not work well with \multicolumn. I also found if I use \multicolumn{2} things do not work, please see second example below. So there are some conflicts, and I am not able to find the correct combination to use.

If I use tabular, I have to use give explicit size for the column with using p{2in} or such. But I do not want to hardcode the width of the columns.

Nothing I tried worked. Here are my attempts

Example 1

\documentclass[12pt,a4paper]{article}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{multirow}
\usepackage{array}
\usepackage{multicol}
\usepackage{lipsum}
\usepackage{tabularx}

\begin{document}
\begin{multicols}{2}
\noindent 

\lipsum[1]

%\begin{tabularx}{.8\textwidth}{@{}|X|X|@{}}
%\begin{tabularx}{.8\linewidth}{@{}|X|X|@{}}
%\begin{tabularx}{\hsize}{|X|X|}
%\begin{tabular*}{\hsize}{|l|p{.8\hsize}}}
%\begin{tabular*}{.8\textwidth}{|l|p{2in}}}
%\begin{tabular}{|p{1in}|p{2in}}
%\begin{tabular*}{.8\linewidth}{|p{.2\linewidth|p{.8\linewidth}}

\begin{tabularx}{.8\linewidth}{@{}|X|X|@{}}
\multicolumn{2}{c} The “lipsum” package is a more basic package. 
It generates a certain  “lorem ipsum” text\\
The “lipsum” package is a more basic package. Itlorem ipsum” text&
The “lipsum” package is a more basic package. It generates a 
certain number of the standard “lorem ipsum” text
\end{tabularx}
\lipsum[1]
\end{multicols}
\end{document}

Mathematica graphics

Example 2

removing \multicolumn{2}{c} seems to have helped.

\documentclass[12pt,a4paper]{article}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{multirow}
\usepackage{array}
\usepackage{multicol}
\usepackage{lipsum}
\usepackage{tabularx}


\begin{document}
\begin{multicols}{2}
\noindent 

\lipsum[1]
%\begin{tabularx}{.8\textwidth}{@{}|X|X|@{}}
%\begin{tabularx}{.8\linewidth}{@{}|X|X|@{}}
%\begin{tabularx}{\hsize}{|X|X|}
%\begin{tabular*}{\hsize}{|l|p{.8\hsize}}}
%\begin{tabular*}{.8\textwidth}{|l|p{2in}}}
%\begin{tabular}{|p{1in}|p{2in}}
%\begin{tabular*}{.8\linewidth}{|p{.2\linewidth|p{.8\linewidth}}
%\begin{tabularx}{\columnwidth}{@{}|X|X|@{}}
\begin{tabularx}{.8\linewidth}{@{}|X|X|@{}}
%\multicolumn{2}{c} The “lipsum” package is a more basic package&
It generates a certain  “lorem ipsum” text\\
The “lipsum” package is a more basic package. Itlorem ipsum” text&
The “lipsum” package is a more basic package. It generates a 
certain number of the standard “lorem ipsum” text
\end{tabularx}
\lipsum[1]
\end{multicols}
\end{document}

Mathematica graphics

(*) reference https://groups.google.com/forum/#!topic/comp.text.tex/WjdABHwT7-g

Best Answer

Your issues are not really related to multicol other than the fact that that changes the line width.

\noindent 

 ...

\noindent followed by \par just makes a paragraph consisting of a blank line \parfillskip glue and no text so it will look a bit like spurious vertical space, except being a line box it will not be discarded at a page break, it will not prevent the indentation of the following text.

%\begin{tabularx}{.8\textwidth}{@{}|X|X|@{}}

This would make a table .8 of \textwidth which is much wider than the column (which is less that .5\textwidth, after you account for the column separation

%\begin{tabularx}{.8\linewidth}{@{}|X|X|@{}}

This would make a table .8 of the column width. It will be indented by \parindent and may or may not reach the right edge of the column, depending if \parindent is bigger or smaller than .2\linewidth

%\begin{tabularx}{\hsize}{|X|X|}

this makes a table the columnwidth (somewhat inefficiently as you know in advance you want both columns the same width, but TeX doesn't know that) The line will be overful due to the paragraph indentation.

%\begin{tabular*}{\hsize}{|l|p{.8\hsize}}}

If you use tabular* you need to use \extracolumsep to add some stretch otherwise you are specifying a target width and give Tex no way to achieve it. (Also you should use \linewidth not \hsize.)

%\begin{tabular*}{.8\textwidth}{|l|p{2in}}}

as above .8\textwidth is too wide and you have not supplied any way to stretch the table.

%\begin{tabular}{|p{1in}|p{2in}}

This will make a table of the specified width, indented by parindent

%\begin{tabular*}{.8\linewidth}{|p{.2\linewidth|p{.8\linewidth}}

as above you can not use tabular* like that.

\begin{tabularx}{.8\linewidth}{@{}|X|X|@{}}

As above this would make a table .8\linewidth indented by \parindent.

%\multicolumn{2}{c} The “lipsum” package is a more basic package&

The text should be in the argument to \multicol

%\multicolumn{2}{c}{The “lipsum” package is a more basic package}&

and as you have specified c the cell will not break over a line.

See for example this answer for ways to specify the column widths taking account of cell padding and rule widths

https://tex.stackexchange.com/a/150987/1090

Related Question