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}
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}
(*) reference https://groups.google.com/forum/#!topic/comp.text.tex/WjdABHwT7-g
tabularx
(and\multicolumn
) have no connection tomulticols
I can't imagine why you saytabularx
doesn't work withmulticol
it neither works with it or not work with it, it's simply unrelated.